Quote:
|
Originally Posted by mtbadfish
How do I get the PK from one table entered as a FK in another?
|
if you are using auto_incrtement columns, you would do this using the LAST_INSERT_ID() function
Quote:
|
Originally Posted by mtbadfish
Do I want FK's from Participant (part_id)and Address (add_id) added to the Event table?
Or do I want the Event (event_id) fk added to the other tables?
|
it does get confusing sometimes
okay, here's a rule of thumb that should help you
if an event can have multiple participants, but a participant have only one event, then event-to-participant is a one-to-many relationship, and the foreign key goes into the "many" table, the participant
if a participant can have multiple events, but an event have only one participant, then participant-to-event is a one-to-many relationship, and the foreign key goes into the "many" table, the event
if an event can have multiple participants, and a participant have multiple events, then event-to-participant is a many-to-many relationship, and you need a 3rd "relational" table between them