Chapter 9 Part-1: Concepts & Foreign Keys

Slides:



Advertisements
Similar presentations
The Relational Model J.G. Zheng May 15 th Introduction Edgar F. Codd, 1970 One sentence to explain relational database model: Data are organized.
Advertisements

Chapter 10: Designing Databases
Relational Database. Relational database: a set of relations Relation: made up of 2 parts: − Schema : specifies the name of relations, plus name and type.
SQL Lecture 10 Inst: Haya Sammaneh. Example Instance of Students Relation  Cardinality = 3, degree = 5, all rows distinct.
© 2005 by Prentice Hall Chapter 3a Database Design Modern Systems Analysis and Design Fourth Edition Jeffrey A. Hoffer Joey F. George Joseph S. Valacich.
Chapter 4 Relational Databases Copyright © 2012 Pearson Education 4-1.
Michael F. Price College of Business Chapter 6: Logical database design and the relational model.
Database Architecture The Relational Database Model.
Introduction to Accounting Information Systems
Learningcomputer.com SQL Server 2008 – Entity Relationships in a Database.
SQL Structured Query Language Programming Course.
Chapter 12: Designing Databases
Relational Database. Database Management System (DBMS)
1 © Prentice Hall, 2002 Chapter 5: Logical Database Design and the Relational Model Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B.
Relational Theory and Design
Chapter 10 Designing Databases. Objectives:  Define key database design terms.  Explain the role of database design in the IS development process. 
Logical Database Design and the Relational Model.
Database Design Chapter 9 Part-1: Concepts & Foreign Keys 1.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 The Relational Model Chapter 3.
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.
12. Chapter 12: Designing Databases Systems Analysis and Design in a Changing World, Fourth Edition 12.
Database Design Chapters 17 and 18.
Databases and DBMSs Todd S. Bacastow January
CompSci 280 S Introduction to Software Development
Chapter 8: Object-Relational Modeling
CSIS 115 Database Design and Applications for Business
Database Development Lifecycle
Chapter 4 Logical Database Design and the Relational Model
Chapter 4: Logical Database Design and the Relational Model
CSIS 115 Database Design and Applications for Business
The Relational Model and Database Normalization
The Relational Model Chapter Two DATABASE CONCEPTS, 3rd Edition
RELATION.
Information Systems Today: Managing in the Digital World
Chapter 5: Logical Database Design and the Relational Model
MIS 322 – Enterprise Business Process Analysis
Tables and Their Characteristics
CIS 155 Table Relationship
Database Management Systems (DBMS)
Chapter 4 Relational Databases
Introduction to MS Access: creating tables, keys, and relationships
Translation of ER-diagram into Relational Schema
Entity Relationship Diagram
Entity-Relationship Model and Diagrams (continued)
Chapter 9 Designing Databases
Entity Relationships and Normalization
Introduction to Database Management System
© 2011 Pearson Education, Inc. Publishing as Prentice Hall
ERD’s REVIEW DBS201.
Relational Database.
Database Fundamentals
Chapter 3 The Relational Model.
Chapter 4 The Relational Model Pearson Education © 2009.
The Relational Model Relational Data Model
Chapter 4 The Relational Model Pearson Education © 2009.
Entity Relationship Diagrams ERDs
Database Management System
Chapter 4 The Relational Model Pearson Education © 2009.
Chapter 9 Part-1: Concepts & Foreign Keys
Database Management Systems
CHAPTER 4: LOGICAL DATABASE DESIGN AND THE RELATIONAL MODEL
The Relational Model Transparencies
Database Design Chapters 17 and 18.
Chapter 4 The Relational Model Pearson Education © 2009.
Chapter 4 The Relational Model Pearson Education © 2009.
Database Design: Relational Model
DBMS ER-Relational Mapping
Chapter 4 The Relational Model Pearson Education © 2009.
Mapping an ERD to a Relational Database
Chapter 3 The Relational Model
Presentation transcript:

Chapter 9 Part-1: Concepts & Foreign Keys Database Design Chapter 9 Part-1: Concepts & Foreign Keys

Outline Part One Data Management Dept Types of DBs From Conceptual Data Model to a Database Relational DB Model Designing a Relational DB Multi-valued Attributes Representing Relationships Referential Integrity

Different Focus Systems Analyst Data Administrator Requirements Use Cases – the user must be able to: Enter orders Track order status Enter/assign/resolve complaints Data Model – the system must be able to capture: Order # Order Date Customer Info Billing address Shipping address Products, & quantity Price, discounts Systems Analyst Data Administrator Primary responsibility Assist to ensure consistency w/existing systems

Database Administrator (DBA) Data Management Dept. Data Administrator Database Administrator (DBA) Data Standards - Naming, etc Data use - Ownership, accessibility Data quality - Integrity rules Managing the DBMS environment Performance monitoring & tuning Security Backup & Recovery Database

Types of Databases Types of Databases Hierarchical Network Relational Object-oriented Relational Database Management System (RDBMS) organizes data into tables (i.e. relations) Tables are two dimensional data structures Record – row or tuple Field – column or attribute

From Conceptual Data Model to a Database ERD Domain Class Diagram RDBMS Entity Class Table Attribute Field Instance Object Record Primary Key Identifier Relationship Association Foreign Key Cardinality Multiplicity ** ** Relationship rules –will learn in the DB class

Relational Database Model (def) a model where data is represented as a set of related tables or relations. Properties/Rules of Relations: Entries in cells are simple. (Rule of Atomic Values) Entries in columns are from the same set of values. (Domain) Each row is unique. (Primary Key) Order of columns may be interchanged Order of rows may be interchanged Other Rules come from “Normalization”

Designing a Relational DB Topic Description Tables Create TBs – 1 for each entity/domain class Primary Keys Select/define a PK for each TB Associative Create new tables to represent many-to-many relationships Multi-Valued Attributes Resolve to new tables Foreign Keys Add FKs to establish relationships Super & Sub Classes Decide on how to represent any Generalization Hierarchies Referential Integrity Define Referential Integrity constraints Normalization Evaluate schema quality and make necessary improvements Data Types Determine appropriate data types for validation, integrity   

Multi-Valued Attributes No Multi-Valued Attributes  Due to the Rule of Atomic Values Employee EmpID {key} lastName firstName title dependents Employee Table EmpID LastName FirstName Title Dependents 111 Smith Robert Accountant Bobbie, Sue 222 Jones Leo Programmer 333 Lopez Trent Sales Rep Trent Jr, Trevor, Sue Dependents Table EmpID Dependents 111 Bobbie Sue 333 Trent Jr Trevor PK? Employee Table EmpID LastName FirstName Title 111 Smith Robert Accountant 222 Jones Leo Programmer 333 Lopez Trent Sales Rep

Foreign Keys: Establishing Relationships One to Many Relationship create foreign key in the relation that is on the “many” side of relationship only NOTE: Going the other way would generate a multi-value attribute PK FK Add DeptCd here Copy it over Department deptCd {key} deptName location Employee EmpID {key} lastName firstName title 1 employs *

Foreign Keys: Establishing Relationships One to One Relationship create foreign key in either relation NOTE: IF you have one & only one on both sides, these may be merged into a single table PK FK Copy it over Add SSN here Employee EmpID {key} lastName firstName title ParkingSpace psNo {key} level Accessible? 1 is assigned 1 PK FK Copy it over Add psNo here

Foreign Keys: Establishing Relationships Many to Many Relationship should’ve been eliminated on ERD!!! create new relation with PKs of related entities as: 1 concatenated PK, and 2 FKs Employee Project 1..* 0..* EmpProject PK FK Copy it over PK FK Copy it over Employee EmpID {key} lastName firstName title Project projCd {key} projName desc stDate endDate EmpProject __________ role stDate 1..1 0..* 1..* 1..1 (PK)

Super & Sub Classes 2 Options to Implement Separate Tables One Table Student (SID, name, birthDate) UndergradStudent (SID, mentor) GradStudent (SID, thesisTopic) One Table Student (SID, name, birthDate, mentor, thesisTopic, studentType) Student Undergrad Student Grad Student SID {key} name birthDate mentor thesisTopic

Referential Integrity (def) an integrity constraint on the Foreign Key: Prevents adding a FK value, if an associated PK value does not exist. Prevents delete of PK value, if an associated FK value exists. Prevents change of PK value, if an associated FK value exists. Can override: Cascade Delete  Overrides constraint #2 Cascade Update  Overrides constraint #3