Modeling Your Data Chapter 2. Overview of Database Design Conceptual design: –What are the entities and relationships in the enterprise? – What information.

Slides:



Advertisements
Similar presentations
The Entity-Relationship Model
Advertisements

The Entity-Relationship Model
Conceptual Design using the Entity-Relationship Model
Database Management Systems, R. Ramakrishnan and J. Gehrke1 The Entity-Relationship Model Chapter 2.
The Entity-Relationship Model
Database Management Systems, R. Ramakrishnan and J. Gehrke1 The Entity-Relationship Model Chapter 2.
Book Chapter 3 (part 2 ) From ER to Relational Model.
1 541: Database Systems S. Muthu Muthukrishnan. 2 Overview of Database Design  Conceptual design: (ER Model is used at this stage.)  What are the entities.
1 Key Constraints Consider Works_In: An employee can work in many departments; a dept can have many employees. In contrast, each dept has at most one manager,
The Entity-Relationship (ER) Model
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 The Entity-Relationship Model Chapter 2.
The Entity-Relationship Model
Comp3300/fall021 The Entity-Relationship Model Chapter 2 What are the steps in designing a database ? Why is the ER model used to create an initial design?
The Entity-Relationship Model
The Entity-Relationship Model Jianlin Feng School of Software SUN YAT-SEN UNIVERSITY courtesy of Joe Hellerstein for some slides.
Conceptual Design and The Entity-Relationship Model
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 The Entity-Relationship Model Chapter 2.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 The Entity-Relationship Model Chapter 2.
1 The Entity-Relationship Model Chapter 2. 2 Overview of Database Design  Conceptual design: (ER Model is used at this stage.) –What are the entities.
The Entity-Relationship Model
Conceptual Design Using the Entity-Relationship (ER) Model
The Entity- Relationship Model CS 186 Fall 2002: Lecture 2 R &G - Chapter 2 A relationship, I think, is like a shark, you know? It has to constantly move.
The Entity-Relationship (ER) Model CS541 Computer Science Department Rutgers University.
1 Data Modeling Yanlei Diao UMass Amherst Feb 1, 2007 Slides Courtesy of R. Ramakrishnan and J. Gehrke.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 The Entity-Relationship Model Chapter 2.
ER continued, and ER to Relational Mappings R&G Chapters 2, 3 Lecture 22.
1 The Entity-Relationship Model Chapter 2. 2 Database Design Process  Requirement collection and analysis  DB requirements and functional requirements.
ISOM MIS710 Module 1a Data and Process Modeling Arijit Sengupta.
The Entity-Relationship Model. 421B: Database Systems - ER Model 2 Overview of Database Design q Conceptual Design -- A first model of the real world.
1 The Entity-Relationship Model Chapter 2. 2 Overview of Database Design  Conceptual design : (ER Model is used at this stage.)  What are the entities.
ER to Relational Mapping. Logical DB Design: ER to Relational Entity sets to tables. CREATE TABLE Employees (ssn CHAR (11), name CHAR (20), lot INTEGER,
1 The Entity-Relationship Model Chapter 6. 2 Database Design Process  Requirement collection and analysis  DB requirements and functional requirements.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 The Entity-Relationship Model Chapter 2.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 The Entity-Relationship Model Chapter 2.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 The Entity-Relationship Model Chapter 2.
Chapter 2.  Conceptual design: (ER Model is used at this stage.) ◦ What are the entities and relationships in the enterprise? ◦ What information about.
CMPT 258 Database Systems The Entity-Relationship Model Part II (Chapter 2)
ICS 321 Spring 2011 High Level Database Models Asst. Prof. Lipyeow Lim Information & Computer Science Department University of Hawaii at Manoa 2/7/20111Lipyeow.
Christoph F. Eick: Designing E/R Diagrams 1 The Entity-Relationship Model Chapter 3+4.
LECTURE 1: Entity Relationship MODEL. Think before doing it! Like most of the software projects, you need to think before you do something. Before developing.
09/03/2009Lipyeow Lim -- University of Hawaii at Manoa 1 ICS 321 Fall 2009 Introduction to Database Design Asst. Prof. Lipyeow Lim Information & Computer.
Database Management Systems,1 Conceptual Design Using the Entity-Relationship (ER) Model.
1 Conceptual Design using the Entity- Relationship Model.
Lecture 3 Book Chapter 3 (part 2 ) From ER to Relational.
The Entity-Relationship (ER) Model. Overview of db design Requirement analysis – Data to be stored – Applications to be built – Operations (most frequent)
CSC 411/511: DBMS Design 1 1 Dr. Nan WangCSC411_L2_ER Model 1 The Entity-Relationship Model (Chapter 2)
ER & Relational: Digging Deeper R &G - Chapters 2 & 3.
Mapping E/R to RM, R. Ramakrishnan and J. Gehrke with Dr. Eick’s additions 1 Mapping E/R Diagrams to Relational Database Schemas Second Half of Chapter.
LECTURE 1: Entity Relationship MODEL. Think before doing it! Like most of the software projects, you need to think before you do something. Before developing.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 The Entity-Relationship Model Chapter 2.
A short review on entity- relationship modelling.
1 Introduction to Data Management Lecture #3 (Conceptual DB Design) Instructor: Chen Li.
Database Management Systems, R. Ramakrishnan and J. Gehrke1 The Entity-Relationship Model Chapter 2.
COP Introduction to Database Structures
MODELS OF DATABASE AND DATABASE DESIGN
The Entity-Relationship Model
Instructor: Elke Rundensteiner
The Entity-Relationship (ER) Model
The Entity-Relationship Model
The Entity-Relationship Model
The Entity-Relationship Model
The Entity-Relationship Model
The Entity-Relationship Model
The Entity-Relationship Model
Question Which of the following plays an important role in representing information about the real world in a database? Explain briefly 1)DDL.
The Entity-Relationship Model
The Entity-Relationship Model
The Entity-Relationship Model
The Entity-Relationship (ER) Model
Presentation transcript:

Modeling Your Data Chapter 2

Overview of Database Design Conceptual design: –What are the entities and relationships in the enterprise? – What information about these entities and relationships should we store in the database? – What are the integrity constraints or business rules that hold?

Overview of Database Design –ER Model is used at this stage. – A database `schema’ in the ER Model can be represented pictorially (ER diagrams). – Can map an ER diagram into a relational schema.

ER Model Basics Entity: Real-world object distinguishable from other objects. An entity is described (in DB) using a set of attributes. Entity Set: A collection of similar entities. E.g., all employees. – All entities in entity set have same set of attributes. – Each entity set has a key. – Each attribute has a domain. Employees ssn name lot

ER Model Basics (Contd.) Relationship: Association among two or more entities. E.g., Attishoo works in Pharmacy depart. Relationship Set: Collection of similar relationships. – An n-ary relationship set R relates n entity sets E1... En; – each relationship in R involves entities e1 from E1,..., en from En Same entity set could participate in different relationship sets, or in different “roles” in same set.

ER Model Basics (Contd.) Relationship: Association among two or more entities. lot dname budget did since name Works_In DepartmentsEmployees ssn

ER Model Basics (Contd.) Relationship: Same entity set could participate in different relationship sets, or in different “roles” in the same set. Reports_To lot name Employees subor- dinate super- visor ssn

Key Constraints Many-to-Many 1-to-11-to ManyMany-to-1

Which key constraint ? lot dname budget did since name Works_In DepartmentsEmployees ssn

Key constraints Consider Works_In: An employee can work in many departments; and a dept can have many employees. lot dname budget did since name Works_In DepartmentsEmployees ssn

Which key constraint ? lot dname budget did since name Works_In DepartmentsEmployees ssn Many-to-Many 1-to-11-to ManyMany-to-1

Which Key Constraint Case ?? Consider Manager Relation- ship? dname budgetdid since lot name ssn Manages Employees Departments

Which Key Constraint Case ?? Consider Manager Relation- ship? Each dept has at most one manager. Many-to-Many 1-to-11-to ManyMany-to-1 dname budgetdid since lot name ssn Manages Employees Departments

Key Constraint: 1 - to - many Each dept has at most one manager, according to the key constraint on Manages. dname budgetdid since lot name ssn Manages Employees Departments dname budgetdid since lot name ssn Manages Employees Departments [0:1] [0:n]

Key Constraints : all four cases ? In contrast, each dept has at most one manager, according to the key constraint on Manages. Many-to-Many 1-to-11-to ManyMany-to-1 dname budgetdid since lot name ssn Manages Employees Departments

Key Constraints Consider Works_In: An employee can work in many departments; a dept can have many employees. In contrast, each dept has at most one manager, according to the key constraint on Manages. Many-to-Many 1-to-11-to ManyMany-to-1 dname budgetdid since lot name ssn Manages Employees Departments

Participation Constraints Must every department have a manager? lot name dname budgetdid since name dname budgetdid since Manages Departments Employees ssn ??

Participation Constraints If every department has a manager, then this is a participation constraint: the participation of Departments in Manages is said to be total (vs. partial). lot name dname budgetdid since name dname budgetdid since Manages Departments Employees ssn ??

Participation Constraints Or, put differently, every did value in Departments table must appear in a row of the Manages table (with a non-null ssn value!) lot name dname budgetdid since name dname budgetdid since Manages Departments Employees ssn ??

Participation Constraints Every department must have a manager! lot name dname budgetdid since name dname budgetdid since Manages Departments Employees ssn

Participation Constraints ? lot dname budget did since name Works_In DepartmentsEmployees ssn

Participation Constraints ! every department have a manager every employe works in at least one dept. every dept has at least one employee lot name dname budgetdid since name dname budgetdid since Manages since Departments Employees ssn Works_In

Weak Entities A weak entity can be identified uniquely only by considering the primary key of another (owner) entity. lot name age pname Dependents Employees ssn Policy cost

Weak Entities weak entity identified uniquely only by considering primary key of another (owner) entity. – Owner entity set and weak entity set must participate in a one-to-many relationship set (one owner, many weak entities). – Weak entity set must have total participation in this identifying relationship set. lot name age pname Dependents Employees ssn Policy cost

ISA (`is a’) Hierarchies Contract_Emps name ssn Employees lot hourly_wages ISA Hourly_Emps contractid hours_worked 1. As in C++, or other PLs, attributes are inherited. 2. If we declare A ISA B, every A entity is also considered to be a B entity.

ISA (`is a’) Hierarchies Contract_Emps name ssn Employees lot hourly_wages ISA Hourly_Emps contractid hours_worked Reasons for using ISA: – To add descriptive attributes specific to a subclass. – To identify entities that participate in a relationship. Implicit Relationship Between Super- And Subentity? 1-1 ?

ISA (`is a’) Hierarchies Contract_Emps name ssn Employees lot hourly_wages ISA Hourly_Emps contractid hours_worked Overlap constraints: Can Joe be Hourly_Emps as well as Contract_Emps entity? (Allowed/disallowed) Covering constraints: Does every Employees entity also have to be an Hourly_Emps or a Contract_Emps entity? (Yes/no)

ISA (`is a’) Hierarchies Contract_Emps name ssn Employees lot hourly_wages ISA Hourly_Emps contractid hours_worked v As in C++, or other PLs, attributes are inherited. v If we declare A ISA B, every A entity is also considered to be a B entity. Overlap constraints: Can Joe be an Hourly_Emps as well as a Contract_Emps entity? (Allowed/disallowed) Covering constraints: Does every Employees entity also have to be an Hourly_Emps or a Contract_Emps entity? (Yes/no) Reasons for using ISA : – To add descriptive attributes specific to a subclass. – To identify entitities that participate in a relationship.

Aggregation Used when we have to model a relationship involving entity sets and a relationship set. budget did pid started_on pbudget dname until Departments Projects Sponsors Employees Monitors lot name ssn since

Aggregation Aggregation allows us to treat a relationship set as an entity set for purposes of participation in (other) relationships budget did pid started_on pbudget dname until Departments Projects Sponsors Employees Monitors lot name ssn since

Aggregation * Aggregation vs. ternary relationship : v Monitors is a distinct relationship, with a descriptive attribute. v Also, can say that each sponsorship is monitored by at most one employee. budget did pid started_on pbudget dname until Departments Projects Sponsors Employees Monitors lot name ssn since

Summary of Conceptual Design Conceptual design follows requirements analysis, – Yields a high-level description of data to be stored ER model popular for conceptual design – Constructs are expressive, close to the way people think about their applications. Basic constructs: entities, relationships, and attributes (of entities and relationships). Some additional constructs: weak entities, ISA hierarchies, and aggregation. Note: There are many variations on ER model.

Summary of ER (Contd.) Several kinds of integrity constraints can be expressed in ER model: –key constraints, –participation constraints, and –overlap/covering constraints for ISA hierarchies. –Some foreign key constraints also implicit in definition of a relationship set. – Some constraints (notably, functional dependencies) cannot be expressed in the ER model. – Constraints play an important role in determining the best database design for an enterprise.