Newbie to RDBMS, Informix...E/R modeling question
Posted in 1996
Topics: Triggers, Constraints & Referential Integrity
I'm trying to create a "contacts" database with SE V6.01 or so...
I'm new to Relational database theory, and to Informix as well.
I'm educating myself with the Informix manuals, and Date, C. J.,
_An Introduction to Database Systems_, 1996.
The Informix Tutorial suggests a need to resolve many-to-many
entity relationships with an intersection table. I'm having trouble
determining how to populate/update the database if the original
base relations no longer have foreign keys.
For example, say I have the relations "name" and "address"; each name
can have multiple addresses of different types (postal,physical,home,etc.),
and each address can be associated with one or more names.
So say I create these tables with the following SQL fragments:
create table name
(
rec_num serial,
orgname char(20),
lname char(20),
fname char(20),
middle char(20),
handle char(10),
name_type char(10),
primary key (rec_num)
);
create table address
(
addr_idx serial,
orgname char(20),
mailstop char(20),
street char(20),
city char(20),
state char(2),
postal_code char(10),
country char(20),
addr_type char(10),
rec_num integer,
primary key (addr_idx),
foreign key (rec_num) references name (rec_num)
);
Now, if I want to insert an address associated with a person, in this
format it's a simple matter to derive address.rec_num = name.rec_num
by SELECTing on "lname" and "fname" in "name".
BUT...if I do as suggested in the tutorial, and move the foreign keys
to a new base relation which is the intersection of the two original
relations, what technique can I use to populate the "address" table
then? How do I associate unordered records in the two original base
relations "name" and "address" with each other, when there are no longer
any foreign keys to use? I mean, how do I create/derive the
intersection when one of the tables is still empty?
I must be missing some concepts still.
C.J. Date apparently doesn't think much of the Entity/Relationship
model. But it's considerably easier for me to follow what I'm doing
with diagrams (pictures) rather than some relational algebra
or calculus :o)
Thanks for taking the time to read this long-winded post!
--
David Carmean <dlc@silcom.com>
Silicon Beach Communications, Santa Barbara, California +1-805-730-7740
Opinions herein are those of the author only, unless otherwise noted