Lesson 4: The Relational Model. Lesson Overview Database Design Entities Relationships E-R Diagrams.

Slides:



Advertisements
Similar presentations
Chapter 6: Entity-Relationship Model (part I)
Advertisements

Entity Relationship (E-R) Modeling Hachim Haddouti
Entity Relationship (ER) Modeling
Ch5: ER Diagrams - Part 1 Much of the material presented in these slides was developed by Dr. Ramon Lawrence at the University of Iowa.
4 1 Chapter 4 Entity Relationship (ER) Modeling Database Systems: Design, Implementation, and Management, Sixth Edition, Rob and Coronel.
Entity Relationship (ER) Modeling
Systems Development Life Cycle
Text-Book Chapters (7 and 8) Entity-Relationship Model
Modeling the Data: Conceptual and Logical Data Modeling
System Analysis - Data Modeling
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 7 Data Modeling Using the Entity- Relationship (ER) Model.
Modeling Data The Entity Relationship Model (ER) For Database Design.
1–1 The E-R Model Prof. Sin-Min Lee Department of Computer Science.
Chapter 4 ENTITY-RELATIONSHIP MODELLING.
Slides adapted from A. Silberschatz et al. Database System Concepts, 5th Ed. Entity-Relationship Model Database Management Systems I Alex Coman, Winter.
Database Systems: Design, Implementation, & Management, 5 th Edition, Rob & Coronel 1 Data Models: Degrees of Data Abstraction l Modified ANSI/SPARC Framework.
Chapter 4 Entity Relationship (E-R) Modeling
Chapter 4 Entity-Relationship modeling Transparencies © Pearson Education Limited 1995, 2005.
Data Modeling 1 Yong Choi School of Business CSUB.
Chapter 3 Data Modeling Using the Entity- Relationship (ER) Model Dr. Bernard Chen Ph.D. University of Central Arkansas.
Entity-Relationship modeling Transparencies
1 © Prentice Hall, 2002 Chapter 3: Modeling Data in the Organization Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B. Prescott, Fred.
1 Web-Enabled Decision Support Systems Entity-Relationship Modeling Prof. Name Position (123) University Name.
3.1 CSIS 3310 Chapter 3 The Entity-Relationship Model Conceptual Data Modeling.
DeSiamorewww.desiamore.com/ifm1 Database Management Systems (DBMS)  B. Computer Science and BSc IT Year 1.
CSE314 Database Systems Data Modeling Using the Entity- Relationship (ER) Model Doç. Dr. Mehmet Göktürk src: Elmasri & Navanthe 6E Pearson Ed Slide Set.
the Entity-Relationship Model
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.
Entity-relationship Modeling Transparencies 1. ©Pearson Education 2009 Objectives How to use ER modeling in database design. The basic concepts of an.
Database. Basic Definitions Database: A collection of related data. Database Management System (DBMS): A software package/ system to facilitate the creation.
Module Title? Data Base Design 30/6/2007 Entity Relationship Diagrams (ERDs)
Chapter 5 Entity Relationship (ER) Modelling
Chapter 5 Entity–Relationship Modeling
1 ER Modeling BUAD/American University Entity Relationship (ER) Modeling.
9/10/2012ISC 329 Isabelle Bichindaritz1 Entity Relationship (E-R) Modeling.
4 1 Chapter 4 Entity Relationship (ER) Modeling Database Systems: Design, Implementation, and Management, Sixth Edition, Rob and Coronel.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Chapter 2: Entity-Relationship Model Entity Sets Relationship Sets Design Issues Mapping.
© Pearson Education Limited, Chapter 7 Entity-Relationship modeling Transparencies.
Chapter 12 Entity-Relationship Modeling Pearson Education © 2009.
Entity-Relationship Model Using High-Level Conceptual Data Models for Database Design Entity Types, Sets, Attributes and Keys Relationship Types, Sets,
Lecture 4 Conceptual Data Modeling. Objectives Define terms related to entity relationship modeling, including entity, entity instance, attribute, relationship,
DeSiamorePowered by DeSiaMore1 Database Management Systems (DBMS)  B. Computer Science and BSc IT Year 1.
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.
Msigwaemhttp//:msigwaem.ueuo.com/1 Database Management Systems (DBMS)  B. Computer Science and BSc IT Year 1.
1 A Demo of Logical Database Design. 2 Aim of the demo To develop an understanding of the logical view of data and the importance of the relational model.
Chapter 2 : Entity-Relationship Model Entity Sets Relationship Sets Design Issues Mapping Constraints Keys E-R Diagram Extended E-R Features Design of.
ITTelkom Entity Relationship Diagram (1) CS2343 Perancangan Basisdata Relasional.
UNIT_2 1 DATABASE MANAGEMENT SYSTEM[DBMS] [Unit: 2] Prepared By Lavlesh Pandit SPCE MCA, Visnagar.
Databases Illuminated Chapter 3 The Entity Relationship Model.
Entity Relationship Modeling
DatabaseIM ISU1 Fundamentals of Database Systems Chapter 3 Data Modeling Using Entity-Relationship Model.
1 Database Systems Entity Relationship (E-R) Modeling.
The Entity-Relationship Model, P. I R. Nakatsu. Data Modeling A data model is the relatively simple representation, usually graphic, of the structure.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 7 Data Modeling Using the Entity- Relationship (ER) Model.
Chapter 3: Modeling Data in the Organization. Business Rules Statements that define or constrain some aspect of the business Assert business structure.
Entity-Relationship Modeling. 2 Entity Type u Entity type –Group of objects with same properties, identified by enterprise as having an independent existence.
CSE 412/598 DATABASE MANAGEMENT COURSE NOTES 3. ENTITY-RELATIONSHIP CONCEPTUAL MODELING Department of Computer Science & Engineering Arizona State University.
Chapter 8 Entity-Relationship Modeling Pearson Education © 2009.
Lecture 5 Entity Relationship Modeling
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Chapter 2: Entity-Relationship Model Entity Sets Relationship Sets Mapping Constraints Keys.
McGraw-Hill/Irwin Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. Chapter 6 Modeling the Data: Conceptual and Logical Data Modeling.
Department of Mathematics Computer and Information Science1 CS 351: Database Management Systems Christopher I. G. Lanclos Chapter 4.
IS 4420 Database Fundamentals Chapter 3: Modeling Data in the Organization Leon Chen.
Entity Relationship Diagram ERD. Background Peter Chen developed ERDs in Charles Bachman and James Martin have added some slight refinements to.
Database Designsemester Slide 1 Database Design Lecture 7 Entity-relationship modeling Text , 7.1.
Entity Relationship (E-R) Model
Entity-Relationship Model
ER MODELING Instructor: SAMIA ARSHAD
Entity Relationship (ER) Modeling
Presentation transcript:

Lesson 4: The Relational Model

Lesson Overview Database Design Entities Relationships E-R Diagrams

Database Design LOGICAL DESIGN PHYSICAL DESIGN REQUIREMENTS ANALYSIS Data Structure Design Data Structure Refinement E-R Diagrams Data Models

Database Design The first step in database design is the requirement analysis where database designers interview prospective users to understand and document their data requirements.

Database Design Once the requirements have been analysed, the designer creates a conceptual schema for the database to make a graphic representation of the organisations’ data requirements independent of the DBMS and the hardware.

Database Design Steps in Database Design involve: 1.Users’requirements analysis 2.Creation of the conceptual schema by the database designers in the logical design. 2a.Design the Data Structure 2b.Refine the Data Structure The conceptual schema is a graphic representation of the organisations’ data requirements independent of the DBMS and the hardware.

Database Design In the first phase of the logical design, i.e. the data structure design, the conceptual schema of the database is developed. This is DBMS-independent. One way of representing the logical design is by using the Entity-Relationship (E- R) Diagram

Database Design In Data Structure refinement the DBMS- independent logical design is transformed into a data model compatible with the chosen DBMS. An Entity is a real world object which exist and is distinguishable from other objects. An entity is represented by a set of attributes which are properties that described the entity’s characteristics.

Database Design The identifier of an entity instance is one or more attributes. This identifier may be unique or not unique. A unique identifier identifies one and only one, entity instance. The unique identifier is known as a superkey. The superkey can be one attribute or a combination of attributes.

Entities An Entity is a real world object which exist and is distinguishable from other objects. We wish to record the data about these objects. An entity may be concrete such as a person, a book, a course etc.

Entity An entity may also be abstract or a concept such as a holiday, registration, a flight reservation etc. An entity set or an entity class is a set of all entities of the same type. It is the general form or description.

Entities The set of all students registered for a particular course for instance can be defined as the entity set STUDENT. The entity set CUSTOMER might represent the set of all persons having an account at a bank.

Entities Entity sets are not disjoint. For e.g.. we may define the entity set of all the customers of the bank, CUSTOMER, and the entity set of all employees of the bank, EMPLOYEE. A Person entity may be an EMPLOYEE entity, a CUSTOMER entity, both or neither.

Entities an entity instance is the representation of a particular entity, e.g. customer with the name Lim is an instance of the entity CUSTOMER.

Attributes An entity is represented by a set of attributes. Attributes are properties which described the entity’s characteristics. For the entity employee, possible attributes are EMPLOYEENO, EMPLOYEENAME, DATEOFHIRE.

Attributes Attributes can be single or multiple valued, simple or composite, stored or derived. For each attribute there is a set of permitted values, called the domain of that attribute.

Attributes The domain of the attribute CustomerName may be the set of all text strings of length 50.

Simple (atomic) Composite Single-valued Multi-valued Attribute types

Simple Attributes (Atomic) A simple attribute is an attribute that cannot be further divided into its components. E.g.. ?

Composite Attribute An attribute that can be further subdivided is a composite attribute. E.g.?

Single-Valued Attribute A single valued attribute can only have one value. E.g.An employee can have only one date of birth, one First Name, one Social security number An employee can have more than one degree, so EMP_Degree is a multivalued attribute Tip: Good database designs ensure that only signle valued attributes are stored in the database.

Identifiers Entity instances have names that identify them. CUSTOMER has CustomerName or CustomerNO STUDENt has Name or StudentNo COURSE has CourseName or CourseNo

Identifiers The identifier of an entity instance is one or more attributes. The identifier may be unique or not unique. If it is unique, then, it identifies one and only one, entity instance. If it is not unique, the value will identify more than one instance.

Identifiers n CustomerName is not a unique identifier because it can produce a set of instances. n Two or more customers may have the same name. n If CustomerName is to be used then additional data, such as Address, TelephoneNo or DateOfBirth is required to find a unique instance.

Relationships A relationship is an association between entities. A relationship set is a set of relationships of the same type. Relationship sets are associations between entity sets.

Relationships Relationship instances are association between entity instances. A relationship can have attributes.

Relationships STUDENT Course COURSE Register

Relationships Register is a relationship between STUDENT and COURSE A possible attribute for Register is Date. Relationships have degrees and cardinalities. The number of entities in the relationship is the degree of the relationship.

Relationship Degrees : Binary (Degree 2) LECTURER STUDENT Teach

Relationship Degrees: Ternary (Degree 3) CHILD MOTHER FATHER Parent

Relationship Degrees In a binary relationship (degree 2) each relationship set involves two entity sets. In a ternary relationship each relationship set involves three entity sets.

Binary Relationships :Relationship Types There are three types of binary relationships: one-to-one, one-to-many, many-to-one and many-to-many. These are the cardinalities of the relationships.

One-to-one Relationship (1:1) a1 a2 a3 b1 b2 b3 AB

One-to-one Relationship (1:1) In a one-to-one relationship an entity in A is associated with one and only one entity in B. A relationship between a wife and a husband is a1:1 relationship. WIFE HUSBAND Marriage has 1 1

One-to-many Relationship (1:M) a1 a2 a3 b1 b2 b3 A B b4 b5

One-to-many Relationship (1:M) An entity in A is associated with any number of entities in B. The relationship between Faculty and Students is a 1:M relationship FACULTY STUDENT Enrols 1 M

Many-to-one Relationship (M:1) a1 a2 a3 b1 b2 b3 A B a4 a5

Enrollment Is-Enrolled Many-to-one Relationship (M:1) An entity A is associated with at most one entity in B. An entity in B, however, can be associated with any number of entities in A. The relationship between Student and Faculty is M:1 STUDENT FACULTY M1

Many-to-many Relationship (M:M) a1 a2 a3 b1 b2 b3 AB

Many-to-many Relationship (M:M) An entity in A is associated with many entities in B, and an entity in B is associated with many entities in A. LECTURER STUDENT 1:M Teach MM

Many-to-many Relationship (M:M) The relationship between Lecturer and Student is M:M In the relational model, M:M relationships are broken into sets of 1:M relationships LECTURER STUDENT LECT-STUD 1 M 1 M

Composite Entity –Designed to transform an M:N relationship into two 1:M relationships –Key comprises at least the primary keys of the entities that it connects

Weak Entity Sets An entity set that does not have a primary key is referred to as a weak entity set. The existance of a weak entity set depends on the existence of a strong entity set; it must relate to the strong set via a on-to-many relationship set. A weak entity cannot exist without the related entity’s presence. E.g. Dependent is a weak entity EMPLOYEE DEPENDENTS Has

Weak Entity The primary key of a weak entity set is formed by the primary key of the strong entity set on which the weak entity set’s existence depends on.

Optional Relationship The relationship between Employee and Dependent is an optional one. An employee can have 0 or more dependents. Thus there will be cases of particular employee without dependents.

Mandatory Relationships The relationship between an EMPLOYEE and DEPARTMENT A Department must be occupied by an employee An employee must be the occupant of a department. 2 nd e.g.: An EMPLOYEE must have one EMPLOYMENT_CONTRACT and each EMPLOYMENT _CONTRACT must have one EMPLOYEE associated with it.

Subtype/Supertype Relationship The relationship between EMPLOYEE and LECTURER is a 1:1 relationship. It is also a subtype/supertype relationship because the LECTURER entity contains attributes that are unique to LECTURERS while the EMPLOYEE entity contains the entity’s common attribute.

Recursive Relationship Happens when an entity is related to itself. COURSE prerequisite

Entity-Relationship(E-R) Diagram The overall logical structure of a database is expressed graphically by an Entity- Relationship (E-R) diagram. The diagram consists of Rectangles which represent entity sets. Ellipses which represent attributes.

Entity-Relationship(E-R) Diagram Diamonds which represent relationship sets. Lines which link attributes to entity sets and entity sets to relationship sets.

Symbols Entity Relationship Composite Entity Optionality CUSTOMER generates INV_LINE DEPENDENT (Weak entity)

An ERD Segment CUSTOMERgenerates INVOICE 1 M (0,N) (1,1) cardinalities connectivities Business rules: 1. One customer may generate many invoices 2. Each invoice is generated by one customer 3. Some customers have never generated an invoice (The customer list apparently includes potential customers. Therefore, INVOICE is optional to CUSTOMER.)

An expanded ERD segment CUSTOMERgeneratesINVOICE INV_LINE PRODUCT 1 M (0,N) (1,1) (O,N)(1,1) 1 M

1:M Relationships CUSTOMERgeneratesINVOICE 1 M (0,N) (1,1) EMPLOYEE has DEPENDENT 1 M (0,N)(1,1)

A supertype/subtype relationship EMPLOYEEis a PILOT 1 1 (0,1) (1,1) The supertype contains all common attributes such as names, addresses, etc. The subtype contains all specialized attributes, such as pilot license, flight check dates, etc.

EMPLOYEEDEGREE EMP_DEGREE 1M (0,N)(1,1) M1 Implementing multi-valued attributes (1,N) Business rules: Some employees do not have degrees. (Employees are not required to have a degree.) Therefore, some employees do not occur in the EMP_DEGREE (composite) entity. A degree is entered only if at least one employee has earned that degree. But a degree can be earned by many employees.

(1,1) EMPLOYEE 1 (0,N) (1,1) M M MM (1,N) CUSTOMER 1 1 (1,N) (0,N) (1,1) contractscoordinates leads PROJECT PROJ_EMP 1 M 1 An ERD for a consulting company

1 M M1 CUSTOMERINVOICELINE (0,N)(1,1) (1,N) PRODUCT generates M 1 (1,1) (0,N) An Invoicing ERD: Composite Entity LINE Relational Schema

1 M M1 CUSTOMERINVOICELINE (0,N)(1,1) (1,N) PRODUCT generates appears in contains M 1 (1,1) (0,N) An Invoicing ERD: Composite Entity LINE Decomposed Through Named Relationships Relational Schema

1 1 M1 EMPLOYEEMECHANICMAINT_LOG (0,1)(1,1) (1,N) MAINT_LINE is a contains writes M 1 (1,N) (1,1) 1 M CUSTOMERCAR (0,N)(1,1) owns needs 1 M (1,1) (0,N) 1 PART (0,N) is in (0,1) M A Car Maintenance ERD

1 M M 1 TEAM GAME PLAYER (1,N) (1,1) uses (1,1) M (1,N) 1 M CITY (1,N) (1,1) sponsors 1 A recursive M:N relationship. Implemented through the composite entity GAME. (TEAM plays TEAM in a GAME.) Relational Schema

E-R Diagram for a BANK Database BANKBRANCH ACCOUNT CUSTOMER LOAN Name Code Add Addr BrNo LoanNo Type Amt AcctNo Balance Type CustNo PhoneNameAdd ACCTS A-C LOANS BRANCHES

Summary Steps in Database Design involve: 1.Users’requirements analysis 2.Creation of the conceptual schema by the database designers in the logical design. 2a.Design the Data Structure 2b.Refine the Data Structure The conceptual schema is a graphic representation of the organisations’ data requirements independent of the DBMS and the hardware.

Summary In the first phase of the logical design, i.e. the data structure design, the conceptual schema of the database is developed. This is DBMS-independent. One way of representing the logical design is by using the Entity-Relationship (E- R) Diagram.

Summary In Data Structure refinement the DBMS- independent logical design is transformed into a data model compatible with the chosen DBMS. An Entity is a real world object which exist and is distinguishable from other objects.

Summary An entity is represented by a set of attributes which are properties that described the entity’s characteristics. The identifier of an entity instance is one or more attributes.

Summary This identifier may be unique or not unique. A unique identifier identifies one and only one, entity instance.

Summary The unique identifier is known as a superkey. The superkey can be one attribute or a combination of attributes.

Summary {CustomerName, Address} is a superkey. Candidate keys are superkeys such that the subset of that key is not a superkey. {CustomerName, Address} is a candidate key. {CustomerNo, Address} is a superkey but not a candidate key.

Summary The candidate key chosen by the database designer as the identifier is called a primary key.

Summary A relationship is an association between entities. A binary relationship (degree 2) each relationship set involves two entity sets. binary relationships can be one-to-one, one-to-many, many-to-one and many-to- many.

Summary (E-R) diagram consists of Rectangles which represent entity sets. Ellipses which represent attributes. Diamonds which represent relationship sets. E-R diagrams are used to represent the logical structure of a database.

Next Lecture Lesson 5: Normalization I

Q & A