CS 146 Database Systems

Similar documents
CS 2451 Database Systems: Entity-Relationship (ER) Model Algebra

Database Design Using E/R Model

The Entity-Relationship Model

Contents. Database. Information Policy. C03. Entity Relationship Model WKU-IP-C03 Database / Entity Relationship Model

1/24/2012. Chapter 7 Outline. Chapter 7 Outline (cont d.) CS 440: Database Management Systems

MIS Database Systems Entity-Relationship Model.

CSE 530A. ER Model. Washington University Fall 2013

Database Applications (15-415)

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

LAB 2 Notes. Conceptual Design ER. Logical DB Design (relational) Schema Refinement. Physical DD

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

Overview of db design Requirement analysis Data to be stored Applications to be built Operations (most frequent) subject to performance requirement

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

CS 4604: Introduction to Database Management Systems. B. Aditya Prakash Lecture #5: Entity/Relational Models---Part 1

The Entity-Relationship Model. Overview of Database Design. ER Model Basics. (Ramakrishnan&Gehrke, Chapter 2)

The Entity-Relationship Model. Overview of Database Design

CS 405G: Introduction to Database Systems

The Entity-Relationship Model

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

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

The Entity-Relationship Model

OVERVIEW OF DATABASE DEVELOPMENT

Review The Big Picture

Administrivia. CS 235: Introduction to Databases. Examples. What is a DBMS? The DBMS Marketplace. Relational Model

Database Applications (15-415)

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

SYLLABUS ADMIN DATABASE SYSTEMS I WEEK 2 THE ENTITY-RELATIONSHIP MODEL. Assignment #2 changed. A2Q1 moved to A3Q1

CIS 330: Web-driven Web Applications. Lecture 2: Introduction to ER Modeling

The Entity-Relationship Model. Steps in Database Design

ER Model Overview. The Entity-Relationship Model. Database Design Process. ER Model Basics

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

The Relational Model. Chapter 3

Conceptual Data Modeling

Conceptual Design with ER Model

VARDHAMAN COLLEGE OF ENGINEERING Shamshabad , Hyderabad B.Tech. CSE IV Semester (VCE - R11) T P C 3+1* -- 4 (A1511) DATABASE MANAGEMENT SYSTEMS

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

Conceptual Data Modeling and the Entity- Relationship Model. Department of Computer Science Northern Illinois University September 2014

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

COMP Instructor: Dimitris Papadias WWW page:

Conceptual Design. The Entity-Relationship (ER) Model

Database Applications (15-415)

Introduction to Database Design

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

Copyright 2016 Ramez Elmasr and Shamkant B. Navathei

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

Chapter 4. In this chapter, you will learn:

Introduction to Data Management. Lecture #2 (Big Picture, Cont.) Instructor: Chen Li

Entity-Relationship Diagrams

Chapter Outline. Note 1. Overview of Database Design Process Example Database Application (COMPANY) ER Model Concepts

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

Introduction to Data Management. Lecture #2 (Big Picture, Cont.)

High Level Database Models

Introduction to Database Design. Dr. Kanda Runapongsa Dept of Computer Engineering Khon Kaen University

Conceptual Design. The Entity-Relationship (ER) Model

Lecture3: Data Modeling Using the Entity-Relationship Model.

EECS 647: Introduction to Database Systems

Introduction to Data Management. Lecture #3 (Conceptual DB Design) Instructor: Chen Li

Entity Relationship Data Model. Slides by: Shree Jaswal

SQL DDL. CS3 Database Systems Weeks 4-5 SQL DDL Database design. Key Constraints. Inclusion Constraints


The Entity-Relationship (ER) Model

The Entity-Relationship (ER) Model 2

Overview of Database Design Process Example Database Application (COMPANY) ER Model Concepts

CIS 330: Applied Database Systems

CS54100: Database Systems

LECTURE 3: ENTITY-RELATIONSHIP MODELING

Database Management Systems. Chapter 2 Part 2

CMPT 354 Database Systems I

Database Systems ER Model. A.R. Hurson 323 CS Building

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

THE ENTITY- RELATIONSHIP (ER) MODEL CHAPTER 7 (6/E) CHAPTER 3 (5/E)

Using High-Level Conceptual Data Models for Database Design A Sample Database Application Entity Types, Entity Sets, Attributes, and Keys

ENTITY-RELATIONSHIP MODEL. CS 564- Spring 2018

CS/INFO 330 Entity-Relationship Modeling. Announcements. Goals of This Lecture. Mirek Riedewald

Entity Relationship Modelling

Database Management Systems MIT Introduction By S. Sabraz Nawaz

CSCC43H: Introduction to Databases

CIS 330: Applied Database Systems. ER to Relational Relational Algebra

CS 2451 Database Systems: Relational Data Model

The Entity-Relationship Model (ER Model) - Part 2

Part 5: Introduction to Logical Design

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

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

Database Design CENG 351

2. DatabaseDesign. Master I Software Engineering. Dr. Imed Bouchrika Dept of Mathematics & Computer Science University of Souk-Ahras

A l Ain University Of Science and Technology

Conceptual Modeling in ER and UML

Data Analysis 1. Chapter 2.1 V3.1. Napier University Dr Gordon Russell

Conceptual Database Design. COSC 304 Introduction to Database Systems. Entity-Relationship Modeling. Entity-Relationship Modeling

Score. 1 (10) 2 (10) 3 (8) 4 (13) 5 (9) Total (50)

Relational Database Systems Part 01. Karine Reis Ferreira

Administrivia. Carnegie Mellon Univ. Dept. of Computer Science /615 - DB Applications. Course Topics. Problem

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

Overview of Database Design Process. Data Modeling Using the Entity- Relationship (ER) Model. Two main activities:

CONCEPTUAL DESIGN: ER TO RELATIONAL TO SQL

II. Data Models. Importance of Data Models. Entity Set (and its attributes) Data Modeling and Data Models. Data Model Basic Building Blocks

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

Entity-Relationship Modelling. Entities Attributes Relationships Mapping Cardinality Keys Reduction of an E-R Diagram to Tables

Carnegie Mellon Univ. Dept. of Computer Science /615 - DB Applications. Problem. Faloutsos - Pavlo CMU SCS /615

System Concepts and Architecture. Rose-Hulman Institute of Technology Curt Clifton

Transcription:

DBMS CS 146 Database Systems Entity-Relationship (ER) Model CS 146 1 CS 146 2 A little history Progression of Database Systems In DBMS: single instance of data maintained and accessed by different users File Processing: Earliest form of information storage systems each user keeps files needed for specific application one user keeps track of students fees and payments second user keeps files on student grades Early 1950 s- file proc, IBM s Ramac system 1960 s: first generalized DBMS IBM Sabre 1970 s: Relational model proposed, INGRES, System R, Query languages- Sequel(SQL),QUEL 1980 s: DBMS for PCs, commercial RDBMS- Oracle, Sybase, Informix 1990s: Object-relational DBMS, Multimedia, Spatial/GIS, Data Mining/OLAP, Dist.DB CS 146 3 CS 146 4

Part 1: Schedule Start with Data Models Relational Model with a little ER model intro Formal query languages- Relational algebra SQL Database schema design: how to design a good schema, how to measure good? Normal Forms (3NF, BCNF) Demonstrate concepts learnt on Commercial DBMS Oracle, MySQL How Does One Build a Database? Requirements Analysis: what data, apps, critical operations Get from client Typically expressed in some natural language May require going back to the client for resolving questions CS 146 5 CS 146 6 Building a Database and Application 1. Start with a conceptual model On paper using certain techniques E-R Model ignore low-level details focus on logical representation step-wise refinement of design with client input 2. Design & implement schema Design and codify (in SQL) the relations/tables Refine the schema normalization Do physical layout indexes, etc. 3. Import the data 4. Write applications using DBMS and other tools Many of the hard problems are taken care of by other people (DBMS, API writers, library authors, web server, etc.) DBMS takes care of Query Optimization, Efficiency, etc. Conceptual Model: Why use a graphical language? Convey database design and properties in simple but precise manner Interpreted by any type of user Does not need to know anything about CS Capture the business rules of the application Picture is worth a thousand words CS 146 7 CS 146 8

An Example: mini banner Entity Relationship Model Database containing information about Students Faculty Courses Students take courses Faculty teach courses How to define student/faculty/course? Based on collection of real world objects or concept called entities; ex: employee, student attribute represents properties of entity; s.s.num relationship represents interaction between entities overall logical structure represented by ER diagram representing entity sets, relationships, attributes CS 146 9 CS 146 10 ER Model Basics ER Model Definitions Conceptual design: What are the entities and relationships in the enterprise? What information about these entities and relationships should we store in the database? What are the integrity constraints or business rules that hold? Can map an ER diagram into a relational schema. CS 146 11 Entity: Real-world object distinguishable from other objects. An entity is described (in DB) using a set of attributes. Entity Set: A collection of similar entities. E.g., all employees. All entities in an entity set have the same set of attributes. (Until we consider ISA hierarchies, anyway!) Each entity set has a key. Each attribute has a domain. Representation/Syntax: Entity set represented by rectangle Attribute represented by Oval Key attribute underlined CS 146 12

ER Model Basics (Contd.) Conceptual Design Process Relationship: Association among two or more entities. E.g., Dan takes Database Course; Attishoo works in Pharmacy department. Relationship can also have attributes (that appear only for this relationship set) Representation/Syntax: a Diamond symbol Attributes represented by Oval (same as before) Relationship Set: Collection of similar relationships. An n-ary relationship set R relates n entity sets E1... En; each relationship in R involves entities e1 E1,..., en En Same entity set could participate in different relationship sets, or in different roles in same set. STUDENTS What are the entities being represented? Takes What are the relationships? What info (attributes) do we store about each? exp-grade What keys & integrity constraints do we have? sid CS 146 13 CS 146 14 Student Entity Connectivity in the E-R Diagram? sid Attributes can only be connected to entities or relationships Entities can only be connected via relationships As for the edges, let s consider kinds of relationships and integrity constraints Student PROFESSORS Teaches COURSES (warning: the book has a slightly different notation here!) CS 146 15 CS 146 16

Entity-Relationship Diagram for the Example Underlined attributes are keys fid PROFESSORS entity set relationship set Teaches semester STUDENTS Takes COURSES sid exp-grade serno subj cid attributes (recall these have domains) CS 146 17 Example: A Company Database COMPANY database keeps track of Employees and Departments Employees identified by SSN, Name, Location Department specified bydepartment ID (did), Name, Budget Each department has a unique manager Database must keep track of starting date Each employee works in a department Database must keep track of starting date CS 146 18 Constraints Key and Participation Capture properties of the relationship and entities Every entity set has a key attribute No two elements can have the same value on this attribute Example: Student ID Does every element in the entity set appear/participate in the relationship? Must every student take a course? Define constraints based on properties of the mapping/relation between entity sets Properties of relations Binary relationships can be classified as oneto-one, many-to-one, one-to-many, many-tomany What is the type of mapping/relation 1-to-1 1-to Many Many-to-1 Many-to-Many CS 146 19 CS 146 20

Example: the Teaches relationship Takes Relationship Want to model the info that each course is taught by one faculty. Type of mapping??? 1-to-1 Note: This is a Mapping and not a function! Every course must have an instructor Each element in the Course entity set must participate/appear in the Teaches relationship A faculty may teach zero or more courses Student can be enrolled in many courses and each Course can have many students Type of mapping: Many to Many Want to model the condition that every student must take at least one course Each student must appear in Takes relationship How many courses can a student take? How many students must be enrolled in a course? CS 146 21 CS 146 22 Mapping Cardinality, Participation Constraints, Structural constraints Type of mapping (cardinality) 1-1, 1-many, many-many, many-1 Provides some information on relationship sets Participation constraints Total vs Partial Total: Every student sid must appear in Takes relationship Partial: All faculty need not appear in Teaches relationship Structural constraints: Minimum and maximum times they can appear in relationship Syntax?? Roles: Labeled Edges Sometimes a relationship connects the same entity, and the entity has more than one role: Student TA Student TA (Nate, Darby) course This often indicates the need for recursive queries id CS 146 23 CS 146 24

id Roles vs. Separate Entities Husband What is the difference between these two representations? Married Husband Married Person Wife Wife id id Weak Entity Sets A weak entity can be identified uniquely only by considering the primary key of another (owner) entity. Owner entity set and weak entity set must participate in a one-to-many relationship set (one owner, many weak entities). Weak entity set must have total participation in this identifying relationship set. If Student is deleted, then we MUST delete the Parent Syntax: Bold face rectangles, Double lined rectangles, CS 146 25 CS 146 26 ISA Relationships: Subclasses (Structurally) Inheritance states that one entity is a special kind of another entity: subclass should be member of base class id People Relationships: Binary or n-ary Binary: Relationship between two entity sets N-ary: Relationship between any N entity sets Not all n-ary can be converted to a set of binary relationships ISA Employees salary CS 146 27 CS 146 28

Conceptual Design Using the ER Model Design choices: Should a concept be modeled as an entity or an attribute? Should a concept be modeled as an entity or a relationship? Identifying relationships: constraints, type, participation Constraints in the ER Model: A lot of data semantics can (and should) be captured. But some constraints cannot be captured in ER diagrams. Summary of Conceptual Design Conceptual design follows requirements analysis, Yields a high-level description of data to be stored Visual language the diagram is the syntax! ER model popular for conceptual design Constructs are expressive, close to the way people think about their applications. There are additional constructs in a real ER model based tools. Can automate mapping of ER model to relational tables! CS 146 29 CS 146 30