Database Relationships

Slides:



Advertisements
Similar presentations
Access 2007 ® Use Databases How can Microsoft Access 2007 help you structure your database?
Advertisements

UNIVERSITY OF PALESTINE business computer application College of Business Instructor: Mr. Ahmed Abumosameh.
Microsoft ® Office Acess 2003 Training An Intro Guide to Acess 2003 Mr Garel…… presents:
ISP 121 Access Normalization and Relationships. Normalization Say we’re operating a pet day-care and we need to keep information on our pets/customers.
Maintenance Modifying the data –Add records –Delete records –Update records Modifying the design –Add fields into tables –Remove fields from a table –Change.
Databases and Database Management Systems
Relational Databases What is a relational database? What would we use one for? What do they look like? How can we describe them? How can you create one?
Database Software Application
Database Relationships Objective 5.01 Understand database tables used in business.
Database Relationships Objective 5.01 Understand database tables used in business.
Database Tables two order-entry scenarios: A customer wants to cancel an order that she's placed. If her address is in a separate table from her.
DAY 15: ACCESS CHAPTER 2 Larry Reaves October 7,
Relational Database Concepts. Let’s start with a simple example of a database application Assume that you want to keep track of your clients’ names, addresses,
Microsoft Access Understanding Relationships Academic Health Center Training (352)
Relational databases and third normal form As always click on speaker notes under view when executing to get more information!
Access 2013 Microsoft Access 2013 is a database application that is ideal for gathering and understanding data that’s been collected on just about anything.
DAY 12: DATABASE CONCEPT Tazin Afrin September 26,
1 Outline  What is a Primary Key?  AutoNumber primary keys  Single-field primary keys  Composite-field primary key  About Foreign Keys  Database.
1 Database Concepts 2 Definition of a Database An organized Collection Of related records.
Databases. What is a database?  A database is used to store data. The word DATA is actually Latin for FACTS. A database is, therefore, a place, or thing.
Microsoft Access Intro Class 6 Relationships.
HSC IT Center Training University of Florida Microsoft Access Understanding Relationships Health Science Center IT Center – Training
Access 2007 ® Use Databases How can Microsoft Access 2007 help you structure your database?
Microsoft ® Office Access 2003 Training Get to know Access CGI presents:
ITGS Databases.
What have we learned?. What is a database? An organized collection of related data.
Forms and Subforms 5.02 Understand database queries, forms, and reports used in business.
Quiz questions. 1 A data structure that is made up of fields and records? Table.
Lesson 2: Designing a Database and Creating Tables.
Forms 5.02 Understand database queries, forms, and reports.
1 CHƯƠNG 4 Creating Relational Databases Understanding Table Relationships Example: This database tracks customers and their orders in two separate.
D1 FMA Review. Many-to-Many Relationships - Examples Car Hire –A customer may hire one or more cars –A car may be hired by one or more customers Gym Club.
Database Relationships Objective 5.01 Understand database tables used in business.
INFORMATION TECHNOLOGY DATABASE MANAGEMENT. A database is a collection of information organized to provide efficient retrieval. The collected information.
HSC IT Center Training University of Florida Microsoft Access Relationships Health Science Center IT Center – Training
1 Finding Your Way Through a Database Exploring Microsoft Office Access.
Microsoft Access 2013 ®® Case Study Creating a Database.
Database Relationships
Databases: What they are and how they work
Tutorial 1 Creating a Database
Microsoft Office Access 2010 Lab 1
Prepared By: Bobby Wan Microsoft Access Prepared By: Bobby Wan
Tables & Relationships
Implementing an REA Model in a Relational Database
Databases Chapter 9 Asfia Rahman.
Database Fundamentals
Databases.
Information Systems Today: Managing in the Digital World
CIS 155 Table Relationship
Microsoft Office Illustrated Fundamentals
Database Relationships
CSCI-100 Introduction to Computing
Databases and Information Management
What is a Database and Why Use One?
INFO/CSE 100, Spring 2005 Fluency in Information Technology
Case Study Creating a Database
Database Fundamentals
Teaching slides Chapter 8.
5.02 Understand database queries, forms, and reports used in business.
PHP and MySQL.
Relational Queries (query 12) Display vendor contact info (contact person and phone number) for inventory products (relationship query) Query: Inventory.
Databases and Information Management
Flat Files & Relational Databases
Database Fundamentals
Advanced Database Concepts: Reports & Views
logical design for relational database
Microsoft Access Understanding Relationships
Nagendra Vemulapalli Access chapters 1&2 Nagendra Vemulapalli
Database Fundamentals
Relationships While we are on the subject of Relationships, let’s take a quick look at them.
Presentation transcript:

Database Relationships Objective 5.01 Understand database tables used in business 5.01 Database Relationships

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.01 Database Relationships

Making Friends with Relations 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. Relationships link data from individual tables and increase the usefulness of a database. Since the database information is associated, the database can pull all the information together whenever you want in ways that you specify. Examples of separate types of data (paragraph 1) In the recycling club database, member contact information is stored separately from lists of recycling volunteers or holiday planning data. Example of associated data (paragraph 2) Recycling club member Nancy Davolio’s name is associated with, or “knows about,” Nancy Davolio’s contact information, which is stored in another set of data. Creating a relational database means you can quickly pull information together. For example, you can quickly print a list of who's volunteered to recycle newspapers this Saturday, along with their up-to-date addresses and phone numbers. 5.01 Understand database tables used in business 5.01 Database Relationships

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 5.01 Database Relationships

Keys to the Relationship A primary key is an essential element of a database table. It is a data type that is set to make each record within a database table unique and to link tables 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 5.01 Database Relationships

What makes a good primary key? Which of the following would make each record in a database unique? Social security number Last name First name Automobile VIN number Birth date Product serial number Discuss why Last name and first name are not valid primary key fields. 5.01 Database Relationships

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 A detailed example of how primary keys and foreign keys work Let’s say you have a Grocery Products table and an Orders table. The ISBN number is the primary key for the Grocery Products table and a foreign key for the Orders table. The Orders table has its own primary key, the Order ID number. When Nancy Davolio takes an order, her Employee ID number is entered into the Orders table. This ID number refers to the details about Nancy in the Employees table, so there's no need to repeat data about Nancy (such as her phone extension) in the Orders table. We’ll go into more detail about primary keys, foreign keys, and table relationships later in the presentation. 5.01 Database Relationships

Diagram of Primary & Foreign Keys The primary key of the Grocery Products table (ISBN) is linked to the foreign key of the Purchase Orders table (ISBN). The primary key of the Purchase Orders table (Order No.) is linked to the primary key of the Orders table. The foreign key of the Orders table (Store ID) is linked to the primary key of the Customers table. 5.02 Understand queries, forms, and reports.

Function of the Junction Table A junction table is used 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. 5.01 Database Relationships

One-to-Many One-to-Many One record in Table A links to multiple records in Table B through the primary/foreign key fields of the two tables One-to-many example: A list of suppliers for the music store is contained in Table A. It is linked by the supplier ID field to Table B which contains all of the products used by the music store. When Table B is searched for a specific product (record), such as a CD carrying case, the manager can view the supplier’s contact information, which is stored in Table A. Many-to-Many example: In the music store database, Table A contains customer information and Table B contains CD inventory. A record for Bob from Table A may be linked to several records of CDs in Table B by linking the Customer ID fields. If Table B contains the CD inventory, a record for a particular CD can be linked to several customers in Table A. 5.01 Database Relationships

Many-to-Many Many-to-Many 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. One-to-many example: A list of suppliers for the music store is contained in Table A. It is linked by the supplier ID field to Table B which contains all of the products used by the music store. When Table B is searched for a specific product (record), such as a CD carrying case, the manager can view the supplier’s contact information, which is stored in Table A. Many-to-Many example: In the music store database, Table A contains customer information and Table B contains CD inventory. A record for Bob from Table A may be linked to several records of CDs in Table B by linking the Customer ID fields. If Table B contains the CD inventory, a record for a particular CD can be linked to several customers in Table A. 5.01 Database Relationships

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 5.01 Database Relationships

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. 5.01 Database Relationships

Relationship Discussion What are the advantages of this system? Are there disadvantages? A music store database contains three tables. An Inventory table is linked by artist to a Royalty table which contains the artist’s contact information and royalty percentages The Inventory table is also linked to a Sales table by salesperson ID numbers, which contains employee information and commission rates Once a purchase is made, the inventory is adjusted in one table and the artist’s royalties and employee’s commissions are calculated from the information in the other tables 5.01 Database Relationships