-
What kinds of relationships can we represent in a database?
One to One, Many to Many, One to Many & Many to One, and self referencing -
When do we use “One to One” relationships?
Given the example in the article a customer would have ONLY a single address. -
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 ensure that each customer row is unique. It allows for the customer and address data to be joined together. Note the foreign key customer_id on the address table. -
Give an example from the real world when would need to use a “Many to One/One to Many” relationship.
Multiple person attending a single sporting event. In this example a there will be multiple person entities tied to a single event or event_ID -
Give an example from the real world when would need to use a “Many to Many” relationship.
Products to Purchases . Each purchase can have many products. Purchase can have many product. -
What does items_orders table do?
The items_order table is an order manifest. Per the book. It creates an many to many relationship between items and orders.
- One to one, one to many/many to one, many to many, and self referencing.
- A passport number can only be issued uniquely to one person.
- This is done to uniquely identify the customer (a key). It is done so another table can use the key as a column to create a relationship with the two tables. In the case, of connecting customers to addresses the customer_id can be referenced in the addresses table.
- A group of people that share the same interest.
- Web page sessions in relation to web pages visited.
- It establishes the item ids that are related to an order id.
-
One to one, one to many, many to many, many to one, self referencing
-
A simple address book
-
Both tables share a common field, address_id. Customer_id is associated with the address_id in each record within the customers table. To find the related address for a customer, you use the common key, address_id
-
An ecommerce website. A customer may have many orders. But an order with many items can only be related to one customer
-
An ecommerce site where many items are being sold to many customers.
-
The items_orders table has the key fields to relate the items and orders tables together
- What kinds of relationships can we represent in a database?
One to one / one to many / many to one / many to many / self referencing - When do we use “One to One” relationships? Give an example from the real world.
When one record in a table can only be linked to one record in another table. E.g. Name to passport number - 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 faster to read when all of the IDs are the same length. Used to associate them - Give an example from the real world when would need to use a “Many to One/One to Many” relationship.
A mother might have a bunch of children attending school. Each child would have the same mother in the school records. - 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?
Item Orders take many table inputs that are id’s and place them in a table which have id’s only
- 1-1, 1-many and many-1, many-many, self referencing
- when we combine one piece of information with another, like linking an email to a user.
- Because the customer_id is linked to the address, foreign key
- When a customer makes an order for many items
- When many customers makes orders for many same items
- To make many to many relationships possible
- One to One Relationships, One to Many and Many to One Relationships, Many to Many Relationships and Self Referencing Relationships
- Customer name and Phone number
- It is a Foreign key and guarantees a connection between customers and address by referencing other records in another table
- Many to one: Multiple children of the same father, One to many: One person having multiple E-Mail addresses
- Customers and T-shirts: Multiple customers can buy multiple different types of T-shirts, and multiple T-shirt type can be in multiple customers possession
- It creates a “Many to Many” relationship between items and orders.
-
What kinds of relationships can we represent in a database?
One to One
One to Many
Many to Many
Self referencing -
When do we use “One to One” relationships? Give an example from the real world.
When one entry is linked exclusively to another entry. Student number - Student -
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?
To link a customer with an exclusive number in order to make an exclusive link. It is used as a foreign key. -
Give an example from the real world when would need to use a “Many to One/One to Many” relationship.
One user, many facebook pictures. -
Give an example from the real world when would need to use a “Many to Many” relationship.
Human relationships. Bob has many friends wich have friends that have friends and might also be Bob’s friends. -
What does items_orders table do?
It links two tables and create a many to many relationship
-
One-to-one relationships, one-to-many relationships, many-to-one relationships, many-to-many relationships, self-referencing relationships.
-
One row in a table is linked to only one row in another table. E.g. a country has only one capital city, and the capital city is linked to only this country.
-
It is used to abstract the process. Customer id can directly reference to the address id.
-
One book can have many pages, one specific page can only be in one book.
-
An author can write several books, and a book can be written by several authors.
-
It creates a many-to-many relationship between the items and the orders.
-
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 -
When do we use “One to One” relationships? Give an example from the real world.
A person and his email address. (assuming he only has one email address) -
In the article in the “One to One”-section, the author of the article has a column called customer_id in the customers table.
3.1 Why?
It identifies the row of the table. It is the primary key.
3.2 How is it used in order to connect customers to addresses?
A foreign key is defined on that row called address_id. The foreign is used to identify a row of another table.
-
Give an example from the real world when would need to use a “Many to One/One to Many” relationship.
– Many to one: Several family members having the same address.
– One to many: A person having many friends. -
Give an example from the real world when we would need to use a “Many-to-Many” relationship.
Several family members having mutual friends. -
What does items_orders table do?
It creates a many-to-many relationship by linking a table ID to another table ID.
-
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. -
When do we use “One to One” relationships? Give an example from the real world.
When only one item in table a can relate to one item in table b. For example, each user can only have one email to login. -
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 gives each customer a number so that query is easier and faster for computer to run. Each id is connected to address so they can be linked and information is not repeated. -
Give an example from the real world when would need to use a “Many to One/One to Many” relationship.
If user ordered many products or if product existed in multiple colors. -
Give an example from the real world when would need to use a “Many to Many” relationship.
You can have many orders and each can have many items. So if I wanted to see how many orders I got in the last week and what items were ordered, that would be many to many. -
What does items_orders table do?
It gives what items were ordered, when, by whom, how many, revenue, maybe even order status, etc
1
One to one, one to many and many to one, many to many, self referencing.
2
Name, work mobile phone in the address book db.
3
It’s used as a “foreign key”: He created another table with addresses and defined each row with an id, so each table has the related id in the key column.
4
Passport number, many visas numbers
5
Different orders contain many items but a single product is choosen during many orders.
6
It defines all the orders during which an item was picked up. Example of many to many relationship.
1 One to one relationships; one to many and many to one relationships; many to many relationships; and self referencing relationships.
2a When there can only be one relationship between other entries. 2b like a social security number for a customer can only be for that one customer.
3 it’s used as a foreign key for another table to help you locate the remaining data that pertains to that entry.
4 like when one customer can have many different items in their cart.
5 when there are many houses owned by multiple subsidiaries that own partial shares in the various properties.
6 to create many to many relationships for items and orders.
-
What kinds of relationships can we represent in a database?
One to one, one to many, many to one and one to self. -
When do we use “One to One” relationships? Give an example from the real world.
A email address to a user. An email address cannot reference more than 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?
The customer_id is then referenced in the addresses table. This creates a reference between the two tables where the customer_id is refered to as a foreign key in the addresses table. -
Give an example from the real world when would need to use a “Many to One/One to Many” relationship.
A user can make many different purchases. So this would be one user and many orders. One order can have many items included in it. -
Give an example from the real world when would need to use a “Many to Many” relationship.
If a user makes an order of many items from an online store, and many users purchase the different item. -
What does items_orders table do?
This creates connections between the items sold and the orders made. This is an example of a many to many relationship.
- One to One Relationships, One to Many and Many to One Relationships, Many to Many Relationships, Self Referencing Relationships.
- if my database stores businesses phone numbers and each business has only 1 number my database only needs to connect the business with the phone number using Foreign Key, this would be one to one.
- the customer id is programmed to connect to the address id which then revealed the customer address.
- if the data belongs to a car spares dealer, the database will store car models, series and spare part numbers, each part can fit on many cars.
- if the database belongs to ebay, it needs to store buyers, sellers, items, shipping addresses and payment info, each buyer can buy from many sellers, each seller has different payment info, each buyer has different address, many buyers buy same and different items.
- it connects the same and multiple items to orders.
-
What kinds of relationships can we represent in a database?
One to one, one to many & many to one, many to many, self referencing. -
When do we use “One to One” relationships? Give an example from the real world.
Social number can only be tied to one person. -
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, makeing sure that it cant be duplicated. -
Give an example from the real world when would need to use a “Many to One/One to Many” relationship.
When a customer makes many orders at webshop. -
Give an example from the real world when would need to use a “Many to Many” relationship.
Many customers, many orders, one item, that many customers order -
What does items_orders table do?
it connect to orders id with the items id
- Types of relationships:
- One to One Relationships
- One to Many and Many to One Relationships
- Many to Many Relationships
- Self Referencing Relationships
- We use 121 relationships in cases where there is only one direct connection between one row in one table and another row in another table. E.g. UserName and Phone No.
- The customer_ID is the Primary Key of the customer table that serves to identify each entry without ambiguity. customer_ID is actually not used to connect the two tables in the example. The primary key of the address table, called address_ID is used in the customer table as a foreign key. In this way address_ID connects the two tables.
- One customer, many orders.
- Orders and items in orders.
- The items_orders table creates the n2n relationships between the orders and the items tables.
- one to one, one to many, many to many, many to one, self referencing
- when an entry belongs to only one related entry elsewhere. social security number has a one to one relationship to a person
- It sets up a unique id for the customer. I don’t believe it is. The address_id is used as a foreign key to connect the unique customer to a unique address.
- A forum thread’s relation to it’s comments. One forum thread has many comments
- A song playlist. A song can belong to many playlists, while a playlist can contain many songs
- Creates the many to many relationship between an order and an item
- one to one, one to many - many to one, many to many
- Customer and customer id, usually a customer has just certain id, while one id just serve one customer for identification purposes
- adding one certain unique number makes it easier to avoid confusion since customers can have the same name
- one customer can do many order, many items can be in one order
- many students can register for many classes and in many classes are many students
- create many to many relationship
one to one
one to many
many to one
many to many
if an entry can only have one corresponding property. E.g. the passport number of one person.
It is there to make the customer unique and to allow referencing from other tables to him. Referencing by name is not good, because there could be more than one customer with the same name.
In the address table the only connection between the person and the address is the customer_id.
many items in one order
A facebook group can include many members and each member could be part of many groups
It is there to create the many-to-many relation
- one to one, one to many, many to one, many to many, self referencing.
- assuming that a customer can have ONLY ONE residence, then a one to one relationship can be customer/address relationship
- the customer_id is the primary key to the customer table and it uniquely identifies a customer record from all other customers.
address_id uniquely identifies an address record in the address table, and when added as a foreign key in the customer table,
the customer record can now reference the ddress associated with that customer to a uniques address record in the address table. - assuming that a customer can have MORE THAN ONE residence, then a one to many relationship can be customer/address; FL residence and NJ residense
- a customer order can consist of many items, and an item can belong to many orders
- it creates a table that contains the primary key from the orders table with the primary key from the items table