- What kinds of relationships can we represent in a database?
One to one, one to many/many to one, many to many and self-referencing relationships
- When do we use “One to One” relationships? Give an example from the real world.
This is used for simple relationships for example the address of a specific grocery store.
- 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?
This is a foreign key. It is used as a reference id to retrieve the customer id data and provides the possibility to connect customers to addresses
- Give an example from the real world when would need to use a “Many to One/One to Many” relationship.
For example to index the grocery basket of a customer
- Give an example from the real world when would need to use a “Many to Many” relationship.
For example indexing taxi rides from several clients for many different taxi drivers.
- What does items_orders table do?
It shows the ID of an ordered item in connection to the ID of an order of a customer