M.P. Johnson, DBMS, Stern/NYU, Spring 20051 C20.0046: Database Management Systems Lecture #2 Matthew P. Johnson Stern School of Business, NYU Spring, 2005.

Slides:



Advertisements
Similar presentations
Chapter 2: Entity-Relationship Model
Advertisements

Chapter 6: Entity-Relationship Model (part I)
High-Level Database Models Spring 2011 Instructor: Hassan Khosravi.
Chapter 2: Entity-Relationship Model
Dale Roberts 1 Department of Computer and Information Science, School of Science, IUPUI Dale Roberts, Lecturer Computer Science, IUPUI
Information Systems Chapter 4 Relational Databases Modelling.
1 Database Systems Lecture #2 Yan Pan School of Software, SYSU 2011.
Text-Book Chapters (7 and 8) Entity-Relationship Model
Design Principles: Faithfulness
Entity-Relationship Model. The process of designing a database begins with: –an analysis of what information the database must hold, and –the relationships.
Design Principles: Faithfulness
Matthew P. Johnson, OCL2, CISDD CUNY, January OCL2 Oracle 10g: SQL & PL/SQL Session #1 Matthew P. Johnson CISDD, CUNY January, 2005.
CS157A Lecture 3 ER Diagram Prof. Sin-Min Lee Department of Computer Science San Jose State University.
M.P. Johnson, DBMS, Stern/NYU, Sp20041 C : Database Management Systems Lecture #2 Matthew P. Johnson Stern School of Business, NYU Spring, 2004.
Entity-Relationship Model Lecture 2. Database Modeling and Implementation Process Ideas ER DesignRelational Schema Relational DBMS Implementation.
System Concepts and Architecture Rose-Hulman Institute of Technology Curt Clifton.
M.P. Johnson, DBMS, Stern/NYU, Spring C : Database Management Systems Lecture #3 Matthew P. Johnson Stern School of Business, NYU Spring, 2005.
Entity-Relationship Model
A four-way Relationship
M.P. Johnson, DBMS, Stern/NYU, Spring C : Database Management Systems Lecture #2 M.P. Johnson Stern School of Business, NYU Spring, 2008.
Entity-Relationship Data Model Alex Ostrovsky. Presentation Overview ► Short historical overview ► Elements of E-R Model ► Basic organization & relationships.
M.P. Johnson, DBMS, Stern/NYU, Sp20041 C : Database Management Systems Lecture #3 Matthew P. Johnson Stern School of Business, NYU Spring, 2004.
The Entity-Relationship Data Model
1 Lecture 3: Database Modeling (continued) April 5, 2002.
Slides adapted from A. Silberschatz et al. Database System Concepts, 5th Ed. Entity-Relationship Model Database Management Systems I Alex Coman, Winter.
Matthew P. Johnson, OCL3, CISDD CUNY, June OCL3 Oracle 10g: SQL & PL/SQL Session #1 Matthew P. Johnson CISDD, CUNY June, 2005.
1 The Entity-Relationship Data Model Chapter 2 (Database Design)
Chapter 2: Entity-Relationship Model (Continued)
Lecture 9: Conceptual Database Design January 27 th, 2003.
CS411 Database Systems Kazuhiro Minami
Database Design April 3, Projects, More Details Goal: build a DB application. (almost) anything goes. Groups of 3-4. End of week 2: groups formed.
The Entity-Relationship Model. 421B: Database Systems - ER Model 2 Overview of Database Design q Conceptual Design -- A first model of the real world.
Data Modeling Using the Entity-Relationship Model
Database Systems The Entity-Relationship Model
CS411 Database Systems Kazuhiro Minami 02: The Entity-Relationship Model.
1 ER Modeling BUAD/American University Entity Relationship (ER) Modeling.
Entity-Relationship Data Model N. Harika Lecturer(csc)
Lecture 2: E/R Diagrams and the Relational Model Thursday, January 4, 2001.
CPSC 603 Database Systems Lecturer: Laurie Webster II, M.S.S.E., M.S.E.E., M.S.BME, Ph.D., P.E. Lecture 3 Introduction to a First Course in Database Systems.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Chapter 2: Entity-Relationship Model Entity Sets Relationship Sets Design Issues Mapping.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts DB Schema Design: the Entity-Relationship Model What’s the use of the E-R model? Entity Sets.
Entity-Relationship Model Using High-Level Conceptual Data Models for Database Design Entity Types, Sets, Attributes and Keys Relationship Types, Sets,
Computing & Information Sciences Kansas State University Wednesday, 24 Sep 2008CIS 560: Database System Concepts Lecture 12 of 42 Wednesday, 24 September.
CS 405G: Introduction to Database Systems Lecture 2 : Database Design I.
Chapter 2 : Entity-Relationship Model Entity Sets Relationship Sets Design Issues Mapping Constraints Keys E-R Diagram Extended E-R Features Design of.
Conceptual Database Design. Building an Application with a DBMS Requirements modeling (conceptual, pictures) –Decide what entities should be part of the.
Tallahassee, Florida, 2015 COP4710 Database Systems E-R Model Fall 2015.
© D. Wong Ch. 2 Entity-Relationship Data Model (continue)  Data models  Entity-Relationship diagrams  Design Principles  Modeling of constraints.
Entity-Relationship Model
CPSC 603 Database Systems Lecturer: Laurie Webster II, M.S.S.E., M.S.E.E., M.S.BME, Ph.D., P.E. Lecture 2 Introduction to a First Course in Database Systems.
Databases Illuminated Chapter 3 The Entity Relationship Model.
Home Work. Design Principles and Weak Entity Sets.
Computing & Information Sciences Kansas State University Friday, 26 Sep 2008CIS 560: Database System Concepts Lecture 13 of 42 Friday, 26 September 2008.
CPSC 603 Database Systems Lecturer: Laurie Webster II, M.S.S.E., M.S.E.E., M.S.BME, Ph.D., P.E. Lecture 4 Introduction to a First Course in Database Systems.
The Entity-Relationship Model CIS 4301 Lecture Notes 1/12/2006.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Chapter 2: Entity-Relationship Model Entity Sets Relationship Sets Mapping Constraints Keys.
Lecture 26 Enterprise Systems Development ( CSC447 ) COMSATS Islamabad Muhammad Usman, Assistant Professor.
High-level Database Models Prof. Yin-Fu Huang CSIE, NYUST Chapter 4.
Modeling: Entity-Relationship Diagrams
Rationale Databases are an integral part of an organization. Aspiring Database Developers should be able to efficiently design and implement databases.
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.
The Entity-Relationship Diagram for Data Modeling
1 BBM471 – Database Management Systems Fall 2013 Assist Prof. Nazlı İkizler Cinbiş.
ER Diagrams and Relational Model CS 174a (Winter 2015)
Chapter 2: Entity-Relationship Model
Database Design Oct. 3, 2001.
Entity-Relationship Model
Database Modeling using Entity Relationship Model (E-R Model)
Chapter 7: Entity-Relationship Model
Chapter 3: Multivalued Dependencies
Presentation transcript:

M.P. Johnson, DBMS, Stern/NYU, Spring C : Database Management Systems Lecture #2 Matthew P. Johnson Stern School of Business, NYU Spring, 2005

M.P. Johnson, DBMS, Stern/NYU, Spring Admin Textbooks  Ullman book pdfsbook sent to stern.nyu accounts

M.P. Johnson, DBMS, Stern/NYU, Spring Agenda Last time: intro, RDBMS, ACID test This time: E/R model 1. Identify entity sets, relations and attributes 2. One-one, one-many, many-many relations 3. Simple ER diagrams to model a situation 4. 3-way relationships; Converting to binary 5. Entities with multiple roles 6. Subclasses Design issues 1. Principles of faithfulness & simplicity in ER diagrams 2. Redundancy 3. Whether an element should be an attribute or entity set 4. Replacing a relationships with entity sets

M.P. Johnson, DBMS, Stern/NYU, Spring DB development path the World E/R design Relational schema Relational DB

M.P. Johnson, DBMS, Stern/NYU, Spring Entity Relationship (E/R) Model A popular data model – useful to database designers Graphical representation of miniworld Used for DB design, not implementation E/R design is translated to a relational design  relational design then implemented in an RDBMS Elements of model  Entities  Entity Sets  Attributes  Relationships (!= relations!)

M.P. Johnson, DBMS, Stern/NYU, Spring Elements of E/R Model: Entity Sets Entity: like an object  e.g. President Bush  Particular instance of a concept Entity set: set of one sort of entities or a concept  e.g. World leaders  Generally, same set of attributes Represented by a rectangle A “good” entity set – you decide  Common properties  Correspond to class of phys. or bus. objects (Employees, products, accounts, grades, campaigns, etc.) World Leader

M.P. Johnson, DBMS, Stern/NYU, Spring Elements of E/R Model: Attributes Properties of entities in entity set  Like fields in a struct  Like columns in a table/spreadsheet  Like data members in an object Values in some domain (e.g., ints, strings) Represented by ovals: Assumed atomic  But could have limited structure  ints, strings, etc. ID Name Student

M.P. Johnson, DBMS, Stern/NYU, Spring Elements of E/R Model: Relationships Connect two or more entity sets  e.g. students enroll in courses  Binary relationships: connect two entity sets – most common  Multiway relationships: connect several entity sets Represented by diamonds StudentsEnrollCourses

M.P. Johnson, DBMS, Stern/NYU, Spring Elms of E/R Model: Rel’ships (cont’d) Students Enroll in courses Courses are Held in rooms The E/R data model: StudentsEnrollCourses Held Rooms Name ID

M.P. Johnson, DBMS, Stern/NYU, Spring A little set theory A mathematical set a collection of members A set is defined by its members  “Are you in or are you out?”  No other structure, no order, no duplicates allowed Sets specified by listing:  {1, 2, 3, …} = N  {1, 2, George Bush} (not useful in DBMS) Or by “set-builder” notation:  { x in N: 2 divides x} = ?  { x in Presidents | reelected(x)} = ?  {2x: x in N} = ?

M.P. Johnson, DBMS, Stern/NYU, Spring A little set theory One set can be a subset of another (which is a superset of it)  ReelectedPresidents is a subset of Presidents  Also, RP is a proper subset of Pres – some lost reelection Given two sets X and Y, the cross product or Cartesian product is X x Y = {(x,y): x in X, y in Y} = the set of all ordered pairs in which the first comes from X and the second comes from Y Important: (x,y) != {x,y} In an order pair or tuple  Order matters  Duplicates are allowed

M.P. Johnson, DBMS, Stern/NYU, Spring A little set theory Mathematically, a relation between X and Y is just a subset of X x Y = all those pairs (x,y) s.t. x is related to y Example: owner-of O on People, Cats  O(MPJ, Gödel) holds The equals relation E on N, N:  E(3,3) holds because 3 = 3  E(3,4) does not hold  E is still a set: E = {(1,1), (2,2), (3,3), …} Father of relation F on People, People:  F(GHWB, GWB) holds  F(GWB, GHWB) does not hold   Relations aren’t necessarily symmetric

M.P. Johnson, DBMS, Stern/NYU, Spring Many-many Multiplicity of Relationships Many-one One-one Representation of relationships No arrow: many-to-many Sharp arrow: many-to-one Rounded arrow: “exactly one”  “key constraint” One-one:

M.P. Johnson, DBMS, Stern/NYU, Spring Multiplicity of Relationships StudentsEnrollsCourses Many-to-many: Student Live Residence hall Many to one: a student living in a residence hall Many to exactly one: a student must live in a residence hall Student Live Residence hall

M.P. Johnson, DBMS, Stern/NYU, Spring Multiplicity, set-theoretically Assume no vars below are equal Many-one means:  if (x1,y1) in R then (x1,y2) cannot be in R One-many means:  if (x1, y1) in R then (x2,y1) cannot be in R One-one means:  if (x1,y1) in R, then neither (x2,y1) nor (x1,y2) can be in R Notice: one-one is stronger than many-one One-one implies both many-one and one-many

M.P. Johnson, DBMS, Stern/NYU, Spring E/R Diagram StudentsCourses Enrolls ID Name ID Name Assisting TA ID Name

M.P. Johnson, DBMS, Stern/NYU, Spring E/R Diagrams Works if each TA is a TA of all students  Student and TA connected only through Course But what if students were divided among multiple TAs?  Then a student in C would be related to only one of the TA's for C —which one?  Schema doesn’t store enough info 3-way relationship is helpful here

M.P. Johnson, DBMS, Stern/NYU, Spring Multiway Relationships Students Courses TAs Enrolls StudentsCoursesTAs Condi C Donald George C Dick Alberto C Colin ……… Enrolls entries: NB: Enrolls determines TA: (student, course)  at most one TA

M.P. Johnson, DBMS, Stern/NYU, Spring Converting multiway relships to binary Some models (e.g. ODL) limit relationships to binary Multiway relationship – equivalent collection of binary, many to one relationships Replace relationship with connecting entity set Students Courses TAs Enrolls Student-of Course-of TA- of NB: Enrolls has no attributes!

M.P. Johnson, DBMS, Stern/NYU, Spring Second multiway e.g.: renting movies Scenario: a Customer Rents a Movie from a VideoStore on a certain date Q: Which entity does date belong to? A: To the fact of the renting Relationships can have attributes  always (implicitly) many-one Rental VideoStore Customer Movie date

M.P. Johnson, DBMS, Stern/NYU, Spring Second multiway e.g.: renting movies But they don’t have to Relationship attributes can be replaced with (trivial) new entities Rental VideoStore Customer Movie date Date

M.P. Johnson, DBMS, Stern/NYU, Spring Where can we draw arrows? (store, video, customer)  date ?  Date is a relship att, implicitly determined (store, video, date)  customer ? (store, date, customer)  video ? (video, date, customer)  store ? Second multiway e.g.: renting movies Rental VideoStore Customer Movie date

M.P. Johnson, DBMS, Stern/NYU, Spring Q: Why does it matter? Round arrow benefit:  Obvious: One item takes less space than many  Less obvious: easier to access one item x than set of one item {x} In programming: an int v. a linked list with just one int Regular arrow benefit:  Mapping to a set of either one elm or none seems bad  But not implemented this way  Always one element, but that value may be NULL Lesson: it pays to identify your relship’s multiplicity

M.P. Johnson, DBMS, Stern/NYU, Spring Second multiway e.g.: renting movies Convert to binary? Rental VideoStore Customer Movie date Rental Customer Store Movie StoreOf MovieOf BuyerOf date

M.P. Johnson, DBMS, Stern/NYU, Spring Roles in relationships Entity set appears more than once in a relship  Generally distinct entities Each appearance is in a different role Edges labeled by roles Pre-req Prereq Successor Course Course (Pre-req) Course (Successor) AccountingFinance-I Derivatives Finance-IFinance-II CalculusDerivatives

M.P. Johnson, DBMS, Stern/NYU, Spring Subclasses in the E/R model Some entities are special cases of other Conversely: some are generalizations  Humans are specialized mammals  Grad students are specialized students And, in turn, specialized mammals  NB: These aren’t examples but subclasses Subclass A isa B  Represented by a triangle  Always one-to-one, though arrows omitted  Root is more general  Multiple inheritance is allowed!  A single entity may consist of all components (sets of fields) in aribtrary ESs and their ancestors

M.P. Johnson, DBMS, Stern/NYU, Spring Subclasses Movies Cartoons Murder- Mysteries isa Voices Weapon stars length title year Lion King Component “Lion King”: atts of Movies; relship Voices “Roger Rabbit”: atts of Movies; relship Voices; att weapon Roger Rabbit TX Chainsaw Massacre

M.P. Johnson, DBMS, Stern/NYU, Spring E/R inheritance v. OO inheritance In a OOP class hierarchy, children also inherit “attributes” from parents  But an object is an instance of one class In E/R, an entity may be composed of components from multiple, not-directly-related ESs  Roger Rabbit is composed of components from Cartoons, Murder Mysteries, and Movies  We could create a Cartoon Murder Mysteries ES if there were any atts specific to them So the real difference: In E/R, can have implicit multiple inheritance between any set of IS-A- connected nodes (sharing a root)

M.P. Johnson, DBMS, Stern/NYU, Spring Design Principles Faithfulness Avoiding redundancy Simplicity Choice of relationships Picking elements

M.P. Johnson, DBMS, Stern/NYU, Spring Faithfulness Is the relationship many-many or many-one? Are the attributes appropriate? Are the relationships applicable to the entities? Examples  Courses & instructors maybe many-one, maybe many-many  Bosses & subordinates maybe one-many, maybe many-many

M.P. Johnson, DBMS, Stern/NYU, Spring Simplicity Einstein: Theories as simple as possible, but not simpler. Use as few elements as possible  Minimum required relations  No unnecessary attributes (will you be using this attribute?)  Eliminate “spinning wheels” Example: how can we simplify this? MoviesOwningsStudios Owned-byOwns

M.P. Johnson, DBMS, Stern/NYU, Spring Next time We’ll finish E/R models and begin the relational model Read chapter 3 Info on project likely posted soon