[thelist] SQL query statement help

rudy r937 at interlog.com
Mon Dec 9 18:39:00 CST 2002


nice design, chris, very nice examples

one wee point (and i admit it's more style than substance)

in the item table, you have

> -> item_type_id (foreign key from item_types)

instead of from, i prefer to say to

it's a foreign key to the item_types table

what you intended was, and i'm guessing, is that the values in this column
in the item table are values that originated in the primary key in the
item_type table, and that would be correct

in practice, this is borne out by the need to create the primary key in the
item_type table first, after which it can be used in foreign keys

to me, the key question for each item is "which item type is this item?"

the answer is "that one over there"

in other words, the foreign key points to the primary key

this is reinforced by the syntax FOREIGN KEY foo REFERENCES bar

this in turn reminds you (well, it does me, anyway) that you can have
multiple foreign keys pointing to the same primary key

multiple iteme can reference the same item_type

the foreign key is in the child, and points to the parent


rudy




More information about the thelist mailing list