Database Design. Overview

Similar documents
Chapter 6: Entity-Relationship Model. The Next Step: Designing DB Schema. Identifying Entities and their Attributes. The E-R Model.

The Next Step: Designing DB Schema. Chapter 6: Entity-Relationship Model. The E-R Model. Identifying Entities and their Attributes.

Consistency The DBMS must ensure the database will always be in a consistent state. Whenever data is modified, the database will change from one

ENTITY-RELATIONSHIP MODEL. CS 564- Spring 2018

Chapter 6: Entity-Relationship Model

2. E/R Design Considerations

Database Foundations. 2-3 Conceptual Data Modeling. Copyright 2015, Oracle and/or its affiliates. All rights reserved.

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

Chapter 6: Entity-Relationship Model

Conceptual Data Modeling

Chapter 7: Entity-Relationship Model

CS 146 Database Systems

Chapter 7: Entity-Relationship Model

Weak Entity Sets. A weak entity is an entity that cannot exist in a database unless another type of entity also exists in that database.

A practical introduction to database design

Chapter 7: Entity-Relationship Model

Database Principles: Fundamentals of Design, Implementation, and Management Tenth Edition. Chapter 7 Data Modeling with Entity Relationship Diagrams

MySQL. A practical introduction to database design

CS 405G: Introduction to Database Systems

Databases Tutorial. January 19,2012 Jing Chen Mcmaster University

L12: ER modeling 5. CS3200 Database design (sp18 s2) 2/22/2018

MIS2502: Data Analytics Relational Data Modeling. Jing Gong

Roadmap of This Lecture. Weak Entity Sets Extended E-R Features Reduction to Relation Schemas Database Design UML*

Working with Databases and Java

Unit I. By Prof.Sushila Aghav MIT

QUETZALANDIA.COM. 5. Data Manipulation Language

EECS 647: Introduction to Database Systems

MIS2502: Data Analytics Relational Data Modeling - 1. JaeHwuen Jung

The Relational Data Model. Data Models. Relational vs Semistructured. Structure Operations - Constraints

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

MIS2502: Data Analytics Relational Data Modeling. Jing Gong

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

CSC 453 Database Technologies. Tanu Malik DePaul University

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

CS54100: Database Systems

File Processing Approaches

Module 2 : Entity-Relationship Model 15

Chapter 7: Entity-Relationship Model

SWEN-220 Mathematical Models of Software. Conceptual to Relational Mapping

Information Technology Audit & Cyber Security

COMP Instructor: Dimitris Papadias WWW page:

Designing Tables for an Oracle Database System. From theory to practice

Chapter 2 ENTITY RELATIONSHIP MODEL

L11: ER modeling 4. CS3200 Database design (sp18 s2) 2/15/2018

Chapter 6: Entity-Relationship Model. E-R Diagrams

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

Database Design and Administration for OnBase WorkView Solutions. Mike Martel Senior Project Manager

Chapter 2: Entity-Relationship Model

Database Management Systems

The Relational Model Constraints and SQL DDL

SECTION 1 DBMS LAB 1.0 INTRODUCTION 1.1 OBJECTIVES 1.2 INTRODUCTION TO MS-ACCESS. Structure Page No.

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

Brief History of SQL. Relational Database Management System. Popular Databases

CSE 154 LECTURE 14: MULTI-TABLE SQL QUERIES (JOINS )

CMPT 354 Database Systems I

Database Management System (15ECSC208) UNIT I: Chapter 2: Relational Data Model and Relational Algebra

Part 5: Introduction to Logical Design

CS 327E Lecture 10. Shirley Cohen. February 29, 2016

2. E-R Model. Entity Sets Relationship Sets Attributes

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

Intro to DB CHAPTER 6

UNIT II A. ENTITY RELATIONSHIP MODEL

Homework Assignment 3. November 9th, 2017 Due on November 23th, 11:59pm (midnight) CS425 - Database Organization Results

Chapter 6: Entity-Relationship Model

CSC 337. Multi-table SQL Queries (Joins) Rick Mercer, Marty Stepp

Informatics 1: Data & Analysis

Create a simple database with MySQL

Relational Database Design (II)

CS403- Database Management Systems Solved MCQS From Midterm Papers. CS403- Database Management Systems MIDTERM EXAMINATION - Spring 2010

OO Design2. Design Artifacts

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

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

Task: Design an ER diagram for that problem. Specify key attributes of each entity type.

Unit1: Introduction. Database System Concepts, 6 th Ed. Silberschatz, Korth and Sudarshan See for conditions on re-use

Project 1. Yuji Shimojo CMIS 320. Instructor: Denton Guy-Williams

CS403- Database Management Systems Solved Objective Midterm Papers For Preparation of Midterm Exam

CSIT5300: Advanced Database Systems

QUIZ 1 REVIEW SESSION DATABASE MANAGEMENT SYSTEMS

ACS-3902 Fall Ron McFadyen 3D21 Slides are based on chapter 5 (7 th edition) (chapter 3 in 6 th edition)

Database Design. Goal: specification of database schema Methodology:

Database Applications (15-415)

Introduction to Databases

CSE 135. Applications View of a Relational Database Management System (RDBMS) SQL. Persistent data structure. High-level API for access &modification

Lecture 3: SQL Part II

FUNCTIONAL DEPENDENCIES

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

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

Relational Model. Courses B0B36DBS, A7B36DBS: Database Systems. Practical Class 03: Martin Svoboda

Lecture4: Guidelines for good relational design Mapping ERD to Relation. Ref. Chapter3

ER Modeling ER Diagram ID-Dependent and Weak Entities Pg 1

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

II. Review/Expansion of Definitions - Ask class for definitions

The Relational Model. 3/1/2010 Database Management Systems, Roya Choupani 1

THE AUSTRALIAN NATIONAL UNIVERSITY. Mid-Semester Examination August 2006 RELATIONAL DATABASES (COMP2400)

Chapter 4 Conceptual Modeling

MIS Database Systems Entity-Relationship Model.

LECTURE 3: ENTITY-RELATIONSHIP MODELING

Database Applications (15-415)

COMP 244 DATABASE CONCEPTS & APPLICATIONS

Database Applications (15-415)

Transcription:

Database Design Overview What is database? Why do we bother? Relational database Entity-Relationship Modeling Mapping class diagrams to tables 2

What Is Database? A tool that stores data, and lets you create, read, update, and delete the data Information container Various types of database Flat files spreadsheets XML relational databases mysql, Oracle, DB2, Access 3 Why Do We Use Database? Every non-trivial application uses databases to keep program states, to store, manipulate, and retrieve data Database plays a critical role in applications Corrupted data => execution failure Poor data organization => poor performance A poorly designed database application allows developers to put in arbitrary data Enter a string none as a phone number 4 2

Relational Database A digital database with a collection of tables Each table contains rows and columns, with a unique key for each row Each entity type described in a database has its own table E.g., Employee, Item, Order Each row represents an instance of the entity E.g., John Jenny, Soap Each column represents an attribute E.g., phone number, price 5 Relational Databases (cont.) Tuple Users Attribute User_id Name Phone 00 John 23458 002 Jane 25434 Relation Primary Key/Unique Key: to uniquely specify a tuple in a table Foreign Key: an attribute in a relational table that matches the primary key column of another table. It can be used to cross-reference tables. 6 3

Entity-Relationship Models Entity-relationship (ER) diagrams are similar to semantic object modelings ( class diagrams) It uses different notations Focuses more on relations and less on class structure 7 Entities and Attributes An entity is similar to a semantic object It includes attributes that describe the object EmployeeId FirstName LastName Employee 8 4

Relationships An ER diagram indicates a relationship between entities with a diamond Sometimes arrows are added to indicate direction of relationship Customer Places Order Ships Shipper 9 Cardinality Numbers used to describe relationship quantitatively Student..N Takes..N Course 0 5

Inheritance A triangle named IsA represents the inheritance relationship Employee IsA Mechanic Salesman Mapping Class Diagrams to Tables 6

Mapping Classes to Tables Course courseid name description Student studentid firstname lastname Courses CourseId Name Description Students StudentId FirstName LastName 3 Key Points about Tables Sometimes you need to explicitly add a primary key to distinguish data in tables Database usually provides functionality to automatically increment primary key Sale date: Date iscomplete:bool Sales SaleId Date IsComplete 4 7

Mapping Associations Mapping One-to-One Associations Sale date: Date iscomplete: bool Receives Payment method: String due: float amountpaid: float change: float Sale Receives Payment 6 8

What Are the Tables? Sale SaleId Date IsComplete PaymentId Payment PaymentId Method Due AmountPaid Change 7 Mapping One-to-Many Associations SalesLineItem quantity:integer getsubtotal() Described-by * Product Specification desc:string price:money Id:DescID SalesLine Item N Descri bed-by ProductSpe cification 8 9

What Are the Tables? SalesLineItem Id Quantity DescId ProductSp ecification DescId Desc Price 9 Mapping Many-to-One Associations Sale Contains..* Sales LineItem quantity:integer Sale..N contains SalesLine Item 20 0

What Are the Tables? Sale SaleId Date IsComplete SalesLineItem Id SaleId Quantity 2 Mapping Many-to-Many Associations to Table Course courseid name description Contains..*..* Takes Student studentid firstname lastname Student..N Takes..N Course 22

What Are the Tables? Courses CourseId Name Description StudentCourses StudentId CourseId Students StudentId FirstName LastName 23 Multiple Many-to-Many What if we want to know students enrollment over time for each year and semester E.g., to distinguish students enrolled different time)? Course courseid name description Contains..* Session year semester instructor * * Student studentid firstname lastname 24 2

Courses CourseId Name Description StudentSession StudentId SessionId Students StudentId FirstName LastName Session SessionId CourseId Year Semester Instructor 25 Multiple-Object Associations Definition Many different kinds of objects are collectively associated with each other Case study Making a movie requires a whole horde of people including a director, a bunch of actors, and a huge number of crew members 26 3

Class Diagram for Movie-making Movie movieid title description * Director directorid name Actor actorid name Crewmember crewmemberid name * 27 ER Diagram for Movie Making Director Actor..N Create Movie Crewmember..N 28 4

Consider the Relationship as a Combination of Simpler Relationships Director Actor..N Helps create Helps create Movie Crewmember..N Helps create 29 Actors ActorId Name Crewmembers CrewmemberId Name MovieActors MovieId ActorId MovieCrewmembers MovieId CrewmemberId Movie MovieId Title Description DirectorId Directors DirectorId Name 30 5

Repeated Attribute Associations Some entities have multiple attributes that represent either the same kind of data or very similar kind of data Some people may have multiple phone numbers for different purposes Some people may have only one number to serve all purposes Person personid firstname lastname workphone cellphone homephone dayphone nightphone 3 How to design the tables to avoid repetition or sparse data? PersonId FirstName LastName DaytimePhone NightPhone Person Workphone Cellphone Homephone 32 6

Persons PersonId FirstName LastName Phones PersonId Type Number 33 Reflexive Associations An object refers to an object of the same class One-to-One reflexive association One-to-Many reflexive association Many-to-Many reflexive association 34 7

One-to-One Reflexive Association Person personid firstname lastname spouse Person 0.. Persons PersonId 0.. Is married to FirstName LastName SpouseId 35 One-to-Many Reflexive Association Employee personid firstname lastname manager 0..* Employee 0.. Employees 0..* PersonId FirstName LastName ManagerId 0.. Is managed by 36 8

9 Many-to-Many Reflexive Association 37 Node nodeid X Y Node Connects to..n..n Distance Nodes NodeId X Y 0..* Links FromNodeId ToNodeId Distance 0..* Inheritance 38 Person personid firstname lastname email address Customer customerid address Employee employeeid ssn specialities Vendor vendorid companyname notes

ER-Diagram Person IsA Customer Employee Employee 39 Persons PersonId FirstName LastName Email Address Tables Vendors vendorid personid CompanyName Notes Customers customerid personid Employees employeeid personid ssn specialities 40 20