25.07.2013, 10:04
Quote:
I know the tutorial is on foreign keys, but the type of relationship is important with this
|
Let's say you have a "users" and a "items" table. The logical reasoning is, "a user HAS items", or more importantly "1 user has many items". Or if you want to be absolutely correct, and this is very important while designing a database, "1 OR 0 users CAN HAVE 0 or more items". When you transorm this into a ERD and later into a logical and normalized database you'll automatically end up with a 1-to-many table. As in, 1 "user" can have many "items". It's pure logic, you end up with a certain relation type just because there is not other way of doing it.
Asking which relation you should use is not a fair question. Instead, ask yourself how your data should be organized and what relation they ave to each other.
Database Design is for most people here a quite advanced topic, but I'm glad it's being brought up because if you work with a relational database there really is nothing more important.