Where should I place the primary key and foreign key
You will end up with more than one of each. Each table should have a primary key which uniquely indentifies each record in that table. Any table that has a relationship to another table based on the primary key field of the other table will have a foreign key to match to the primary key in the related table. that much is a start at least.
thanks. Yes... i´ve done that, but i think i must have at least one more table for the many-to-many cases. and that is my bigger problem, where should i create and who many tables more hsould i create?
Thanks for your help.
Resolving many-to-many relationships is best done with a join table. The join table is a little different in that it exists not for the recording of data, but to manage the relationships between data from other tables. An example might be Users & groups, 1 user could be in many groups and many users could be in a group or stated in other words many users can be in many groups. The join table GroupUsers would only have foreign keys one to Groups and one to Users, but no primary key because each record exists only to connect the two. So to add / remove a user from a group boils down to adding or deleting a record ( userid & groupid combination ) from the join table.
Hope this helps,
Message was edited by: timwhisenant
Thanks, i think i understand