SQL Relationships - Reading Assignment

1 id=name,adresse+order or no order
2 name and address
3 the customers id functions like a key that only this customer can have like 101
4 like writing reviews on trustpilot for your academy you or mother and children
5 in a football game 11 players and the ball, fouls, outs, goals or statistics against the other 11 players
6 write what got ordert from the costumer_id

  1. What kinds of relationships can we represent in a database?

    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.
    When the entry is use for only one customer.Than can be personal information about one person.

  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?
    This is called a “Foreign key” And, yes, Is to refers to the matching record in the Address table.

  4. Give an example from the real world when would need to use a “Many to One/One to Many” relationship.

    Customers can make many orders.
    Orders can contain many items.
    Items can have descriptions in many languages.

  5. Give an example from the real world when would need to use a “Many to Many” relationship.
    Some cases we need multiple instances on both sides of the relationships, that contain multiple items.

  6. What does items_orders table do?
    The Items_Orders table has only one purpose, and that is to create a “Many to Many” relationship between the items and the orders.

1 Like

1. What kinds of relationships can we represent in a database?

Hello sir. those are not a relationship for a database, maybe you want to redesign your answer :slight_smile:

If you have any more questions, please let us know so we can help you! :slight_smile:

Carlos Z.

one to one, one to many, many to many and self referencing relationships.
2.
when a single piece of information has a unique relationship with another piece of information. An example could be all dieren colors of balloons picked by different children at a birthday party.
3.
this is the foreign key used in database relationships identifying a record in a table.
4.
an example of a one to many relationship is a person and his socks. one person can have multi pairs of socks, while the socks only have one user.
5.
a person can do his shopping soon at multiple stores, but these stores also have multiple customers.
6.
The Items_Orders table has only one purpose, and that is to create a “Many to Many” relationship between the items and the orders.

2 Likes
  1. What kinds of relationships can we represent in a database?
    1 to 1, 1 to many, many to many and relationship

  2. When do we use “One to One” relationships? Give an example from the real world.
    To find a customer birthdate to send discount code or promotion.

  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?
    “Customer id” is the numerical value given to a user name, and it can be quarried to produces information about that customer.

  4. Give an example from the real world when would need to use a “Many to One/One to Many” relationship.
    A customer ordering off Amazon.

  5. Give an example from the real world when would need to use a “Many to Many” relationship.
    A referral code for Robinhood

  6. What does “items_orders” table do?
    “Items_orders” show items purchased by a customer and the amount of that purchases. It creates a may to many table of item’s relationship to orders.

1 Like
  1. Database can represent following relations:
    one to one
    one to many or many to one
    Many to Many
    Self-referencing

  2. One to one relationships when only one field can belong to one record
    ex. Employee and TAX ID number

  3. The customer ID is a"foreign key". It is used for reference purposes of all data

  4. One account number (customer number) can have many different orders or
    an Order have many items

  5. Many students take many courses or many courses have many instructors

  6. It shows relation between orders and items (many to many relation).

1 Like
  1. What kinds of relationships can we represent in a database?
  • One to One Relationships
  • One to Many and Many to One Relationships
  • Many to Many Relationships
  • Self Referencing Relationships
  1. **When do we use “One to One” relationships?

When one data set have to be unique.
Give an example from the real world.**
Customer name with an address
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?
4. Give an example from the real world when would need to use a “Many to One/One to Many” relationship.
5. Give an example from the real world when would need to use a “Many to Many” relationship.
6. What does items_orders table do?

Following is the kind/type of relationship represented in SQL DB.
One to One Relationships
One to Many and Many to One Relationships
Many to Many Relationships
Self Referencing Relationships

Whenever we have a situation where one set of info will result one set of info would be “one to one” relation. My name and my SSN is a 1to1 relation.

By giving each customer a unique identification number or customer ID one can organize data in more efficient manner. Customer address can now be looked up using customer ID number.

When I send an email to company group by selecting a single email address it goes to all company employees, would be a one to many relation.

The item_order create a “Many to Many” relationship between the items and the orders.

1 Like
  1. What kinds of relationships can we represent in a database?

Answer:

-One to One Relationships
-One to Many and Many to One Relationships
-Many to Many Relationships
-Self Referencing Relationships

  1. When do we use “One to One” relationships? Give an example from the real world.

Answer: Usually when we marry.

  1. 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?

Answer: The customer_id is unique, therefore; only one address per customer_id.

  1. Give an example from the real world when you would need to use a “Many to One/One to Many” relationship.

Answer: You use “Many to One/One to Many” relationships regarding orders from Amazon.

  1. Give an example from the real world when you would need to use a “Many to Many” relationship.
    What does items_orders table do?

Answer: All the families ordering at a restaurant any given time. It seperates and distinguishes between order_id and item_id.

1 Like

Hello sir, did you forgot to answer those questions?

If you have any more questions, please let us know so we can help you! :slight_smile:

Carlos Z.

  1. Types of Database relationships; One to One Relationships, One to many to one Relationships, Many to Many Relationships, Self Referencing Relationships
  2. An example is address in the database that represents the customer, since only ONE address belongs to a customer that creates a “One to One” relationship.
  3. This is called a “Foreign Key” and it is used for all kinds of database relationships. It will duplicate an attribute from the table.
  4. A One to Many and Many to One Relationship, example could be a person buying several items, 1 order can contain many items, and items can come from several different vendors.
  5. For instance the same order going to several customers in the database.
  6. The items_orders table has only one purpose and that is to create a “Many to Many” relationship between the item and the orders
1 Like
  1. one to one relationships, one to many and many to one relationships, many to many relationships and self referencing relationships
  2. When an entry/field can belong to only one customer.
    Example: A persons passport number.
  3. It is a foreign key used for all kinds of database relationships.
  4. Ordering food on Uber Eats. Each user can order multiple Uber Eats orders. The Uber Eats orders can contain many items. But this order can only belong to one customer.
  5. University classes. Each person can take many classes. Each classes can be taken by many people.
  6. It is used to create a ‘Many to Many’ relationship between the items and orders
1 Like
  • What kinds of relationships can we represent in a database?
    We can represent One to One Relationships, One to Many and Many to One Relationships, and Many to Many Relationships.

  • When do we use “One to One” relationships? Give an example from the real world.
    We use a One to One relationship when one item and be connected to only one item. An example of this can be in a table that lists people and their Social Security Number (SSN), as is in the United States. There could only be a One to One relationship in this case because everyone has their own SSN.

  • 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_id refers to the matching record in the customers table. In the article, the author refers to it as a foreign key and it is used for all kinds of database relationships.

  • Give an example from the real world when would need to use a “Many to One/One to Many” relationship.
    An example of a Many to One/One to Many relationship would be in Ivan On Tech Academy, how many courses did Student A complete in the Academy/how many students completed the course titled Blockchain Business Masterclass.

  • Give an example from the real world when would need to use a “Many to Many” relationship.
    Keeping in the context of Ivan On Tech Academy, the number of students enrolled in the Academy compared to the number of courses available in the Academy. You can further establish how many of those enrolled students participate in the Altcoin Secret Newsletter as well as how many of those go on to careers in web development as a result of being in the Academy.

  • What does items_orders table do?
    The Items_Orders table creates a “Many to Many” relationship between the items and the orders.

1 Like
  1. What kinds of relationships can we represent in a database?
    One on one, one to many and many to one, self referencing, many to many

  2. When do we use “One to One” relationships?
    Give an example from the real world.
    For example when sending an email to one person.
    From my mailaddress to another persons mailaddress.

  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’s called foreign key. It’s role is to enforce
    referential integrity between data in two tables.

  4. Give an example from the real world when would
    need to use a “Many to One/One to Many” relationship.
    For example when many people order the same kind of product or
    like when many clients make a lot of orders

  5. Give an example from the real world when would
    need to use a “Many to Many” relationship.
    Might be like this academy? Many people can attend to many
    of your different courses and each of your course can have many students.

  6. What does items_orders table do?
    It shows which types of items that are connected to the order.
    The goal is to create many-to-many relationships in between like;
    customer, customer_id and order-id.

1 Like
  1. One to One
    One to Many/Many to One
    Many to Many
    Self Referencing

  2. Each email address can only belong to one person.

  3. Each customer in the CUSTOMERS table is assigned a unique customer ID, which is listed in the customer_id column. Each address is also assigned a unique ID and is listed in the address_id column in the CUSTOMERS table and refers back to the addresses on the ADDRESSES table - this is called a foreign key. The customer_id and the address_id form a One to One relationship between the customer and their address.

  4. A restaurant can have many customers, each customer can order many dishes and each dish can have many ingredients.

  5. Each dish on the restaurant’s menu contains many ingredients and each ingredient can be used in many different dishes on the menu.

  6. Creates a Many to Many relationship between the items and the orders.

1 Like
  1. What kinds of relationships can we represent in a database?
  • One to One Relationships
  • One to Many and Many to One Relationships
  • Many to Many Relationships
  • Self Referencing Relationships
  1. When do we use “One to One” relationships? Give an example from the real world.
    1 house has 1 roof

  2. 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?
    customer ID’s are joined with adress ID’s to form a new table

  3. Give an example from the real world when would need to use a “Many to One/One to Many” relationship.
    1 rainbow has many colors
    1000 people at 1 party

  4. Give an example from the real world when would need to use a “Many to Many” relationship.
    many orders have many items
    and vice versa

  5. What does items_orders table do?
    create a many to many relationship between items and orders

1 Like
  1. one-to-one / one-to-many / many-to-many
  2. When their can only be one relationship between two items. For example a user ID linked to a social security number
  3. A FOREIGN KEY is a key used to link two tables together. Through this link items can be changed in separate tables without having to change them in all tables.
    Customer details like addresses are stored in a second table. In the orders table the customer ID is used linking them with a foreign ket to the customer details table.
  4. For a webshop situation. Many customers register in order to buy items in the shop. One item in the store can be linked to many customers.
  5. When multiple orders in the webshop from multiple customers consists of multiple items.
    6.The Items_Orders table has only one purpose, and that is to create a “Many to Many” relationship between the items and the orders.
1 Like
  1. What kinds of relationships can we represent in a database?
    One to One
    One to Many
    Many to One
    Many to Many
  2. When do we use “One to One” relationships? Give an example from the real world.
    Each transaction at a store has only one customer. One transaction is tied to One customer.
  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?
    This creates a new “Foreign Key” and used to manage and identify relationships that are not naturally created in a data set.
  4. Give an example from the real world when would need to use a “Many to One/One to Many” relationship.
    One person may have many siblings, while many siblings will have only one mother.
  5. Give an example from the real world when would need to use a “Many to Many” relationship.
    A car maker may have Many models of cars and Many parts that are used in the Many cars.
  6. What does items_orders table do?
    The “items_orders” is used to create relationships of Many items in individual orders to the Many orders in which they occur.
2 Likes
  1. The types of relationships we can represent in a database include:
  • One-to-one
  • One-to-Many
  • Many-to-Many
  • Self-Referencing
  1. One-to-one relationships are mainly found when dealing with addresses. One person (typically) has only one address, and that one address (sometimes) has only one person.

  2. The customer_id column in the table is used as a foreign key, to allow other databases to access data.

  3. One-to-many relationships are common in the world of online shopping. One customer can have many orders.

Similarly, Many-to-one relationships are common in this industry. Many customers may order the same type of one item.

  1. Many-to-many relationships are again found whilst internet shopping. Many orders contain many items, whilst many (of the same type of) items can be found in many (different) orders.

  2. The items_orders table “has only one purpose”: to create the many-to-many relationships needed between items and orders. Then our “Orders” table need only include:

  • Order ID
  • Customer ID
  • Order Date
  • Total Price
1 Like

a) One to One
b) One to Many
c) Many to Many
d) Self Referencing

  1. One to One relationships have a key and a value. For example a User and a Highscore.

  2. The customer_id column is used to represent each unique customer and be used as a foreign key in another table, like the address table.

  3. I can have multiple different Bitcoin addresses, but they all belong to one person (me).

  4. A list of cryptocurrency YouTubers and their subscribers. Each YouTuber has many subscribers and each subscriber can be subscribed to multiple YouTubers.

  5. The items_orders table links the order to each item in the order.

2 Likes