Download presentation
Presentation is loading. Please wait.
1
Tables & Relationships
Quick Review-Steps when Creating a Database Steps to complete before creating the database using the software Decide what information you will store in the database Create the layout of the database Create a relationship diagram to identify the table relationships, primary keys and foreign keys 4. Create the database using the database software
2
Create the database using the database software
Create the Database File Create the tables Fields Primary keys Field Types Field Properties We know the information we want to store, but how do we match a customer’s name to their charges and payments? We need a way to relate these two tables to extract useful information. We can relate these two tables by matching the Client ID We do this by “Joining” the tables Create the Relationships
4
∞ 1 Parent Child Table Name: Client Primary Key: ClientID Table Name:
Payments Primary Key: None FK: ClientID On Payments table
5
Relationship Rules Must be a primary key in least one of the tables in the relationship. The related fields must be the same data type number, text etc. The foreign key field must contain the same information as the primary key field. The field names on each table do not have to match as long as the information is the same. FK: ClientID On Payments table Table Name: Client Primary Key: ClientID Table Name: Payments Primary Key: None
6
Referential Data Integrity
A set of rules that specifies what records may exist in each table A record input with a foreign key must always have a matching record in the primary key table in the relationship
7
Cascade Delete Related Records
Removing any entry in a primary key field will automatically remove all entries in foreign key fields of related tables. Cascade Update Related Records Updating any entry in a primary key field will automatically update all entries in foreign key fields of related tables.
8
∞ ∞ ∞ 1 1 1 Parent Parent Child Child Child Parent Table Name: Client
FK: ClientID On Payments table FK: ClientID On Charges table Table Name: Client Primary Key: ClientID Parent Parent 1 1 Child ∞ Child ∞ Table Name: Payments Primary Key: None Table Name: Charges Primary Key: None ∞ Child FK: PaymentType On Payments table 1 Parent Table Name: MethodTypes Primary Key: MethodID A Foreign Key (FK) is a field that defines the relationship between 2 tables.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.