What kinds of relationships can we represent in a database?
One to one relationships, one to many / many to one relationships, many to many relationships, and self-referencing relationships.
When do we use “One to One” relationships? Give an example from the real world.
When each element can relate to only one other element, it is one to one. For example, an address belongs to only one customer or an email belongs to only one user.
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 that helps with relationships.
Give an example from the real world when would need to use a “Many to One/One to Many” relationship.
A unique customer at an ecommerce site who has many attributes, such as username, address, payment information, orders, etc.
Give an example from the real world when would need to use a “Many to Many” relationship.
A social network user who has multiple entries, multiple friends, and multiple entry comments.
What does items_orders table do?
Creates a many to many relationship between items and orders (ex. orders each with different items).