Reputation: 10815
I have a question, if two tables in database are from different entities then how we define relationship between them. i mean can we use some foreign key or any thing to define relationship between them. or we have to create a third table
Upvotes: 0
Views: 126
Reputation: 57063
There is a design principle that states that a table either defines an entity or a relationship but not both. Therefore, use a third table to model the relationship between your two entities -- yes, even if it is 1-1 or 1-N -- noting that the relationship itself may have its own attributes.
Upvotes: 0
Reputation: 6684
It depends on what kind of relationship you have. If it´s a 1-1 or 1-N then you will only add foreign key column on the respective table. If you need a N-N (aka N-M) you will need a third table.
Upvotes: 2