Database Design & ER Diagrams

Slides:



Advertisements
Similar presentations
Logical DB Design: ER to Relational Entity sets to tables. Employees ssn name lot CREATE TABLE Employees (ssn CHAR (11), name CHAR (20), lot INTEGER, PRIMARY.
Advertisements

Prof. Sin-Min Lee Department of Computer Science
Relational Database. Relational database: a set of relations Relation: made up of 2 parts: − Schema : specifies the name of relations, plus name and type.
Database Management Systems, R. Ramakrishnan and J. Gehrke1 The Relational Model Chapter 3.
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.
The Entity-Relationship (ER) Model
SQL Lecture 10 Inst: Haya Sammaneh. Example Instance of Students Relation  Cardinality = 3, degree = 5, all rows distinct.
The Relational Model System Development Life Cycle Normalisation
Chapter 3 The Relational Model Transparencies © Pearson Education Limited 1995, 2005.
Databases Revision.
1 Translation of ER-diagram into Relational Schema Prof. Sin-Min Lee Department of Computer Science.
SPRING 2004CENG 3521 The Relational Model Chapter 3.
Database Design Conceptual –identify important entities and relationships –determine attribute domains and candidate keys –draw the E-R diagram Logical.
Chapter 3. 2 Chapter 3 - Objectives Terminology of relational model. Terminology of relational model. How tables are used to represent data. How tables.
Relational Model Stores data as tables –Each column contains values about the same attribute –Each column has a distinct name –Each row contains values.
Conceptual Design Using the Entity-Relationship (ER) Model
Modeling Data The Entity Relationship Model (ER) For Database Design.
1 Relational Model. 2 Relational Database: Definitions  Relational database: a set of relations  Relation: made up of 2 parts: – Instance : a table,
Methodology Logical Database Design for the Relational Model
1 Data Modeling Yanlei Diao UMass Amherst Feb 1, 2007 Slides Courtesy of R. Ramakrishnan and J. Gehrke.
SLIDE 1IS Fall 2002 Database Management: Discussion Session University of California, Berkeley School of Information Management and.
Sunday, June 28, Entity-Relationship and Enhanced Entity-Relationship Conceptual Data Models (Chapters 6 & Section 7.1)
Chapter 4 Relational Databases Copyright © 2012 Pearson Education, Inc. publishing as Prentice Hall 4-1.
Entity-Relationship (E-R) Model
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.
Data Modeling Using the Entity-Relationship Model
Chapter 4 The Relational Model Pearson Education © 2014.
Chapter 4 The Relational Model.
1 The Relational Model Chapter 3. 2 Why Study the Relational Model?  Most widely used model  Vendors: IBM, Informix, Microsoft, Oracle, Sybase  Recent.
Alexander Tzokev 2005 FDIBA Lecture 2 The Entity-Relationship Model The Relational Model.
CSCI 3140 Module 2 – Conceptual Database Design Theodore Chiasson Dalhousie University.
Entity Relationship Modeling
Concepts and Terminology Introduction to Database.
CSCI 3140 Module 3 – Logical Database Design for the Relational Model Theodore Chiasson Dalhousie University.
Lecture2: Database Environment Prepared by L. Nouf Almujally & Aisha AlArfaj 1 Ref. Chapter2 College of Computer and Information Sciences - Information.
1 The Relational Model. 2 Why Study the Relational Model? v Most widely used model. – Vendors: IBM, Informix, Microsoft, Oracle, Sybase, etc. v “Legacy.
FALL 2004CENG 351 File Structures and Data Management1 Relational Model Chapter 3.
DataBase Management System What is DBMS Purpose of DBMS Data Abstraction Data Definition Language Data Manipulation Language Data Models Data Keys Relationships.
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.
1 © Prentice Hall, 2002 Chapter 5: Logical Database Design and the Relational Model Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B.
1 Chapter 17 Methodology - Local Logical Database Design.
UNIT_2 1 DATABASE MANAGEMENT SYSTEM[DBMS] [Unit: 2] Prepared By Lavlesh Pandit SPCE MCA, Visnagar.
Databases Illuminated Chapter 3 The Entity Relationship Model.
CMPT 258 Database Systems The Relationship Model PartII (Chapter 3)
The Entity-Relationship (ER) Model. Overview of db design Requirement analysis – Data to be stored – Applications to be built – Operations (most frequent)
1 ER Modeling BUAD/American University Mapping ER modeling to Relationships.
The Relational Model. 2 Relational Model Terminology u A relation is a table with columns and rows. –Only applies to logical structure of the database,
The Relational Model Jianlin Feng School of Software SUN YAT-SEN UNIVERSITY.
CS34311 The Relational Model. cs34312 Why Relational Model? Currently the most widely used Vendors: Oracle, Microsoft, IBM Older models still used IBM’s.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 The Relational Model Chapter 3.
The Relational Model © Pearson Education Limited 1995, 2005 Bayu Adhi Tama, M.T.I.
Mapping ER to Relational Model Each strong entity set becomes a table. Each weak entity set also becomes a table by adding primary key of owner entity.
CSCI 6315 Applied Database Systems Review for Midterm Exam I Xiang Lian The University of Texas Rio Grande Valley Edinburg, TX 78539
FEN Introduction to the database field: The development process Seminar: Introduction to relational databases Development process: Analyse.
IT 5433 LM2 ER & EER Model. Learning Objectives: Explain importance of data modeling Define and use the entity-relationship model Define E/R terms Describe.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 The Relational Model Chapter 3.
1 CS122A: Introduction to Data Management Lecture #4 (E-R  Relational Translation) Instructor: Chen Li.
CENG 351 File Structures and Data Management1 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.
April 20022/CS/3X1 Database Design Design method John Wordsworth Department of Computer Science The University of Reading Room.
ER Diagrams and Relational Model CS 174a (Winter 2015)
COP Introduction to Database Structures
Conceptual Design & ERD Modelling
Quiz Questions Q.1 An entity set that does not have sufficient attributes to form a primary key is a (A) strong entity set. (B) weak entity set. (C) simple.
Translation of ER-diagram into Relational Schema
The Relational Model Relational Data Model
Presentation transcript:

Database Design & ER Diagrams Basis Data 2

ER, Relational Model

Database Design The database design process can be divided into six steps. The ER model is most relevant to the first three steps. Requirements Analysis Conceptual Database Design Logical Database Design 1. what data is to be stored in the database, what applications must be built on top of it, and what operations are most frequent and subject to performance requirements 2. The information gathered in the requirements analysis step is used to develop a high-level description of the data to be stored in the database, along with the constraints known to hold over this data. This step is often carried out using the ER model The ER model is one of several high-level, or semantic, data models used in database design. The goal is to create a simple description of the data that closely matches how users and developers think of the data 3. We must choose a DBMS to implement our database design, and convert the conceptual database design into a database schema in the data model of the chosen DBMS. We will consider only relational DBMSs, and therefore, the task in the logical design step is to convert an ER schema into a relational database schema.

The remaining three steps of database design Schema Refinement Physical Database Design Application and Security Design 4. The fourth step ill databa')e design is to analyze the collection of relations in our relational database schema to identify potential problems, and to refine it. In contrast to the requirements analysis and conceptual design steps, which are essentially subjective, schema refinement can be guided by some elegant and powerful theory. 5. In this step, we consider typical expected workloads that our database must support and further refine the database design to ensure that it meets desired performance criteria. This step may simply involve building indexes on some tables and clustering some tables, or it may involve a substantial redesign of parts of the database schema obtained from the earlier design steps.

Entities, Attributes, And Entity Sets An entity is an object in the real world that is distinguishable from other objects It is often useful to identify a collection of similar entities. Such a collection is called an entity set An entity is described using a set of attributes. All entities in a given entity set have the same attributes; this is what we mean by similar. For each attribute associated with an entity set, we must identify a domain of possible values derived attribute can be obtained from other attributes or related entities Weak and Strong Entity is…

Relationships And Relationship Sets A relationship is an association among two or more entities. Set of similar relationships is called relationship set. A relationship set can be thought of as a set of n-tuples: A relationship can also have descriptive attributes  used to record information about the relationship [Employee] -- <work> -- [department] | (since)  descriptive attribute As another example of an ER diagram, suppose that each department has offices in several locations and we want to record the locations at which each employee works. This relationship is ternary because we must record an association between an employee, a department, and a location.

ADDITIONAL FEATURES OF THE ER MODEL Key Constraints

Additional Features Of The ER Model Key Constraints  statement that a certain minimal subset of the fields of a relation is a unique identifier for a tuple A set of fields that uniquely identifies a tuple according to a key constraint is called a candidate key for the relation; we often abbreviate this to just key Sometimes the information stored in a relation is linked to the information stored in another relation that’s why we need Foreign Key. The foreign key in the referencing relation must match the primary key of the referenced relation, that is must have the same number of columns and compatible data types

Cardinality Constraints Cardinality of relationship One to one One to many Many to many

Participation Constraints

Participation Constraints

Additional Features Of The ER Model Weak Entities Class Hierarchies

Enhanced ER Models (EER) Semantic modelling concepts (abstraction) Specialisation Generalisation Classification/Categorisation Aggregation First we need some new entity constructs. Superclass - an entity type that includes distinct subclasses that require to be represented in a data model. Subclass - an entity type that has a distinct role and is also a member of a superclass.

Specialisation This is the process of maximising the differences between members of an entity by identifying their distinguishing characteristics. Here we have shown that the manages relationship is only applicable to the Manager subclass, whereas the works_for relationship is applicable to all staff. It is possible to have subclasses of subclasses.

Generalisation Generalisation is the process of minimising the differences between entities by identifying common features. This is the identification of a generalised superclass from the original subclasses. This is the process of identifying the common attributes and relationships. For instance, taking: car(regno,colour,make,model,numSeats) motorbike(regno,colour,make,model,hasWindshield) And forming: vehicle(regno,colour,make,model,numSeats,hasWindshielf)

Categorisation ? Aggregation ? Classification abstraction defines a class of objects with a common set of properties. It collects similar things into a class. Example: class month = {January, February, . . .}. January, February, etc., are members of class month. In other words, January, February, etc., are classified as month. The arc represents the relationship: IS_MEMBER_OF. Thus, we say January IS_MEMBER_OF class month. The E-R model cannot express relationships among relationships. The solution is to use aggregation. An abstraction through which relationships are treated as higher-level entities. For our example, we treat the relationship set work and the entity sets employee and project as a higher-level entity set called work.

Conceptual Design With The ER Model Entity versus Attribute Entity versus Relationship Binary versus Ternary Relationships Aggregation versus Ternary Relationships

Integrity Constraints Over Relations Key Constraints Which one is the primary key used in the table Foreign Key Constraints Which one is the foreign key to refer to another table General Constraints The domain in the attribute

Enforcing Integrity Constraints Insert  if not exists in referenced table, reject the insertion Delete  can be one of the options: Delete all rows in referenced table Disallow deletion Set the primary key to the existing default row Set the primary key to null Update  same as previous

Enforcing Integrity Constraints CREATE TABLE Enrolled ( studid CHAR(20) ,cid CHAR(20) , grade CHAR(10), PRIMARY KEY (studid, dd), FOREIGN KEY (studid) REFERENCES Students ON DELETE CASCADE ON UPDATE NO ACTION) CASCADE , if a Students row is deleted, all rows that refer to it are to be deleted as well ON DELETE SET DEFAULT set to default as defined in default value constraint

Logical Database Design: ER to Relational Entity Sets to Tables Relationship Sets (without Constraints) to Tables Translating Relationship Sets with Key Constraints Translating Relationship Sets with Participation Constraints Translating Weak Entity Sets Translating Class Hierarchies Translating ER Diagrams with Aggregation

Normalization

Schema Refinement Why do we need decomposition? What is Functional Dependency (FD)? Normal forms 1NF 2NF 3NF Boyce-Codd (BCNF) 4NF 5NF