Questions about Primary Keys, Foreign Keys and Sub-forms
Posted: Thu Jan 03, 2013 5:05 am
Hi,
I realize that my questions may be beyond the scope of this forum.
As you know from previous posts, I now know how to add primary keys to a table as I am loading the data using uniqid(). I am now ready to add a foreign key to a table and join them. I need some direction.
I have 2 tables. One lists all of the units in a building. The second table lists which units have violations and up to 3 rows of information per violation. (Each violation can have up to 3 warnings and there can be multiple different violations per unit.) The user would look at a browse screen of units, choose a unit which would open the sub-form, showing all of the violations for that unit. The user could then update a violation or add another warning or even a new violation.
Both tables have a primary key that was created when loading the data. I assume the violations table would also have a foreign key pointing back to the units table.
How does the foreign key get populated in the violations table?
Since the primary key and the foreign key do not include the unit number, how do the rows get linked?
I have read many of the posts on foreign keys and looked at wiki and videos and am still confused. I understand bits and pieces but not how they all come together. In addition to this web site, are there other places I should look at to get a better feel for how it all fits together?
Thanks,
John
I realize that my questions may be beyond the scope of this forum.
As you know from previous posts, I now know how to add primary keys to a table as I am loading the data using uniqid(). I am now ready to add a foreign key to a table and join them. I need some direction.
I have 2 tables. One lists all of the units in a building. The second table lists which units have violations and up to 3 rows of information per violation. (Each violation can have up to 3 warnings and there can be multiple different violations per unit.) The user would look at a browse screen of units, choose a unit which would open the sub-form, showing all of the violations for that unit. The user could then update a violation or add another warning or even a new violation.
Both tables have a primary key that was created when loading the data. I assume the violations table would also have a foreign key pointing back to the units table.
How does the foreign key get populated in the violations table?
Since the primary key and the foreign key do not include the unit number, how do the rows get linked?
I have read many of the posts on foreign keys and looked at wiki and videos and am still confused. I understand bits and pieces but not how they all come together. In addition to this web site, are there other places I should look at to get a better feel for how it all fits together?
Thanks,
John