e e Conceptual design begins with the collection of requirements and results needed from the database (ER Diag.)

Similar documents
The Relational Model

Introduction to Data Management. Lecture #4 (E-R Relational Translation)

The Relational Model of Data (ii)

Entity-Relationship Model. Purpose of E/R Model

The Relational Model. Relational Data Model Relational Query Language (DDL + DML) Integrity Constraints (IC)

Relational data model

Introduction to Data Management. Lecture #4 (E-R à Relational Design)

The Relational Model. Chapter 3

Entity-Relationship Model

The Relational Model. Chapter 3. Database Management Systems, R. Ramakrishnan and J. Gehrke 1

CS54100: Database Systems

Introduction to Data Management. Lecture #5 Relational Model (Cont.) & E-Rà Relational Mapping

From E/R Diagrams to Relations

The Relational Data Model. Data Model

Database Applications (15-415)

Data Modeling. Yanlei Diao UMass Amherst. Slides Courtesy of R. Ramakrishnan and J. Gehrke

Phases of Database Design

Database Systems ( 資料庫系統 )

The Relational Model. Chapter 3. Comp 521 Files and Databases Fall

The Relational Model. Why Study the Relational Model? Relational Database: Definitions

CS 405G: Introduction to Database Systems. Database Design II

Database Management Systems. Chapter 3 Part 1

Database Systems. Course Administration

Design Techniques. 1. Avoid redundancy 2. Limit the use of weak entity sets 3. Don t use an entity set when an attribute will do

Comp 5311 Database Management Systems. 4b. Structured Query Language 3

Database Systems. Lecture2:E-R model. Juan Huo( 霍娟 )

KEYS WEAK ENTITY SETS EXAMPLE: WEAK ENTITY SET EXAMPLE: WEAK ENTITY SET. Beers. Ales. Players. Teams ISA. and. Plays-on

Why Study the Relational Model? The Relational Model. Relational Database: Definitions. The SQL Query Language. Relational Query Languages

The Relational Model. Week 2

The Relational Model. Chapter 3. Comp 521 Files and Databases Fall

Relational Database Design Part I. Announcement. Relational model: review. CPS 116 Introduction to Database Systems

CS 2451 Database Systems: Relational Data Model

CS 317/387. A Relation is a Table. Schemas. Towards SQL - Relational Algebra. name manf Winterbrew Pete s Bud Lite Anheuser-Busch Beers

Lecture 2 SQL. Announcements. Recap: Lecture 1. Today s topic. Semi-structured Data and XML. XML: an overview 8/30/17. Instructor: Sudeepa Roy

The Relational Model 2. Week 3

Chapter 6 The database Language SQL as a tutorial

ER Model. CSC 343 Winter 2018 MICHAEL LIUT

Announcement. Relational Database Design Part I. Keys. Relational model: review. Schema vs. data. More examples of keys

BİL 354 Veritabanı Sistemleri. Relational Model (İlişkisel Veri Modeli)

The Basic (Flat) Relational Model. Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Relational Database Design Part I. Announcements (September 5) Relational model: review. CPS 116 Introduction to Database Systems

CS425 Midterm Exam Summer C 2012

DBMS. Relational Model. Module Title?

The Relational Model

Introduction to Data Management. Lecture #3 (E-R Design, Cont d.)

Relational Model. Topics. Relational Model. Why Study the Relational Model? Linda Wu (CMPT )

CompSci 516 Database Systems. Lecture 2 SQL. Instructor: Sudeepa Roy

Relational Databases BORROWED WITH MINOR ADAPTATION FROM PROF. CHRISTOS FALOUTSOS, CMU /615

Translation of ER-diagram into Relational Schema. Dr. Sunnie S. Chung CIS430/530

Lecture 2 SQL. Instructor: Sudeepa Roy. CompSci 516: Data Intensive Computing Systems

CIS 330: Applied Database Systems

Relational Model. Lecture #6 Autumn, Fall, 2001, LRX

E/R Diagrams! Converting E/R Diagrams to Relations!

Let s briefly review important EER inheritance concepts

Databases Model the Real World. The Entity- Relationship Model. Conceptual Design. Steps in Database Design. ER Model Basics. ER Model Basics (Contd.

The Relational Model

The Relational Model. Outline. Why Study the Relational Model? Faloutsos SCS object-relational model

Relational Query Languages

Review. The Relational Model. Glossary. Review. Data Models. Why Study the Relational Model? Why use a DBMS? OS provides RAM and disk

Chapter 6 The database Language SQL as a tutorial

The Relational Model. Database Management Systems

01/01/2017. Chapter 5: The Relational Data Model and Relational Database Constraints: Outline. Chapter 5: Relational Database Constraints

Chapter 2 The relational Model of data. Relational model introduction

Introduction to Data Management. Lecture #4 E-R Model, Still Going

Introduction to SQL. Multirelation Queries Subqueries. Slides are reused by the approval of Jeffrey Ullman s

Announcements If you are enrolled to the class, but have not received the from Piazza, please send me an . Recap: Lecture 1.

A database consists of several tables (relations) AccountNum

Administrivia. The Relational Model. Review. Review. Review. Some useful terms

CS 377 Database Systems

The Relational Model. Roadmap. Relational Database: Definitions. Why Study the Relational Model? Relational database: a set of relations

SQL Continued! Outerjoins, Aggregations, Grouping, Data Modification

Translation of ER-diagram into Relational Schema. Dr. Sunnie S. Chung CIS430/530

Databases Model the Real World. The Entity- Relationship Model. Conceptual Design. Steps in Database Design. ER Model Basics. ER Model Basics (Contd.

Introduction to SQL. Select-From-Where Statements Multirelation Queries Subqueries. Slides are reused by the approval of Jeffrey Ullman s

Chapter 5. Relational Model Concepts 5/2/2008. Chapter Outline. Relational Database Constraints

CSCI3030U Database Models

SQL: Part III. Announcements. Constraints. CPS 216 Advanced Database Systems

Chapter 5. Relational Model Concepts 9/4/2012. Chapter Outline. The Relational Data Model and Relational Database Constraints

More SQL. Extended Relational Algebra Outerjoins, Grouping/Aggregation Insert/Delete/Update

EXTENDED RELATIONAL ALGEBRA OUTERJOINS, GROUPING/AGGREGATION INSERT/DELETE/UPDATE

CSE 132A Database Systems Principles

The Relational Data Model and Relational Database Constraints

EGCI 321: Database Systems. Dr. Tanasanee Phienthrakul

Introduction to SQL SELECT-FROM-WHERE STATEMENTS SUBQUERIES DATABASE SYSTEMS AND CONCEPTS, CSCI 3030U, UOIT, COURSE INSTRUCTOR: JAREK SZLICHTA

Introduction to SQL. Select-From-Where Statements Multirelation Queries Subqueries

Chapter 5. The Relational Data Model and Relational Database Constraints. Slide 5-١. Copyright 2007 Ramez Elmasri and Shamkant B.

Copyright 2007 Ramez Elmasri and Shamkant B. Navathe. Slide 5-1

CS275 Intro to Databases

CS145 Introduction. About CS145 Relational Model, Schemas, SQL Semistructured Model, XML

Relational Model & Algebra. Announcements (Thu. Aug. 27) Relational data model. CPS 116 Introduction to Database Systems

SQL: Part II. Announcements (September 18) Incomplete information. CPS 116 Introduction to Database Systems. Homework #1 due today (11:59pm)

Databases-1 Lecture-01. Introduction, Relational Algebra

SQL DATA DEFINITION LANGUAGE

CS 405G: Introduction to Database Systems

Copyright 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide 5-1

SQL DATA DEFINITION LANGUAGE

SQL DATA DEFINITION LANGUAGE

CSC 742 Database Management Systems

Announcements (September 18) SQL: Part II. Solution 1. Incomplete information. Solution 3? Solution 2. Homework #1 due today (11:59pm)

Conceptual Design with ER Model

Transcription:

Instructor: Jinze Liu Fall 2008

Phases of Database Design Data Requirements e e Conceptual design begins with the collection of requirements and results needed from the database (ER Diag.) Conceptual Design Logical schema is a description of the Conceptual Schema structure of the database (Relational, Logical Network, etc.) Design Physical schema is a description of Logical Schema the implementation (programs, tables, dictionaries, catalogs Specification of requirements and results Physical Design Physical Schema 2

A data model is a collection of objects that can be used to represent a set of data and operations to manipulate the data Conceptual models dl are tools for representing reality at a very high level of abstraction Logical models are data descriptions that can be processed by computers 3

Entities represent classes of real world objects. Person, Students, Projects, Courses are entities of a University database Relationships represent interactions between two or more entities N 1 Lives_In Person City Is_Born_In In N 1 4

Every employee works in at least one project Every project has employees working on it. EMPLOYEE SSN Name Salary N WORKS_ONON N PROJECT Name Code 5

A relationship may involve more than two entities Course Meets Classroom Day 6

Relationships could be mapped from one entity to itself Manager_Of 1 Employee Manages N Subordinate_To 7

Attributes represent elementary properties of the entities or relationships. The stored data will be kept as values of the attributes Lives_In N 1 PERSON Ssn Name Profession Moving_Date Birth_Date CITY Name Country Elevation Population Is_Born_In N 1 8

An entity could ldbe seen from many different viewpoints i Each viewpoint defines a set of roles in a generalization Example below uses SEX to classify the object Person PERSON Ssn Name Address MAN Draft_Status FEMALE Maiden_Name 9

A classification could be disjoint or overlapping An entity could have more than one classification PERSON Ssn Name Address SEX JOB MAN Draft_Status FEMALE Maiden_Name Full_Time Annual_Salary Department Part_Time Hour_Rate Weekly_Hours 10

name population county_namename Cities In States name capital county_area County area information i is repeated for every city in the county Redundancy is bad. What else? State capital should really be a city Should reference entities ii through h explicit i relationships 9/5/2008 11

name population Cities In IsCapitalOf name area Counties In States name Technically, nothing in this design could prevent a city in state X from being the capital of another state Y, but oh well 9/5/2008 12

Attributes (column headers) Tuples (rows) name manf Winterbrew Pete s Bud Lite Beers Anheuser Busch 13

Relation schema = relation name + attributes, in order (+ types of attributes). Example: Beers(name, manf) or Beers(name: string, manf: string) Database = collection of relations. Database schema = set of all relation schemas in the database. 14

Very simple model. Often matches how we think about data. Abstract model that underlies SQL, the most important database language today. But SQL uses bags, while the relational model is a setbased model. 15

Entity sets become relations with the same set of attributes. Relationships become relations whose attributes are only: The keys of the connected entity sets. Attributes of the relationship itself. 16

name manf Beers Relation: Beers(name, manf) 17

name addr name manf husband Drinkers 1 2 Likes Beers Buddies Married Favorite wife Likes(drinker, beer) Favorite(drinker, beer) Buddies(name1, name2) Married(husband, wife) 18

It is OK to combine the relation for an entity set E with the relation R for a many one relationship from E to another entity set. Example: Drinkers(name, addr) and Favorite(drinker, i beer) combine to make Drinker1(name, addr, favbeer). 19

Combining Drinkers with Likes would be a mistake. It leads to redundancy, as: name addr beer Sally 123 Maple Bud Sally 123 Maple Miller Redundancy 20

Relation for a weak entity set must include attributes for its complete key (including those belonging to other entity sets), as well as its own, nonkey attributes. A supporting (double diamond) di d) relationship is redundant and yields no relation. 21

name name time Logins At Hosts Hosts(hostName) Logins(loginName, hostname, time) At(loginName, hostname, hostname2) At becomes part of Logins Must be the same 22

A database is a collection o of relations (or tables) Each relation is identified by a name and a list of attributes (or columns) Each attribute has a name and a domain (or type) Set valued attributes not allowed 9/5/2008 23

Schema (metadata) Specification of how data is to be structured logically Defined at set up Rarely changes Instance Content Changes rapidly, but always conforms to the schema Compare to type and objects of type in a programming language 9/5/2008 24

Schema Student (SID integer, name string, age integer, GPA float) Course (CID string, title il string) Enroll (SID integer, CID integer) Instance { h142, Bart, 10, 2.3i, h123, Milhouse, 10, 3.1i,...} { hcps116, Intro. to Database Systemsi,...} { h142, CPS116i, h142, CPS114i,...} 9/5/2008 25

Constraints ts are aeconditions o that must hold odon all valid relation instances. There are four main types of constraints: 1. Domain constraints 1. The value of a attribute must come from its domain 2. Key constraints 3. Entity integrity constraints 4. Referential integrity constraints 9/5/2008 26

A set of fields is a candidate key for a relation if : 1. No two distinct tuples can have same values in all key fields, and 2. This is not true for any subset of the key. Part 2 false? A superkey. If there s >1 key for a relation, one of the keys is chosen (by DBA) to be the primary key. E.g., given a schema Student(sid: string, name: string, gpa: float) we have: sid is a key for Students. (What about name?) The set {sid, gpa} is a superkey. 9/5/2008 Jinze Liu @ University of Kentucky 27

CAR (licence ce_ num: :string, Engine e_serial _ num: :string, make: string, model: string, year: integer) What is the candidate key(s) Which one you may use as a primary key What are the super keys 9/5/2008 28

Entity Integrity: The primary key attributes PK of each relation schema R in S cannot have null values in any tuple of r(r). Other attributes of R may be similarly constrained to disallow null values, even though they are not members of the primary key. 9/5/2008 29

Foreign key : Set of fields in one relation that is used to `refer to a tuple in another relation. (Must correspond to primary key of the second relation.) Like a `logical l pointer. E.g. sid is a foreign key referring to Students: Student(sid: string, name: string, gpa: float) Enrolled(sid: string, cid: string, grade: string) If all foreign key constraints are enforced, referential integrity is achieved, i.e., no dangling references. Can you name a data model w/o referential integrity? Links in HTML! 9/5/2008 Jinze Liu @ University of Kentucky 30

Only students listed in the Students relation should be allowed to enroll for courses. Enrolled sid cid grade 53666 Carnatic101 C 53666 Reggae203 B 53650 Topology112 A 53666 History105 B Students sid name login age gpa 53666 Jones jones@cs 18 3.4 53688 Smith smith@eecs 18 32 3.2 53650 Smith smith@math 19 3.8 Or, use NULL as the value for the foreign key in the referencing tuple when the referenced tuple does not exist 9/5/2008 Jinze Liu @ University of Kentucky 31

Semantic Integrity Constraints: based on application semantics and cannot be expressed by the model per se eg e.g., the max. no. of hours per employee for all projects he or she works on is 56 hrs per week A constraint specification language may have to be used to express these SQL 99 allows triggers and ASSERTIONS to allow for some of these 9/5/2008 32