We know how to query a database using SQL. A set of tables and their schemas are given Data are properly loaded



Similar documents
Chapter 2: Entity-Relationship Model. E-R R Diagrams

Lesson 8: Introduction to Databases E-R Data Modeling

Chapter 2: Entity-Relationship Model. Entity Sets. " Example: specific person, company, event, plant

ER modelling, Weak Entities, Class Hierarchies, Aggregation

Chapter 2: Entity-Relationship Model

Foundations of Information Management

OVERVIEW 1.1 DATABASE MANAGEMENT SYSTEM (DBMS) DEFINITION:-

Boyce-Codd Normal Form

not necessarily strictly sequential feedback loops exist, i.e. may need to revisit earlier stages during a later stage

Foundations of Information Management

BİL 354 Veritabanı Sistemleri. Entity-Relationship Model

Chapter 7 Data Modeling Using the Entity- Relationship (ER) Model

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

Database Management Systems

Chapter 7: Relational Database Design

three Entity-Relationship Modeling chapter OVERVIEW CHAPTER

Introduction to SQL ( )

Comp 3311 Database Management Systems. 2. Relational Model Exercises

DATABASE DESIGN. - Developing database and information systems is performed using a development lifecycle, which consists of a series of steps.

Simple SQL Queries (3)

Chapter 1: Introduction. Database Management System (DBMS)

Functional Dependencies

Chapter 6: Integrity Constraints

Data Analysis 1. SET08104 Database Systems. Napier University

Unit 2.1. Data Analysis 1 - V Data Analysis 1. Dr Gordon Russell, Napier University

Conceptual Design: Entity Relationship Models. Objectives. Overview

COMP 378 Database Systems Notes for Chapter 7 of Database System Concepts Database Design and the Entity-Relationship Model

Database Design Overview. Conceptual Design ER Model. Entities and Entity Sets. Entity Set Representation. Keys

2. Conceptual Modeling using the Entity-Relationship Model

Entity-Relationship Model

You can use command show database; to check if bank has been created.

Introduction to database management systems

An Example: Video Rental System

Database Design Process

Chapter 3. Data Modeling Using the Entity-Relationship (ER) Model

CSE 233. Database System Overview

SQL is capable in manipulating relational data SQL is not good for many other tasks

B2.2-R3: INTRODUCTION TO DATABASE MANAGEMENT SYSTEMS

Advance DBMS. Structured Query Language (SQL)

CSC 742 Database Management Systems

CSE 132A. Database Systems Principles

Database Design Methodology

Comp 5311 Database Management Systems. 3. Structured Query Language 1

Database Design Process

XV. The Entity-Relationship Model

Data Modelling and E-R Diagrams

Chapter 1: Introduction

Exercise 1: Relational Model

Converting E-R Diagrams to Relational Model. Winter Lecture 17

Designing a Database Schema

Database Design Process. Databases - Entity-Relationship Modelling. Requirements Analysis. Database Design


The Relational Data Model: Structure

AS LEVEL Computer Application Databases

The E-R èentity-relationshipè data model views the real world as a set of basic objects èentitiesè and

Modern Systems Analysis and Design

CS 377 Database Systems. Database Design Theory and Normalization. Li Xiong Department of Mathematics and Computer Science Emory University

Lecture 12: Entity Relationship Modelling

Introdução às Bases de Dados

Bridge from Entity Relationship modeling to creating SQL databases, tables, & relations

The Entity-Relationship Model

Database Design and the E-R Model

Databases and BigData

7.1 The Information system

Data Modeling. Database Systems: The Complete Book Ch ,

Chapter 1: Introduction

CPS352 Database Systems: Design Project

SAMPLE FINAL EXAMINATION SPRING SESSION 2015

Chapter 7: Relational Database Design

Concepts of Database Management Seventh Edition. Chapter 6 Database Design 2: Design Method

Database Systems. Session 3 Main Theme. Enterprise Data Modeling Using The Entity/Relationship (ER) Model. Dr. Jean-Claude Franchitti

Fundamentals of Database System

Basic Concepts. Chapter A: Network Model. Cont.) Data-Structure Diagrams (Cont( Data-Structure Diagrams. General Relationships. The DBTG CODASYL Model

Review Entity-Relationship Diagrams and the Relational Model. Data Models. Review. Why Study the Relational Model? Steps in Database Design

LOGICAL DATABASE DESIGN

Database Design. Marta Jakubowska-Sobczak IT/ADC based on slides prepared by Paula Figueiredo, IT/DB

Relational model. Relational model - practice. Relational Database Definitions 9/27/11. Relational model. Relational Database: Terminology

Entity/Relationship Modelling. Database Systems Lecture 4 Natasha Alechina

About the Tutorial. Audience. Prerequisites. Copyright & Disclaimer

A Comparative Analysis of Entity-Relationship Diagrams 1

A brief overview of developing a conceptual data model as the first step in creating a relational database.

DataBase Management Systems Lecture Notes

Designing Databases. Introduction

SUBQUERIES AND VIEWS. CS121: Introduction to Relational Database Systems Fall 2015 Lecture 6

CS2Bh: Current Technologies. Introduction to XML and Relational Databases. The Relational Model. The relational model

? Database Management

Databases -Normalization III. (N Spadaccini 2010 and W Liu 2012) Databases - Normalization III 1 / 31

The Entity-Relationship Model

Introduction to Database Systems CS4320/CS5320. CS4320/4321: Introduction to Database Systems. CS4320/4321: Introduction to Database Systems

14 Databases. Source: Foundations of Computer Science Cengage Learning. Objectives After studying this chapter, the student should be able to:

Data Modeling with Entity-Relationship Diagrams

Database Design. Database Design I: The Entity-Relationship Model. Entity Type (con t) Chapter 4. Entity: an object that is involved in the enterprise

Relational Database Concepts

Rose Data Modeler (logical)

Information Systems Analysis and Design CSC John Mylopoulos Database Design Information Systems Analysis and Design CSC340

IV. The (Extended) Entity-Relationship Model

Data Modeling: Part 1. Entity Relationship (ER) Model

CHAPTER 3: DATA MODELING USING THE ENTITY-RELATIONSHIP MODEL

Information Systems Modelling Information Systems I: Databases

Announcements. SQL is hot! Facebook. Goal. Database Design Process. IT420: Database Management and Organization. Normalization (Chapter 3)

Transcription:

E-R Diagram

Database Development We know how to query a database using SQL A set of tables and their schemas are given Data are properly loaded But, how can we develop appropriate tables and their schema for an application? In real applications, data often does not present as tables naturally What are the corresponding data units of tables? CMPT 354: Database I -- E-R Diagram 2

What Is Data in Applications? A student information system Objects: students (Ann, Bob, ), courses (354, 459, ), departments (CS, Engineering, ), Objects are related Students taking courses (Ann takes 354, Bob takes 459, ), courses offered by departments (354 and 459 are offered by CS), Generally, an application contains a set of objects and their relationships CMPT 354: Database I -- E-R Diagram 3

Entities An entity: an object that exists and is distinguishable from other objects E.g., Ann, Bob, CS, Engineering, 354, 459, Entities have attributes, e.g., Ann has a phone number and an address An entity set: a set of entities of the same type that share the same properties E.g., the set of students, the set of departments, the set of courses, CMPT 354: Database I -- E-R Diagram 4

Entity Sets in Relational Databases customer_id customer_ customer_ customer_ loan_ amount name street city number CMPT 354: Database I -- E-R Diagram 5

Attributes An entity is represented by a set of attributes the descriptive properties possessed by all members of an entity set customer = (customer_id, customer_name, customer_street, customer_city ) loan = (loan_number, amount ) Domain the set of permitted values for an attribute CMPT 354: Database I -- E-R Diagram 6

Attribute types Simple and composite attributes Simple: cannot be divided into subparts Composite: Name = first_name + last_name Single-valued and multi-valued attributes Single-valued: each entity has only one value Multi-valued: an entity may have zero, one, or more values, e.g., telephone numbers Derived attributes Can be computed from other attributes Example: age, given date_of_birth CMPT 354: Database I -- E-R Diagram 7

Relationships A relationship: an association among several entities Ann takes 354, Bob takes 459 A set of relationships may share common features: student-takingcourses A relationship set: a mathematical relation among n 2 entities, each taken from an entity set {(e 1, e 2,, e n ) e 1 E 1, e 2 E 2,, e n E n }, where (e 1, e 2,, e n ) is a relationship Example: (Ann, 354) std-take-crs, (Bob, 459) stdtake-crs CMPT 354: Database I -- E-R Diagram 8

Relationship Set borrower CMPT 354: Database I -- E-R Diagram 9

Properties of Relationship Sets A relationship set can also have properties CMPT 354: Database I -- E-R Diagram 10

Degree of a Relationship Set The number of entity sets that participate in a relationship set Relationship sets that involve two entity sets are binary (or of degree two) Most relationship sets in a database system are binary Relationship sets may involve more than two entity sets Example: a ternary relationship set between entity sets student, course, and instructor CMPT 354: Database I -- E-R Diagram 11

Mapping Cardinality Constraints Express the number of entities to which another entity can be associated via a relationship set Most useful in describing binary relationship sets For a binary relationship set the mapping cardinality must be one of the following types One to one, e.g., president university One to many, e.g.,. instructor course Many to one, e.g., course instructor Many to many, e.g., student course CMPT 354: Database I -- E-R Diagram 12

Mapping Cardinalities One to one One to many CMPT 354: Database I -- E-R Diagram 13

Mapping Cardinalities Many to one Many to many CMPT 354: Database I -- E-R Diagram 14

Entity-Relationship (ER) Model Elements in a database: data entries Data entries represent Entities: data objects, e.g., students, courses, and instructors Relationships among entities: students take courses, instructors teach courses ER model: model data using entities and relationships CMPT 354: Database I -- E-R Diagram 15

Object Identity and Keys In an application, we need to uniquely identify a natural object, and a natural relationship among multiple objects Student: name, address, phone number Course: name, instructor, time Student-take-course: student-id, course-id The identities are modeled as keys CMPT 354: Database I -- E-R Diagram 16

Keys A super key of an entity set is a set of one or more attributes whose values uniquely determine each entity A candidate key of an entity set is a minimal super key customer_id is a candidate key of customer account_number is a candidate key of account One of the candidate keys is selected to be the primary key CMPT 354: Database I -- E-R Diagram 17

Keys for Relationship Sets The combination of primary keys of the participating entity sets forms a super key of a relationship set (customer_id, account_number) is the super key of depositor Need to consider the semantics of relationship set in selecting the primary key if more than one candidate key is feasible CMPT 354: Database I -- E-R Diagram 18

Keys and Mapping Cardinality One to one relationship set Use a candidate key in either entity set University-president (university, president) Many to one relationship set Use a candidate key in the many side entity set Teaching (instructor, courses) Many to many relationship set Use a candidate key in each participating entity set Take-course (student, course) CMPT 354: Database I -- E-R Diagram 19

E-R Diagrams Rectangles represent entity sets Diamonds represent relationship sets Lines link attributes to entity sets and entity sets to relationship sets Ellipses represent attributes Double ellipses represent multivalued attributes Dashed ellipses denote derived attributes Underline indicates primary key attributes CMPT 354: Database I -- E-R Diagram 20

Example Attribute Entity set Relationship set CMPT 354: Database I -- E-R Diagram 21

A More Complicated Example Composite attribute Multi-valued attribute Derived attribute CMPT 354: Database I -- E-R Diagram 22

Relationship Sets with Attributes CMPT 354: Database I -- E-R Diagram 23

Summary Model real world data using entities and relationships The ER model ER diagrams Entities, relationships, attributes Constraints, keys, cardinalities CMPT 354: Database I -- E-R Diagram 24

To-Do-List Examine the tables in the TPC data set used in assignment 1. Can you guess for each table whether it models an entity set or a relationship set? CMPT 354: Database I -- E-R Diagram 25