Introducing Databases

Slides:



Advertisements
Similar presentations
Maintenance Modifying the data –Add records –Delete records –Update records Modifying the design –Add fields into tables –Remove fields from a table –Change.
Advertisements

Systems Development Life Cycle
1 © Prentice Hall, 2002 Chapter 5: Logical Database Design and the Relational Model Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B.
CS424 PK, FK, FD Normalization Primary and Foreign Keys Primary and foreign keys are the most basic components on which relational theory is based. Primary.
Keys Chapter 8 Database Design for Mere Mortals. Why Keys Are Important They ensure that each record in a table can be properly identified. They help.
Transforming Data Models into Database Designs
3 The Relational Model MIS 304 Winter Class Objectives That the relational database model takes a logical view of data That the relational model’s.
Module Title? DBMS E-R Model to Relational Model.
DAY 15: ACCESS CHAPTER 2 Larry Reaves October 7,
Learningcomputer.com SQL Server 2008 – Entity Relationships in a Database.
Data Modelling – ERD Entity Relationship Diagram’s Entity Relationship Diagrams and how to create them. 1.
Concepts and Terminology Introduction to Database.
CSCI N207: Data Analysis Using Spreadsheets Copyright ©2005  Department of Computer & Information Science Introducing Databases.
CSCI N201: Programming Concepts Copyright ©2005  Department of Computer & Information Science Introducing Databases.
Office Management Tools II Ms Saima Gul.  When you create your tables, you should assign each table a primary key—one or more fields whose contents are.
Relationships and Advanced Query Concepts Using Multiple Tables Please use speaker notes for additional information!
1 n 1 n 1 1 n n Schema for part of a business application relational database.
Implementing an REA Model in a Relational Database
3 & 4 1 Chapters 3 and 4 Drawing ERDs October 16, 2006 Week 3.
1 © Prentice Hall, 2002 Chapter 5: Logical Database Design and the Relational Model Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B.
Logical Database Design and the Relational Model.
© 2009 Pearson Education, Inc. Publishing as Prentice Hall 1 Chapter 5 (Part a): Logical Database Design and the Relational Model Modern Database Management.
DATA MODELING AND DATABASE DESIGN DATA MODELING AND DATABASE DESIGN Part 2.
Lecture 4: Logical Database Design and the Relational Model 1.
Lecture # 14 Chapter # 5 The Relational Data Model and Relational Database Constraints Database Systems.
IT 5433 LM3 Relational Data Model. Learning Objectives: List the 5 properties of relations List the properties of a candidate key, primary key and foreign.
AOIT Database Design Unit 3, Lesson 9 Data Integrity Copyright © 2009–2011 National Academy Foundation. All rights reserved.
Database Constraints ICT 011. Database Constraints Database constraints are restrictions on the contents of the database or on database operations Database.
Getting started with Accurately Storing Data
What is a Database? In a general, a database is any organized collection of data Examples: Grocery List Audio CD Catalog Phone Book Airline Ticketing Software.
(Winter 2017) Instructor: Craig Duckett
CSIS 115 Database Design and Applications for Business
Logical Database Design and the Rational Model
Tables & Relationships
Implementing an REA Model in a Relational Database
Database Constraints Ashima Wadhwa.
Databases Chapter 9 Asfia Rahman.
Chapter 4 Logical Database Design and the Relational Model
(Winter 2017) Instructor: Craig Duckett
Chapter 4: Logical Database Design and the Relational Model
The Relational Database Model
(Winter 2017) Instructor: Craig Duckett
Objectives Query for top values Create a parameter query
Implementing an REA Model in a Relational Database
Chapter 5: Logical Database Design and the Relational Model
Relational Databases.
CSIS 115 Database Design and Applications for Business
Tables and Their Characteristics
CIS 155 Table Relationship
Database Systems: Design, Implementation, and Management Tenth Edition
Database Relationships
Implementing an REA Model in a Relational Database
Database Systems Instructor Name: Lecture-12.
Chapter 3 The Relational Database Model
Data Modelling Introduction
ERD’s REVIEW DBS201.
Normalization Referential Integrity
(Winter 2017) Instructor: Craig Duckett
IST 318 Database Administration
CHAPTER 4: LOGICAL DATABASE DESIGN AND THE RELATIONAL MODEL
Database Systems Instructor Name: Lecture-9.
Database Systems Instructor Name: Lecture-10.
Chapter 3: Modeling Data in the Organization
Chapter 17 Designing Databases
Microsoft Access Validation Rules, Table Relationships And
INSTRUCTOR: MRS T.G. ZHOU
Database Systems: Design, Implementation, and Management
Relational data model. Codd's Rule E.F Codd was a Computer Scientist who invented Relational model for Database management. Based on relational model,
Chapter 3 The Relational Model
Presentation transcript:

Introducing Databases

Business Rules A database is framed to fit the ways in which an organization runs its business. Business rules may affect several aspects of database design, including: Field ranges and valid values Types of table relationships Degree of relationships Degree of participation Synchronization of tables

Importance of Relationships Relationships allow users to establish views based on multiple base tables. Relationships help to reduce data redundancy and eliminate duplicate data, thus reinforcing data integrity.

Relationships We can build a relationship between tables if we can relate the records in one table with the records in the joining table. Two methods for building a relationship: Linking primary and foreign keys Linking tables via a third table called a linking table or associative table

Categorizing Relationships We categorize relationships between tables in three ways: The type of relationship between tables The way that each table in relationship participates in that relationship The degree of participation that each table participates in a relationship

Relationship Participation There are two ways that we categorize relationships based on participation: Mandatory Participation: If a user MUST enter at least one record into a parent table before s/he may enter records in a child table. Optional Participation: If a user MAY enter records in a child table without entering records in the parent table.

Degrees of Participation We calculate a table's degree of participation by: The minimum number of records it must associate with a single record in the related table. The maximum number of records that a related table may associate with a single record in the given table. Think of the degree of participation as the minimum and maximum number of relationships for a single record in a table.

Example of Degree of Association Assume that for a Department, advisors are assigned at least 1 student and up to 50 students, but no more. The degree of participation of the Advisor Table would be 1,50. That is, an advisor must be assigned to at least one student in the Student Table, but has a limit of 50 students in the Student Table.

Different Types of Relationships One-to-One Relationship (1:1) One-to-Many Relationship (1:N) Many-to-Many Relationship (N:N)

One-To-One Relationships (1:1) In a one-to-one relationship (1:1), we relate one and only one record from a parent table to one and only one record in a second table (a child table). To create a 1:1 relationship, we copy the primary key of a parent table into a child table, where it becomes a foreign key. This type of relationship is unique because both tables share the same primary key. The primary key in the child table serves both as that table's primary key and a foreign key .

Example of a 1:1 Relationship Employee ID Employee First Name Employee Last Name 100 Zachary Erlich 101 Susan McClain 102 Joe Rosales Employee ID Hourly Rate Commission Rate 100 25.00 5.0% 101 19.75 3.5% 102 22.50 Employee Table Employee ID is the Primary Key for both tables and also a Foreign Key in the Compensation Table. Compensation Table - Adapted from Figure 3.13 from Herenandez

One-To-Many Relationships (1:N) In a one-to-many (1:N) relationship, we relate a record in one table (a parent table) to many records in a second table (a child table). To create a 1:N relationship, we copy the primary key of a parent table into a child table, where it becomes a foreign key. This type of relationship is the most common type of relationship in the relational database model.

Example of a 1:N Relationship Agent ID Agent First Name Agent Last Name Hire Date 100 Mike Hernandez 05/16/95 101 Greg Piercy 10/15/95 102 Katherine Ehrlich 03/01/96 Agents Table Client ID Agent ID Client First Name Client Last Name 9001 100 Stewart Jameson 9002 Shannon McLain 9003 102 Estella Pundt Clients Table Agent ID is the Primary Key in the Agents Table and a Foreign Key in the Clients Table. - Adapted from Figure 3.14 from Herenandez

Many-To-Many Relationships (N:N) In a many-to-many relationship, we relate many records in one table to many records in a second table. We cannot inherently create a N:N relationship. Instead, we can resolve a N:N relationship by copying the primary keys of each table into a third table, called a linking (associative) table. Together, the copied keys form a composite primary key. Individually, they serve as foreign keys for the other table.

Example of Resolving an N:N Relationship

Primary Keys A primary key is a field or group of fields that uniquely identifies a record. A primary key comprised of two or more fields is called a composite primary key. Every table must have a primary key! The most important key in a table: Uniquely identifies a specific record throughout a database Identifies a specific table throughout the database Enforces table-level integrity Helps to establish relationships between tables

Foreign Keys A foreign key is important when we establish relationships between tables. To create a foreign key, you would take a primary key from one table and copy it in a second table. In the second table, the key becomes a foreign key. Foreign keys enforce relationship-level integrity – values in one table's foreign key field must match exactly with the corresponding values of a second table's primary key field.

Example of Primary & Foreign Keys Agent ID Agent First Name Agent Last Name Hire Date 100 Mike Hernandez 05/16/95 101 Greg Piercy 10/15/95 102 Katherine Ehrlich 03/01/96 Agents Table Client ID Agent ID Client First Name Client Last Name 9001 100 Stewart Jameson 9002 Shannon McLain 9003 102 Estella Pundt Clients Table Agent ID is the Primary Key in the Agents Table and a Foreign Key in the Clients Table. - Adapted from Figure 3.11 from Herenandez

Data Integrity "Data integrity refers to the validity, consistency, and accuracy of the data in a database." (Hernandez, p. 71) Four Types of Data Integrity: Table-level integrity Field-level integrity Relationship-level integrity Business rules

Table-Level Integrity Also known as entity integrity Ensures there are no duplicate records throughout a database Makes sure that primary keys with a table are unique never null

Field-Level Integrity Also known as domain integrity Guarantees that that structure of each field is sound: Values are "valid, consistent and accurate" (Hernandez, p. 71) Values of the same type (for instance, we would define fields related to an academic major in a consistent manner throughout the database).

Relationship-Level Integrity Also known as referential integrity Checks to make sure that the relationships between tables are sound. Also, ensures that records in related tables are synchronized when someone enters data, deletes data or otherwise manipulates it.

Questions?

References geekgirl's plain-english computing (website): http://www.geekgirls.com/menu_databases.htm Database Design for Mere Mortals, 2nd Edition by Michael Hernandez (Addison-Wesley, 2004)