6.8 Case Study: E-R for Supplier-and-Parts Database

Slides:



Advertisements
Similar presentations
Unit 5 The Network Model  5.1 The Network Model  5.2 IDMS.
Advertisements

Relational Database. Relational database: a set of relations Relation: made up of 2 parts: − Schema : specifies the name of relations, plus name and type.
Chapter 3 An Introduction to Relational Databases.
Wei-Pang Yang, Information Management, NDHU More on Normalization Unit 18 More on Normalization ( 表格正規化探討 ) 18-1.
Chapter 31 Chapter 3 Data Modeling Using the Entity-Relationship Model.
SQL Lecture 10 Inst: Haya Sammaneh. Example Instance of Students Relation  Cardinality = 3, degree = 5, all rows distinct.
Ch5: ER Diagrams - Part 1 Much of the material presented in these slides was developed by Dr. Ramon Lawrence at the University of Iowa.
Databases Revision.
Systems Development Life Cycle
© 2005 by Prentice Hall 1 Chapter 5: Logical Database Design and the Relational Model Modern Database Management 7 th Edition Jeffrey A. Hoffer, Mary B.
Chapter 4 ENTITY-RELATIONSHIP MODELLING.
Entity-Relationship (E-R) Model
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Reduction of an E-R Schema to Tables A database which conforms to an E-R diagram can be represented.
Chapter 4 Entity-Relationship modeling Transparencies © Pearson Education Limited 1995, 2005.
Database Management COP4540, SCS, FIU Database Modeling Using the Entity-Relationship Model (Chapter 3)
Michael F. Price College of Business Chapter 6: Logical database design and the relational model.
CS 405G Introduction to Database Systems
 Keys are special fields that serve two main purposes: ◦ Primary keys are unique identifiers of the relation in question. Examples include employee numbers,
Chapter 3 Data Modeling Using the Entity-Relationship (ER) Model.
the Entity-Relationship Model
Database Systems Lecture # 8 11 th Feb,2011. The Relational Model of Data The term relation is basically just a mathematical term for a table. DBMS products.
Chapter 5 1 © Prentice Hall, 2002 Chapter 5: Transforming EER Diagrams into Relations Mapping Regular Entities to Relations 1. Simple attributes: E-R attributes.
1. 2 Data Modeling 3 Process of creating a logical representation of the structure of the database The most important task in database development E-R.
CS370 Spring 2007 CS 370 Database Systems Lecture 7 The Relational model.
Data Manipulation 11 After this lecture, you should be able to:  Understand the differences between SQL (Structured Query Language) and other programming.
Logical Database Design Unit 7 Logical Database Design.
1 ER Modeling BUAD/American University Entity Relationship (ER) Modeling.
Entity-Relationship Model Ch. 3
Entity Relationship Modeling
3-1 Unit 3 The Relational Model. 3-2 Wei-Pang Yang, Information Management, NDHU Outline  3.1 Introduction  3.2 Relational Data Structure  3.3 Relational.
4B-1 Wei-Pang Yang, Information Management, NDHU Introduction to Database CHAPTER 4B ( 補 ) DB2 and SQL  Overview  Data Definition  Data Manipulation.
Logical Database Design ( 補 ) Unit 7 Logical Database Design ( 補 )
Chapter 10 Views. Topics in this Chapter What are Views For? View Retrievals View Updates Snapshots SQL Facilities.
Dr. Ahmad R. Hadaegh A.R. Hadaegh California State University San Marcos (CSUSM) Page 1 Entity Relational Diagram (ERD) Modeling This particular lecture.
Further Normalization I
Data Definition After this lecture, you should be able to:
© Pearson Education Limited, Chapter 7 Entity-Relationship modeling Transparencies.
Entity-Relationship Modeling Based on Chapter 12.
Chapter 12 Entity-Relationship Modeling Pearson Education © 2009.
1 From E-R Model to Relational Model. 2 Entity type sid#name address house#street pcode Student.
Chapter 11 & 12 Entity-Relationship (E-R) Model Characteristics of E-R Model Components of E-R Model Example of E-R Model Enhanced E-R Model.
Chapter 9: Logical Database Design and the Relational Model (ERD Mapping)
Chapter 3 Data Modeling Using the Entity-Relationship (ER) Model Copyright © 2004 Pearson Education, Inc.
Data Manipulation 21 After this lecture, you should be able to:  Use SQL SELECT statement effectively to retrieve the data from multiple related tables.
1 © Prentice Hall, 2002 Chapter 5: Logical Database Design and the Relational Model Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B.
Unit 5 The Network Model  5.1 Data Modeling Issues  5.2 The Network Model  5.3 IDMS.
Database Management Systems MIT Lesson 02 – Database Design (Entity Relationship Diagram) By S. Sabraz Nawaz.
In this session, you will learn to: Map an ER diagram to a table Objectives.
Database Systems Conceptual to Relational Modeling II Lecture # 11 Feb 25 th 2011.
Entity-Relation Model. E-R Model The Entity-Relationship (ER) model was originally proposed by Peter in 1976 ER model is a conceptual data model that.
Lecture # 6.  A class of data models  Conveys semantic meaning  Implements databases more intelligently  Support more sophisticated user interfaces.
Copyright © 2013 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill/Irwin APPENDIX C DESIGNING DATABASES APPENDIX C DESIGNING DATABASES.
Unit 2 DB2 and SQL. 2-2 Wei-Pang Yang, Information Management, NDHU Outline of Unit Overview 2.2 Data Definition 2.3 Data Manipulation 2.4 The System.
1 © Prentice Hall, 2002 ITD1312 Database Principles Chapter 4B: Logical Design for Relational Systems -- Transforming ER Diagrams into Relations Modern.
Chapter 14 Semantic Modeling. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.14-2 Topics in this Chapter The Overall Approach The E/R Model.
Levels of Database Modeling High degree of abstraction Conceptual model User view 1 User view 2 Implementa- tion model Physical model Medium degree of.
Lecture 4: Logical Database Design and the Relational Model 1.
Views Prof. Yin-Fu Huang CSIE, NYUST Chapter 10. Advanced Database System Yin-Fu Huang 10.1Introduction Example: Var Good_Supplier View (S Where Status.
Microsoft Access CS 110 Fall Entity Relationship Model Entities Entities Principal data object about which information is to be collectedPrincipal.
Rationale Databases are an integral part of an organization. Aspiring Database Developers should be able to efficiently design and implement databases.
Lecture # 14 Chapter # 5 The Relational Data Model and Relational Database Constraints Database Systems.
Database Designsemester Slide 1 Database Design Lecture 7 Entity-relationship modeling Text , 7.1.
COP Introduction to Database Structures
Advanced Database System
پايگاه داده ها.
Introduction to Database
Φροντιστήριο SQL (από το βιβλίο του Date)
Unit 7 Normalization (表格正規化).
Question 1: Basic Concepts (45 %)
STRUCTURE OF PRESENTATION :
Presentation transcript:

6.8 Case Study: E-R for Supplier-and-Parts Database Unit 6 Database Design and the E-R Model

Supplier-and-Parts Database <e.g.> Supplier-and-Parts Database P# PNAME COLOR WEIGHT CITY P1 Nut Red 12 London P2 Bolt Green 17 Paris P3 Screw Blue 17 Rome P4 Screw Red 14 London P5 Cam Blue 12 Paris P6 Cog Red 19 London P S# SNAME STATUS CITY S1 Smith 20 London S2 Jones 10 Paris S3 Blake 30 Paris S4 Clark 20 London S5 Adams 30 Athens S S# P# QTY S1 P1 300 S1 P2 200 S1 P3 400 S1 P4 200 S1 P5 100 S1 P6 100 S2 P1 300 S2 P2 400 S3 P2 200 S4 P2 200 S4 P4 300 S4 P5 400 SP Unit 6 Database Design and the E-R Model

Entity/Relationship Diagram Property: Relationship: <e.g> Department Employee Dependent Supplier Part Project Department_Emp SP SPJ Part_Struct Proj_Work Proj_Mngr Emp_Dependent Emp# Salary Ename First Last MI S# Sname Status City Qty 1 M Exp Imp ... P# Regular Entity Weak Entity Base Derived Multi Key Composite Regular Weak total partial Unit 6 Database Design and the E-R Model

Unit 6 Database Design and the E-R Model Semantic Concepts Entity: a thing which can be distinctly identified. e.g. S, P Weak Entities: an entity that is existence-dependent on some other entity. e.g. Dependent Regular Entities: an entity that is not weak. Property: Simple or Composite Property key: unique value Single or Multi-valued: i.e. repeating data Missing: unknown or not applicable. Base or Derived: e.g. "total quantity" Unit 6 Database Design and the E-R Model

Semantic Concepts (cont.) Relationship: association among entities. participant: the entity participates in a relationship. e.g. Employee, Dependent degree of relationship: number of participants. total participant: every instance is used. e.g. Dependent partial participant: e.g. Employee Note: An E/R relationship can be one-to-one, one-to- many, many-to-one, or many-to-many. Dependent M 1 Employee Employee Dependent E1 E2 E3 E4 . . Unit 6 Database Design and the E-R Model

Semantic Concepts (cont.) Subtype: Any given entity can be a subtype of other entity. e.g. An example type hierarchy: Programmer Employee Application Programmer Programmer Employee Programmer Application System Unit 6 Database Design and the E-R Model

Transfer E-R Diagram to SQL Definition (1) Regular Entities  Base Relations e.g. Department DEPT Employee EMP Supplier S Part P Project J attributes: properties. primary key: key property. <e.g> CREATE TABLE EMP (EMP# ...... . primary key (EMP#)); (2) Properties  attributes multivalued property: normalized first. Unit 6 Database Design and the E-R Model

Transfer E-R Diagram to SQL Definition (cont.) (3) Many-to-Many Relationships Base Relations <e.g.> Consider SUPP-PART SP foreign keys: key attributes of the participant entity. primary key: (1) combination of foreign keys, or (2) introduce a new attribute. attributes: primary key  foreign keys properties S S# SP P QTY P# M M <e.g.> CREATE TABLE SP ( S#, ..., P#, ..., Qty, ..., FOREIGN KEY (S#) REFERENCES S NULL NOT ALLOWED DELETE OF S RESTRICTED UPDATE OF S.S# CASCADES FOREIGN KEY (P#) REFERENCES P ...... PRIMARY KEY (S#, P#) ) ID S# P# QTY 1 2 3 ... Unit 6 Database Design and the E-R Model

Transfer E-R Diagram to SQL Definition (cont.) (4) Many-to-One or One-to-Many or One-to-One Relationships → 不用給Base-Relation, 但…. e.g. Consider DEPT_EMP(Department_Employee) 1° no any new relation is necessary. 2° Introduce a foreign key in "many" side relation (eg. EMP) that reference the "one" side relation (eg. DEPT). CREATE TABLE EMP ( EMP#, ... DEPT#, ... ...... FOREIGN KEY (DEPT#) REFERENCES DEPT ); Department (DEPT) DEPT_EMP EMP# DEPT# Employee (EMP) M 1 Unit 6 Database Design and the E-R Model

Transfer E-R Diagram to SQL Definition (cont.) (5) Weak Entities  Base Relation + Foreign Key foreign key: key property of its dependent entity primary key: (1) combination of foreign key and its own primary key (2) introduce a new attribute e.g. CREATE TABLE DEPENDENT ( EMP#, … name, ...... FOREIGN KEY (EMP#) REFERENCES EMP NULL NOT ALLOWED DELETE OF EMP CASCADES UPDATE OF EMP.EMP# CASCADES PRIMARY KEY ( EMP#, DEPENDENT_NAME ) ); e.g. EMP# e.g. name name EMP# Dependent M 1 EMP# EMP Unit 6 Database Design and the E-R Model

Transfer E-R Diagram to SQL Definition (cont.) (6) Supertypes and SubtypesBase Relation + Foreign Key <e.g.> CREATE TABLE EMP ( EMP#, ... DEPT#, ... SALARY, ... ...... PRIMARY KEY (EMP#), ...); CREATE TABLE PGMR LANG#, ... PRIMARY KEY (EMP#) FOREIGN KEY (EMP#) REFERENCES EMP ......); EMP PGMR Unit 6 Database Design and the E-R Model

17.7 The Entity/Relationship Model Proposed by Peter Pin-Shan Chen. “The Entity- Relationship Model,” in ACM Trans. on Database System Vol. 1, No. 1, pp.9-36, 1976. E-R Model contains: Semantic Concepts and E/R Diagram.

Entity/Relationship Diagram Property: Relationship: <e.g> Department Employee Dependent Supplier Part Project Department_Emp SP SPJ Part_Struct Proj_Work Proj_Mngr Emp_Dependent Emp# Salary Ename First Last MI S# Sname Status City Qty 1 M Exp Imp ... P# Regular Entity Weak Entity Base Derived Multi Key Composite Regular Weak total partial

Semantic Concepts Entity: a thing which can be distinctly identified. e.g. S, P Weak Entities: an entity that is existence-dependent on some other entity. e.g. Dependent Regular Entities: an entity that is not weak. Property: Simple or Composite Property key: unique value Single or Multi-valued: i.e. repeating data Missing: unknown or not applicable. Base or Derived: e.g. "total quantity"

Semantic Concepts (cont.) Relationship: association among entities. participant: the entity participates in a relationship. e.g. Employee, Dependent degree of relationship: number of participants. total participant: every instance is used. e.g. Dependent partial participant: e.g. Employee Note: An E/R relationship can be one-to-one, one-to- many, many-to-one, or many-to-many. Dependent M 1 Employee Employee Dependent E1 E2 E3 E4 . .

Semantic Concepts (cont.) Subtype: Any given entity can be a subtype of other entity. e.g. An example type hierarchy: Programmer Employee Application Programmer Programmer Employee Programmer Application System

Transfer E-R Diagram to SQL Definition (1) Regular Entities  Base Relations e.g. Department DEPT Employee EMP Supplier S Part P Project J attributes: properties. primary key: key property. <e.g> CREATE TABLE EMP (EMP# ...... . primary key (EMP#)); (2) Properties  attributes multivalued property: normalized first.

Transfer E-R Diagram to SQL Definition (cont.) (3) Many-to-Many Relationships Base Relations <e.g.> Consider SUPP-PART SP foreign keys: key attributes of the participant entity. primary key: (1) combination of foreign keys, or (2) introduce a new attribute. attributes: primary key  foreign keys properties S S# SP P QTY P# M M <e.g.> CREATE TABLE SP ( S#, ..., P#, ..., Qty, ..., FOREIGN KEY (S#) REFERENCES S NULL NOT ALLOWED DELETE OF S RESTRICTED UPDATE OF S.S# CASCADES FOREIGN KEY (P#) REFERENCES P ...... PRIMARY KEY (S#, P#) ) ID S# P# QTY 1 2 3 ...

Transfer E-R Diagram to SQL Definition (cont.) (4) Many-to-One or One-to-Many or One-to-One Relationships → 不用給Base-Relation, 但…. e.g. Consider DEPT_EMP(Department_Employee) 1° no any new relation is necessary. 2° Introduce a foreign key in "many" side relation (eg. EMP) that reference the "one" side relation (eg. DEPT). CREATE TABLE EMP ( EMP#, ... DEPT#, ... ...... FOREIGN KEY (DEPT#) REFERENCES DEPT ); Department (DEPT) DEPT_EMP EMP# DEPT# Employee (EMP) M 1

Transfer E-R Diagram to SQL Definition (cont.) (5) Weak Entities  Base Relation + Foreign Key foreign key: key property of its dependent entity primary key: (1) combination of foreign key and its own primary key (2) introduce a new attribute e.g. CREATE TABLE DEPENDENT ( EMP#, … name, ...... FOREIGN KEY (EMP#) REFERENCES EMP NULL NOT ALLOWED DELETE OF EMP CASCADES UPDATE OF EMP.EMP# CASCADES PRIMARY KEY ( EMP#, DEPENDENT_NAME ) ); e.g. EMP# e.g. name name EMP# Dependent M 1 EMP# EMP

Transfer E-R Diagram to SQL Definition (cont.) (6) Supertypes and SubtypesBase Relation + Foreign Key <e.g.> CREATE TABLE EMP ( EMP#, ... DEPT#, ... SALARY, ... ...... PRIMARY KEY (EMP#), ...); CREATE TABLE PGMR LANG#, ... PRIMARY KEY (EMP#) FOREIGN KEY (EMP#) REFERENCES EMP ......); EMP PGMR

Home Work: Term Project Design and implementation an useful, complete, and “real” database system. Steps: Take any data you are familiar with. (from your work or ?) System Analysis represented by flow chart By using the E-R model to analysis and describe your data. Design logical database, user interface, and more Design the database system as “complete and real” as possible. Due: Demo and A Comprehensive Report

end of unit 17