Lecture 9: Data Design CSC 470 Spring 2010.

Slides:



Advertisements
Similar presentations
Relational Model (CB Chapter 4) CPSC 356 Database Ellen Walker Hiram College.
Advertisements

Ch5: ER Diagrams - Part 1 Much of the material presented in these slides was developed by Dr. Ramon Lawrence at the University of Iowa.
Chapter 3 The Relational Model Transparencies © Pearson Education Limited 1995, 2005.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 3 The Basic (Flat) Relational Model.
Lecture Eleven Entity-Relationship Modelling
Chapter 3. 2 Chapter 3 - Objectives Terminology of relational model. Terminology of relational model. How tables are used to represent data. How tables.
Modeling Data The Entity Relationship Model (ER) For Database Design.
Mapping ERD to Relational Models
Chapter 4 ENTITY-RELATIONSHIP MODELLING.
1 Minggu 2, Pertemuan 3 The Relational Model Matakuliah: T0206-Sistem Basisdata Tahun: 2005 Versi: 1.0/0.0.
Database Systems: Design, Implementation, & Management, 5 th Edition, Rob & Coronel 1 Data Models: Degrees of Data Abstraction l Modified ANSI/SPARC Framework.
1 Pertemuan 04 MODEL RELASIONAL Matakuliah: >/ > Tahun: > Versi: >
Chapter 4 Entity-Relationship modeling Transparencies © Pearson Education Limited 1995, 2005.
Relational Database Management System A type of database in which records are stored in relational form is called relational database management system.
Database Architecture The Relational Database Model.
Chapter 12 Entity-Relationship Modeling Pearson Education © 2009.
Dr. Mohamed Osman Hegaz1 Conceptual data base design: The conceptual models: The Entity Relationship Model.
Relational Model & Relational Algebra. 2 Relational Model u Terminology of relational model. u How tables are used to represent data. u Connection between.
Lecture 2 The Relational Model. Objectives Terminology of relational model. How tables are used to represent data. Connection between mathematical relations.
Chapter 4 The Relational Model Pearson Education © 2014.
© Pearson Education Limited, Chapter 2 The Relational Model Transparencies.
Module Title? DBMS E-R Model to Relational Model.
Relational Model Session 6 Course Name: Database System Year : 2012.
1 The Relational Data Model, Relational Constraints, and The Relational Algebra.
Chapter 4 The Relational Model.
Chapter 3 The Relational Model Transparencies Last Updated: Pebruari 2011 By M. Arief
Content Resource- Elamsari and Navathe, Fundamentals of Database Management systems.
Database. Basic Definitions Database: A collection of related data. Database Management System (DBMS): A software package/ system to facilitate the creation.
CG084&085 / / 1 The Relational Data Model Properties of Relations Keys and Constraints.
DatabaseIM ISU1 Fundamentals of Database Systems Chapter 5 The Relational Data Model.
Chapter 3 The Relational Model. 2 Chapter 3 - Objectives u Terminology of relational model. u How tables are used to represent data. u Connection between.
1 The Relational Database Model. 2 Learning Objectives Terminology of relational model. How tables are used to represent data. Connection between mathematical.
9/7/2012ISC329 Isabelle Bichindaritz1 The Relational Database Model.
Relational Data Model Ch. 7.1 – 7.3 John Ortiz Lecture 3Relational Data Model2 Why Study Relational Model?  Most widely used model.  Vendors: IBM,
1 Relational Databases and SQL. Learning Objectives Understand techniques to model complex accounting phenomena in an E-R diagram Develop E-R diagrams.
© Pearson Education Limited, Chapter 7 Entity-Relationship modeling Transparencies.
Entity-Relationship Modeling Based on Chapter 12.
1 Chapter 11 Entity-Relationship Modeling Transparencies Last Updated: 25 April 2011 By M. Arief
Chapter 12 Entity-Relationship Modeling Pearson Education © 2009.
The Relational Model Pertemuan 03 Matakuliah: M0564 /Pengantar Sistem Basis Data Tahun : 2008.
Relational Database. Database Management System (DBMS)
Slide Chapter 5 The Relational Data Model and Relational Database Constraints.
1 Entity-Relationship Model © Pearson Education Limited 1995, 2005.
The University of Akron Dept of Business Technology Computer Information Systems The Relational Model: Concepts 2440: 180 Database Concepts Instructor:
Databases Illuminated Chapter 3 The Entity Relationship Model.
12/2/2015CPSC , CPSC , Lecture 41 Relational Model.
CSE314 Database Systems Lecture 3 The Relational Data Model and Relational Database Constraints Doç. Dr. Mehmet Göktürk src: Elmasri & Navanthe 6E Pearson.
Relational Model E.F. Codd at IBM 1970 Chapter 3 (ed. 7 – Chap. 5)
1 Database Systems Entity Relationship (E-R) Modeling.
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,
Chapter 8 Entity-Relationship Modeling Pearson Education © 2009.
The Relational Model © Pearson Education Limited 1995, 2005 Bayu Adhi Tama, M.T.I.
CSCI 6315 Applied Database Systems Review for Midterm Exam I Xiang Lian The University of Texas Rio Grande Valley Edinburg, TX 78539
Chapter 3 The Relational Model. Objectives u Terminology of relational model. u How tables are used to represent data. u Connection between mathematical.
Chapter 4 The Relational Model Pearson Education © 2009.
1 The Relational Data Model David J. Stucki. Relational Model Concepts 2 Fundamental concept: the relation  The Relational Model represents an entire.
Database Designsemester Slide 1 Database Design Lecture 7 Entity-relationship modeling Text , 7.1.
ENTITY-RELATIONSHIP MODELLING. Objectives: How to use Entity–Relationship (ER) modelling in database design. Basic concepts associated with ER model.
Tables and Their Characteristics
Entity-Relationship Modeling
The Relational Database Model
Chapter 4 The Relational Model Pearson Education © 2009.
Chapter 4 The Relational Model Pearson Education © 2009.
Chapter 4+17 The Relational Model Pearson Education © 2014.
Chapter 4 The Relational Model Pearson Education © 2009.
Entity-Relationship Modeling
The Relational Model Transparencies
Chapter 4 The Relational Model Pearson Education © 2009.
Chapter 4 The Relational Model Pearson Education © 2009.
Chapter 4 The Relational Model Pearson Education © 2009.
Presentation transcript:

Lecture 9: Data Design CSC 470 Spring 2010

Entity Relationship Model Used to capture the conceptual design of a database It represents the logical structure of a database Three basic elements in an ER Model : Entity types Relationship types Attributes We use UML class notation for the ER model Only the first two sections are used

Entity Type Entity type Entity occurrence (or entity instance) Define a group of objects with same properties or attributes. Examples: EMPLOYEE, CUSTOMER, SUPPLIER entity types. Entity occurrence (or entity instance) Uniquely identifiable object of an entity type. Examples: Employee John Doe, Customer Mike Jordan, Supplier Office Depot. Entity set is the set of entity occurrences.

ER diagram of Staff and Branch entity types An entity type is displayed in a rectangular box.

Relationship Types Relationship type Relationship occurrence Define a set of meaningful associations among entity types. Examples: A Branch HAS some Staff, An Employee WORKS ON a Project. Relationship occurrence Uniquely identifiable association, which includes one occurrence from each participating entity type. Relationship set is the set of relationship occurrences (current state of a relationship).

Binary and ternary relationships

Relationship Types Recursive Relationship A relationship type where same entity type participates more than once in different roles.

Attributes Attribute Attribute Domain Composite Attribute Property of an entity or a relationship type. Attribute Domain Set of allowable values for one or more attributes. Simple Attribute (or single-valued Attribute) An entity has a single atomic value for the attribute. Example: Employee with SSN 123-45-6789 Composite Attribute Attribute composed of multiple components. Examples: Address, Name. It can be nested.

Attributes Multi-valued Attribute Derived Attribute Attribute that holds multiple values for each occurrence of an entity type. Example: Previous jobs for an employee. Identify them with a (*) after the attribute name Derived Attribute Attribute that represents a value that is derivable from value of a related attribute, or set of attributes, not necessarily in the same entity type. Example: Age derived from DOB and Today’s date. Precede the attribute name with a ‘/’ character

Keys Candidate Key Minimal set of attributes that uniquely identifies each occurrence of an entity type. Primary Key Candidate key selected to uniquely identify each occurrence of an entity type. Composite Key A candidate key that consists of two or more attributes.

ER diagram of Staff and Branch entities and their attributes

Relationship called Advertises with its own attributes

Structural Constraints Main type of constraint on relationships is called multiplicity. Indicate how many instances of an entity type are related to an instance of another entity type . Binary relationships are generally referred to as being: one-to-one (1:1) one-to-many (1:* or 1:M) many-to-many (*:* or M:N)

Multiplicity of Staff Manages Branch (1:1) relationship

Multiplicity of Staff Oversees PropertyForRent (1:*) relationship type

Multiplicity of Newspaper Advertises PropertyForRent (. : Multiplicity of Newspaper Advertises PropertyForRent (*:*) relationship M M M:M

Multiplicity of ternary Registers relationship 1 1 M A staff/branch value pair registers several clients

Example of a complete ER diagram Student Registration System SSCourse CourseCode Name CreditNum SSStudent StudentID Name Address * 1 part of * enrolls * SSFaculty SSSection FacultyID Name Address SectionNum ClassTime Room *1 teaches *

Database Shared collection of logically related data designed to meet the information needs of an organization. Data are known facts that can be recorded and have an implicit meaning. Database Management System (DBMS) A software system designed to store and manage databases easily and efficiently. Database Schema: The description of a database. Includes descriptions of the database structure, data types, and the constraints on the database.

Example of a database schema

Example of a database instance

The Relational Model Proposed by Dr. E. Codd in the early 70’s He worked at IBM Research Lab Model based on the notion of a relation (table) It has solid theoretical foundation Easy to understand, powerful query languages Most widely used model Vendors: IBM (DB2), Oracle (Oracle10g), Microsoft (SQL Server 2005), Sybase, Informix, etc.

Relational Model Terminology A relation is a mathematical concept based on the ideas of sets. Informally, it is a table (relation) with columns (attributes) and rows (tuples). A relation has a schema. Denoted by R(A1, A2, …, An) R is the name of the relation, Ai’s are its attributes A relational database schema is the set of relation schemas, each with a distinct name that belongs to the same database.

Mathematical definition of a relation The Cartesian product of n sets (D1, D2, . . ., Dn) is: D1 ´ D2 ´ . . . ´ Dn = {<d1, d2, . . . , dn> | d1 ÎD1, d2 ÎD2, . . . , dnÎDn} Any set of n-tuples from this Cartesian product is a relation instance on the n sets. Consider two sets, D1 & D2, where D1 = {2, 4} and D2 = {1, 3, 5}. R = {<2, 1>, <4, 1>} is a relation.

Mathematical definition of a relation The Cartesian product of n sets (D1, D2, . . ., Dn) is: D1 ´ D2 ´ . . . ´ Dn = {<d1, d2, . . . , dn> | d1 ÎD1, d2 ÎD2, . . . , dnÎDn} Any set of n-tuples from this Cartesian product is a relation instance on the n sets. Consider two sets, D1 & D2, where D1 = {2, 4} and D2 = {1, 3, 5}. R = {<2, 1>, <4, 1>} is a relation.

Characteristics of a relation Rows contain data about an entity. Columns contain data about attributes of the entity. All entries in a column are of the same kind. Each column has a unique name. Cells of a table hold a single value. The order of the columns in unimportant. The order of the rows is unimportant. Each row is distinct. There are no duplicate rows. A special NULL values represent unknown values.

Relational Keys Superkey (SK) Candidate Key (CK) An attribute, or a set of attributes (composite key), that uniquely identifies a tuple within a relation. Candidate Key (CK) Superkey (K) such that no proper subset is a superkey within the relation. In each tuple of R, values of K uniquely identify that tuple (uniqueness). No proper subset of K has the uniqueness property (irreducibility).

Relational Keys Primary Key (PK) Foreign Key (FK) Candidate key selected to identify tuples uniquely within relation. Primary keys are underlined in a relational DB schema. Foreign Key (FK) Attribute, or set of attributes, within one relation that matches candidate key of some (possibly same) relation. Displayed as a direct arc from foreign key to referenced table (or its primary key). Surrogate Key (SuK: used as a primary key) A unique attribute introduced in the relation which is not a property of a relation.

Example of COMPANY Database Schema

Relational Integrity Constraints Integrity constraints (IC) Conditions that must be true for any instance of the database. Defined during creation of the database. Checked when relations are modified. Null Represents value for an attribute that is currently unknown or not applicable for a tuple. Deals with incomplete or exceptional data. Represents the absence of a value and is not the same as zero or spaces, which are values.

Mapping ERD to RDB Schema Map each entity to a DB relation Map each binary M:M relationship to a DB relation New relation includes the PK of each related entity These PKs act as FKs to the “parent” relations PK of new relation are usually these two FKs Map each binary 1:M relationship Copy the PK of the “1-side” entity (“parent”) into the “M-side” entity (“child”) of the relationship (acting as FK) Copy the PK of one of the entities into the entity (“child”) that participate the most in the relationship

Mapping ERD to RDB Schema (cont.) Map more complex relationships to a DB relation New relation includes the PK of each related entity These PKs becomes FK in the new relations Relationships with their own attributes Place them in the new relation or in the “child” relation Mapping multivalued attributes (MVAs) For each MVA, create a new DB relation Place a copy of the PK of the owner entity into the new relation (acting as a FK) Place the MVA in the new relation PK of the new relation are these two attributes

Mapping Example: ERD worksAt schedAt reserves applies

Mapping result: RDB schema Student(studID, studName, studPhone, studEmail, studURL, major, minor, gpa) Company(compID, compName, compURL) LaborDeptPosition(posID, title, description) TimeBlock(blockID, date, startTime, endTime) Opening(openID, salary, tentStartDate, specificDesc, posID, compID) FK: posID references LaborDeptPosition(posID) FK: compID references Company(compID) CityOpening(openID, city, state) // implement the multivalued attribute city in the Opening entity FK: openID references Opening(openID) Reservation(blockID, compID, room, building) // implements the M:M relationship called reserves FK: blockID references TimeBlock(blockID) Interviewer(empID, empName, empPhone, empEmail, dateHired, compID) Interview(intviewID, blockID, time, room, building, empID) FK: empID references Interviewer(empID) Application(studID, intviewID, openID, applDate) // implements the complex relationship called applies FK: studID references Student(studID) FK: intviewID references Interview(intviewID)