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

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.
Mapping an ERD to a Relational Database To map an ERD to a relational database, five rules are defined to govern how tables are constructed. 1)Rule for.
THE RELATIONAL DATABASE MODEL & THE DATABASE DEVELOPMENT PROCESS Fact of the Week: According to a Gartner study in ‘06, Microsoft SQL server had the highest.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 3 The Basic (Flat) Relational Model.
© 2005 by Prentice Hall Chapter 3a Database Design Modern Systems Analysis and Design Fourth Edition Jeffrey A. Hoffer Joey F. George Joseph S. Valacich.
Database Management: Getting Data Together Chapter 14.
Entity-Relationship Model and Diagrams (continued)
RELATIONSHIP  THE WAY TABLES ARE RELATED  A TABLE MUST PARTICIPATE IN AT LEAST ONE RELATIONSHIP  IN A BINARY RELATIONSHIP TWO ENTITIES PARTICIPATE 
Mapping from E-R Model to Relational Model Yong Choi School of Business CSUB.
Chapter 4 Relational Databases Copyright © 2012 Pearson Education, Inc. publishing as Prentice Hall 4-1.
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.
Chapter 14 & 15 Conceptual & Logical Database Design Methodology
Mapping ERM to relational database
Chapter 3 Relational Model Chapter 4 in Textbook.
Chapter 4 The Relational Model.
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall 9.1.
Primary & Foreign Keys. PK & FK 1.Primary key is required 2.The PK must be unique 3.If the primary key from one table is related to a field in another.
1 Intro to Info Tech Database Management Systems Copyright 2003 by Janson Industries This presentation can be viewed on line at:
Mapping from Data Model (ERD) to Relational Model Yong Choi School of Business CSUB.
DATA MODELING AND DATABASE DESIGN
MIS 385/MBA 664 Systems Implementation with DBMS/ Database Management Dave Salisbury ( )
Database. Basic Definitions Database: A collection of related data. Database Management System (DBMS): A software package/ system to facilitate the creation.
Introduction to Accounting Information Systems
Learningcomputer.com SQL Server 2008 – Entity Relationships in a Database.
Mapping from Data Model (ERD) to Relational Model
MIS 301 Information Systems in Organizations Dave Salisbury ( )
Relational Database Management Systems. A set of programs to manage one or more databases Provides means for: Accessing the data Inserting, updating and.
MIS 301 Information Systems in Organizations Dave Salisbury ( )
Normalization (Codd, 1972) Practical Information For Real World Database Design.
Logical Database Design Relational Model. Logical Database Design Logical database design: process of transforming conceptual data model into a logical.
SQL Structured Query Language Programming Course.
Lecture2: Database Environment Prepared by L. Nouf Almujally & Aisha AlArfaj 1 Ref. Chapter2 College of Computer and Information Sciences - Information.
Relational Data Model Ch. 7.1 – 7.3 John Ortiz Lecture 3Relational Data Model2 Why Study Relational Model?  Most widely used model.  Vendors: IBM,
Chapter 12: Designing Databases
Relational Database. Database Management System (DBMS)
Databases Shortfalls of file management systems Structure of a database Database administration Database Management system Hierarchical Databases Network.
Object-Relational Modeling. What Is a Relational Data Model? Based on the concept of relations (tables of data) Relationships established by matching.
Unit 4 Object Relational Modeling. Key Concepts Object-Relational Modeling outcomes and process Relational data model Normalization Anomalies Functional.
1 © Prentice Hall, 2002 Chapter 5: Logical Database Design and the Relational Model Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B.
Database Design – Lecture 8
Relational Theory and Design
CS263 Lecture 5: Logical Database Design Can express the structure of a relation by a Tuple, a shorthand notation Name of the relation is followed (in.
CSE314 Database Systems Lecture 3 The Relational Data Model and Relational Database Constraints Doç. Dr. Mehmet Göktürk src: Elmasri & Navanthe 6E Pearson.
MIS 301 Information Systems in Organizations Dave Salisbury ( )
Week 7-8 DBMS ER-Relational Mapping. ER-Relational Mapping.
1 ER Modeling BUAD/American University Mapping ER modeling to Relationships.
Chapter 10 Designing Databases. Objectives:  Define key database design terms.  Explain the role of database design in the IS development process. 
Lecture4: Informal guidelines for good relational design Mapping ERD to Relation Prepared by L. Nouf Almujally Ref. Chapter3 Lecture4 1.
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.
6-1 © Prentice Hall, 2007 Topic 6: Object-Relational Modeling Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,
IST 220 – Intro to DB Lecture 4 Database Design thru ER Modeling.
CHAPTER 2 : RELATIONAL DATA MODEL Prepared by : nbs.
Chapter 8: Object-Relational Modeling Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich, Jeffrey A. Hoffer.
8-1 © Prentice Hall, 2007 Chapter 8: Object-Relational Modeling Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,
1 10 Systems Analysis and Design in a Changing World, 2 nd Edition, Satzinger, Jackson, & Burd Chapter 10 Designing Databases.
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.
CSIS 115 Database Design and Applications for Business
Chapter 9 Part-1: Concepts & Foreign Keys
Tables and Their Characteristics
Translation of ER-diagram into Relational Schema
© 2011 Pearson Education, Inc. Publishing as Prentice Hall
Chapter 9 Part-1: Concepts & Foreign Keys
CHAPTER 4: LOGICAL DATABASE DESIGN AND THE RELATIONAL MODEL
Presentation transcript:

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

 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 Outline 2

Different Focus 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 Data Administrator Systems Analyst Primary responsibility Assist to ensure consistency w/existing systems

Data Management Dept. Database 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

 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 5 Types of Databases

From Conceptual Data Model to a Database 6 Conceptual Data ModelDatabase ERD Domain Class DiagramRDBMS EntityClassTable Attribute Field InstanceObjectRecord Primary KeyIdentifierPrimary Key RelationshipAssociationForeign Key

 (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” 7 Relational Database Model

TopicDescription 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 8 Designing a Relational DB

 No Multi-Valued Attributes  Due to the Rule of Atomic Values 9 Multi-Valued Attributes Employee Table SSNLastNameFirstNameTitleDependents 111SmithRobertAccountantBobbie, Sue 222JonesLeoProgrammer 333LopezTrentSales RepTrent Jr, Trevor, Sue Dependents Table SSNDependents 111Bobbie 111Sue 333Trent Jr 333Trevor 333Sue PK? Employee SSN {key} lastName firstName title dependents SSN {key} lastName firstName title dependents Employee Table SSNLastNameFirstNameTitle 111SmithRobertAccountant 222JonesLeoProgrammer 333LopezTrentSales Rep

 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 10 Foreign Keys: Establishing Relationships employs PKFK Add DeptCd here Copy it over Department deptCd {key} deptName location deptCd {key} deptName location Employee SSN {key} lastName firstName title SSN {key} lastName firstName title 1 *

 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 11 Foreign Keys: Establishing Relationships is assigned PKFK Copy it over Add SSN here ParkingSpace psNo {key} level Accessible? psNo {key} level Accessible? Employee SSN {key} lastName firstName title SSN {key} lastName firstName title PKFK Copy it over Add psNo here 1 1

PKFK Copy it over  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 12 Foreign Keys: Establishing Relationships PKFK Copy it over (PK) Employee SSN {key} lastName firstName title SSN {key} lastName firstName title Project projCd {key} projName desc stDate endDate projCd {key} projName desc stDate endDate EmpProject __________ role stDate __________ role stDate 0..* *1..1 EmpProject Employee Project 0..*1..*

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

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