1. What kinds of relationships can we represent in a database?
There are many kinds, some of them are
- One to One Relationships
- One to Many and Many to One Relationships
- Many to Many Relationships
- Self Referencing Relationships
2. When do we use “One to One” relationships? Give an example from the real world.
This kind of relationship is not very common, but an example can be the ID each citizen has. Because each citizen has its own ID and each ID correspond to only one citizen.
3. In the article in the “One to One”-section, the author of the article has a column called customer_id in the customers table. Why? How is it used in order to connect customers to addresses?
It is used as a foreign key in the adresses table to make the relation between the customer and the adress wich is stored in another table.
4. Give an example from the real world when would need to use a “Many to One/One to Many” relationship.
An example can be all my utensils inside my pencil-box. I have many different utensils which they only belong to me (One-to-Many). All those utensils have one owner which is me (Many-to-One). @thecil is that correct?
5. Give an example from the real world when would need to use a “Many to Many” relationship.
Many-to-Many examples are when the object/item/product/etc. can be shared. In the morning breakfast I can eat cereal and have coffee, my brother can drink orange juice and my father can also have coffee.
6. What does items_orders table do?
The items_orders is specifically make as a “Many to Many” relationship between the items and the orders.