Presentation is loading. Please wait.

Presentation is loading. Please wait.

Database Relationships Objective 5.01 Understand database tables used in business.

Similar presentations


Presentation on theme: "Database Relationships Objective 5.01 Understand database tables used in business."— Presentation transcript:

1 Database Relationships Objective 5.01 Understand database tables used in business

2 Database Management The effectiveness of a database is measured by the user’s ability to retrieve useful information. An effective database contains timely information and requires continuous maintenance. Ex: A Telephone Directory Database contains a large amount of information that must be gathered, edited, and processed to provide customers with accurate information. Many tools are available to assist in the retrieval, processing & manipulation of database information.

3 Database Tools Filtering – allows for the retrieval of information that meets specific criteria. Sorts – Allows for information to be arranged in a specific order such as alphabetical, chronological, ascending or descending. Database Relationships – a link between two or more tables in a database.

4 Relationships A relationship means that two or more tables are linked together by a common field, called a primary key field. Table relationships increase the power of the database by allowing data to be stored separately, but managed and retrieved collectively.

5 Slide 55.01 Understand database tables used in business Making Friends with Relations Relationships link data from individual tables and increase the usefulness of a database. One of the great benefits of working with databases is the ability to store huge quantities of information. One company’s database may contain multiple tables of related information. When the information between tables is linked, it is called a relationship.

6 What does a relationship look like? One record in the Student Table is related to one record in the Participation Table Relationship established between two tables

7 Keys to the Relationship A primary key unlocks the relationship potential of a table by creating a unique link between tables. Primary Key is a data type that is set to make each record within a database table unique so that tables can link together. Primary key fields must be of the same data type and size for the tables to which they link. The red line that graphically represents the relationship is called a Join Line

8 What makes a good primary key? Which of the following would make each record in a database unique? Social security number Social security number Last name Last name First name First name Automobile VIN number Automobile VIN number Birth date Birth date Product serial number Product serial number

9 Primary and Foreign Keys When tables relate, the primary key of one table becomes a foreign key of the other table For example, in the tables below, ISBN appears as a primary key in the Grocery Products table...…and in the Orders Table as a foreign key

10 Diagram of Primary & Foreign Keys 10 5.02 Understand queries, forms, and reports.

11 Function of the Junction Table A junction table is used with many-to- many relationships to join primary key fields of multiple tables The Junction table is like a hub or control center In this example, Orders is the Junction Table. It allows the Grocery Products and the Customers tables to share information.

12 One-to-One Only one matching record between two tables This relationship is the least common because it is not a very efficient use of tables

13 One-to-Many One-to-Many The most common type of relationship The most common type of relationship One record in Table A links to multiple records in Table B One record in Table A links to multiple records in Table B The link is established through the primary/foreign key fields of the two tables The link is established through the primary/foreign key fields of the two tables

14 Many-to-Many Many-to-Many Multiple records in multiple tables are linked by their primary keys through a Junction Table. Multiple records in multiple tables are linked by their primary keys through a Junction Table. A many-to-many relationship is formed by connecting two or more tables that have a one-to-many relationship. The connection is made by a Junction Table. A many-to-many relationship is formed by connecting two or more tables that have a one-to-many relationship. The connection is made by a Junction Table.

15 Setting up a Relationship Add one table’s primary key to a field in another table that has the same properties The primary key in Grocery Products is ISBN The primary key in Orders is Order No The primary key in Customers is Store ID

16 Referential Integrity Referential integrity protects related data that is stored in multiple tables. It would prevent a customer in one table from being deleted if the customer is also in a related table.

17


Download ppt "Database Relationships Objective 5.01 Understand database tables used in business."

Similar presentations


Ads by Google