What kinds of relationships can we represent in a database?
When do we use “One to One” relationships? Give an example from the real world.
A one2one relationship example could be for instance a gym membership where a customer’s name, DOB and address would all belong to one person in a table.
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?
The customer’s I.D in the customer’s table is sufficient as “customer i.D.” stores the value of the customer name and address.
Give an example from the real world when would need to use a “Many to One/One to Many” relationship.
An Amazon account where a customer has many orders of items.
Give an example from the real world when would need to use a “Many to Many” relationship.
This example can work great for someone who has an account with a builders merchant for building materials for their business as there could be multiple items of the same items also spread across multiple orders.
6 1. What does items_orders table do?
This entity does nothing more than create a many2many relationship between items and orders.