Similar documents
Chapter 2: Entity-Relationship Model

Chapter 2: Entity-Relationship Model. Entity Sets. Entity Sets customer and loan. Attributes. Relationship Sets. A database can be modeled as:

Chapter 4. Enhanced Entity- Relationship Modeling. Enhanced-ER (EER) Model Concepts. Subclasses and Superclasses (1)

Chapter 6: Entity-Relationship Model

COMP Instructor: Dimitris Papadias WWW page:

6.1 RELATIONSHIP CONCEPTS

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

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

A database can be modeled as: + a collection of entities, + a set of relationships among entities.

Chapter (4) Enhanced Entity-Relationship and Object Modeling

Chapter 6: Entity-Relationship Model

COIS Databases

LELCTURE 4: ENHANCED ENTITY-RELATIONSHIP MODELING (EER)

Entity-Relationship Model

1. Considering functional dependency, one in which removal from some attributes must affect dependency is called

Entity Relationship Data Model. Slides by: Shree Jaswal

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

More on the Chen Notation

Conceptual Data Models for Database Design

Intro to DB CHAPTER 6

Represent entities and relations with diagrams

Enhanced Entity- Relationship Models (EER)

Relational Model (cont d) & Entity Relational Model. Lecture 2

Chapter 6: Entity-Relationship Model

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

Design Process Modeling Constraints E-R Diagram Design Issues Weak Entity Sets Extended E-R Features Design of the Bank Database Reduction to

E-R Model. Hi! Here in this lecture we are going to discuss about the E-R Model.

UNIT I. Introduction

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

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

Database Systems. A Practical Approach to Design, Implementation, and Management. Database Systems. Thomas Connolly Carolyn Begg

Chapter 7: Entity-Relationship Model

Entity Relationship Modelling

Chapter 7: Entity-Relationship Model

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

Chapter 7: Entity-Relationship Model

Chapter 2 ENTITY RELATIONSHIP MODEL

IS 263 Database Concepts

Chapter 9: Relational DB Design byer/eer to Relational Mapping Relational Database Design Using ER-to- Relational Mapping Mapping EER Model

Example: specific person, company, event, plant

Database Principles: Fundamentals of Design, Implementation, and Management Tenth Edition. Chapter 8 Data Modeling Advanced Concepts

CSIT5300: Advanced Database Systems

A l Ain University Of Science and Technology

Conceptual Data Modeling

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

Chapter 8: Enhanced ER Model

Chapter 1 Chapter-1

Enhanced Entity-Relationship (EER) Modeling

Chapter 8 The Enhanced Entity- Relationship (EER) Model

Module 2 : Entity-Relationship Model 15

Data about data is database Select correct option: True False Partially True None of the Above

4. Entity Relationship Model

FINAL EXAM REVIEW. CS121: Introduction to Relational Database Systems Fall 2018 Lecture 27

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

Database Systems. Overview - important points. Lecture 5. Some introductory information ERD diagrams Normalization Other stuff 08/03/2015

Chapter 3 Database Modeling and Design II. Database Modeling

Lecture 14 of 42. E-R Diagrams, UML Notes: PS3 Notes, E-R Design. Thursday, 15 Feb 2007

DATABASE MANAGEMENT SYSTEM

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

Unit 2 - Data Modeling. Pratian Technologies (India) Pvt. Ltd.

Outline. Database Management Systems (DBMS) Database Management and Organization. IT420: Database Management and Organization

Chapter 7: Entity-Relationship Model

ER modeling. Lecture 4

Basant Group of Institution

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

Mahathma Gandhi University

ER DIAGRAM ER) diagram, a graphical representation of entities and their relationships to each other, typically used in computing in regard to the

SOFTWARE ENGINEERING Prof.N.L.Sarda Computer Science & Engineering IIT Bombay. Lecture #10 Process Modelling DFD, Function Decomp (Part 2)

The Entity Relationship Model

Chapter 7: Entity-Relationship Model. Chapter 7: Entity-Relationship Model

A l Ain University Of Science and Technology

The Entity-Relationship Model. Steps in Database Design

MIS Database Systems Entity-Relationship Model.

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

Chapter 17. Methodology Logical Database Design for the Relational Model

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

1. Data Model, Categories, Schemas and Instances. Outline

Database Management System CS403 Lecture No 1 Database definitions: 1 A shared collection of logically related data, designed to meet the information

Database Management Systems LECTURE NOTES 2

System Analysis And Design Methods ENTITY RELATIONSHIP DIAGRAM (ERD) Prof. Ali Khaleghi Eng. Hadi Haedar

The En'ty Rela'onship Model

THE ENHANCED ER (EER) MODEL CHAPTER 8 (6/E) CHAPTER 4 (5/E)

The Relational Model

B.H.GARDI COLLEGE OF MASTER OF COMPUTER APPLICATION. Ch. 1 :- Introduction Database Management System - 1

CMSC 424 Database design Lecture 2: Design, Modeling, Entity-Relationship. Book: Chap. 1 and 6. Mihai Pop

DATABASE SCHEMA DESIGN ENTITY-RELATIONSHIP MODEL. CS121: Relational Databases Fall 2017 Lecture 14

Chapter 2 Conceptual Modeling. Objectives

Conceptual Database Design

COMP102: Introduction to Databases, 13

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

CS 338 The Enhanced Entity-Relationship (EER) Model

Non-overlappingoverlapping. Final outcome of the worked example On pages R&C pages R&C page 157 Fig 3.52

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

Unit I. By Prof.Sushila Aghav MIT

Data Modeling using ER Model

CSCC43H: Introduction to Databases

II B.Sc(IT) [ BATCH] IV SEMESTER CORE: RELATIONAL DATABASE MANAGEMENT SYSTEM - 412A Multiple Choice Questions.

Entity-Relationship Model &

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

Database Systems: Design, Implementation, and Management Tenth Edition. Chapter 4 Entity Relationship (ER) Modeling

Transcription:

0. Database Systems 1.1 Introduction to DBMS Information is one of the most valuable resources in this information age! How do we effectively and efficiently manage this information? - How does Wal-Mart manage its 200 TB data warehouse? - What is the database technology behind ebay's website? - How do you build an Oracle 10g, IBM DB2 or Microsoft SQL Server database? Relational Database Management Systems: Dominant data management paradigm today 10 Billion dollar a year industry (in the U.S. only): You will see this in the job market! 0.1 What the subject is about This course covers the fundamental concepts in database systems: Organization of data Efficient retrieval of data Reliable storage of data Maintaining consistent data Not surprisingly, all these topics are interrelated. 1.0 What is a Database System (DBS)? A Database (DB) is a very large, integrated collection of data designed to meet the information needs of an organization. A DB models a real world enterprise. Entities: e.g. students, courses... A Database Management System (DBMS) is a software package designed to store and manages databases. Allows the user to define the database through a Data Definition Language (DDL). Allows users to insert, update, delete, and retrieve data from the database through a Data Manipulation Language (DML). Provides controlled access to the database. Database System = DBMS + Data Why don't us program up" databases when we need them? For simple and small databases this is often the best solution: Flat files and grep get us a long way. We run into problems when The structure is complicated (more than a simple table) The database gets large Many people want to use it simultaneously 1.1.1 Actors in the Database Environment Data and Database Administrators / Database Designers Designs the logical/physical schemas Handles Security and authorization Crash Recovery Database tuning as needs evolve Application Programmers: Provide the required functionality to the end-users End-Users: Clients for the database Naive users: unaware of the DBMS Sophisticated users: Familiar with the structure of the database and the facilities offered by the DBMS. Relationships: e.g. Rashmi is taking CS 04 705 G DBMS Module 1 1

1.1.2 Advantages and Disadvantages of DBMS 1.1.4 Data Model Advantages Control of Data Redundancy Data Consistency Sharing of Data Improved Data Integrity and Security Increased Concurrency Disadvantages: Complexity Size Cost of DBMS Additional Hardware Costs Performance Higher Impact of Failure 1.1.3 Database architecture It is common to describe databases in two ways: The logical level: What users see, i.e. the program or query language interface. - It is traditional to split the logical level into two components: A data model describes conceptual structuring of data stored in database. - Example: Data is set of records, each with ID, name, address, and courses. - Example: Data is a graph where nodes represent proteins and edges represent chemical bonds between proteins. Data model provides a description of the database structure including: The data The relationships within the data The constraints on the data Different representation methods: Entity-Relationship Model Relational Model Object-Oriented Model Object Relational Model Semistructured Data Model 1.1.5 Schema & Instance Database Schema describes how data is to be structured. It is a description of the logical view of database. A common tool used to design schema is an entityrelationship diagram. - defined during creation of the database - rarely change - Conceptual level: overall database design - Views that various users get to see. The physical level: How files are organized, what indexing mechanisms are used. Database instance: The data stored in the database at a given moment. - rapidly change - updated continuously DBMS Module 1 2

1.1.6 Data independence 1.1.8 DBMS Interfaces Data independence: one of the most important benefits of DBMS A user of a relational database system should be able to use SQL to query the database without knowing about how precisely data is stored. e.g.: SELECT When, Where FROM Calendar WHERE Who = "Bill" We distinguish between two kinds of data independence: Logical data independence protects the user from changes in the logical structure of the data - could completely reorganize the calendar "schema without changing how I query it. Physical data independence protects the user from changes in the physical structure of data: could add an index on Who without changing how the user would write the query, but the query would execute faster (query optimization). 1.1.7 Database Languages Data Definition Language (DDL): Allows the user to define the database conceptual schema Storage Definition Language (SDL), is used to specify the internal schema Data Manipulation Language (DML): Allows users to insert, update, delete, and retrieve data from the database through a Query. Menu-Based Interface Form-Based Interface Graphical User Interface - utilize both Menu & Form Natural Language Interface - These interfaces accept requests written in English (or similar) and attempt to understand them. Interfaces for Parametric Users - Parametric users (e.g. : bank tellers) often have a small set of operations that they must perform repeatedly Interfaces for the DBA (DB Administrator) - Most database systems contain privileged commands that can be used only by the DBA s staff. DBMS Module 1 3

1.2 Entity-Relationship Model Attributes: An Example First introduced in the mid 1970's by Chen as an improvement to the relational model. The Entity-Relationship (E/R) model allows us to draw diagrams of database designs. Represent different types of data and how they relate to each other. The design is a drawing called the entityrelationship diagram. The Entity-Relationship model is an example of what is called a semantic model Description of conceptual and external levels of data Independent of the internal and physical aspects Ideas E/R Design Relational Schema Relational DBMS 1.2.1 Entity - Entity Set - Attributes An Entity is an abstract object of some sort. Examples: Banking system: Customer, Account, Loan. Airline system: Aircraft, Passenger, Flight, Airport. An Entity set is a collection of similar entities. Entities have attributes. An attribute is a property of the entities in an entity set. In an E/R diagram: A rectangle represents an entity set An oval represents an attribute A line connects an entity set (rectangle) to an attribute (oval) What appears to be an attribute to one designer may be an entity to another Attributes: Domain and Values Attributes have a value set or domain (set of possible values). - Null values: Sometimes the value of an attribute is unknown at the present time or undefined for a particular instance. Composite Attributes: can be decomposed into smaller elements. - Example: Address can be broken down into street, city, state, and zip. Multivalued Attributes: have multiple values for an entity instance, e.g. student with more than one e-mail address. They are represented with a double oval. Derived Attributes: whose value can be calculated when needed. - Example: Age may be determined from the current date and the date of birth. DBMS Module 1 4

Attributes in ER-Diagram 1.2.2 Keys Multivalued Attribute: Double oval around the attribute's name Composite Attribute: Writing the name in an oval and then drawing ovals for the individual components which are connected by lines to the composite attribute's oval Derived Attribute: Dashed oval around the attribute's name Entity Identification The process of identifying entities is one of the most important steps in developing a data model. Some guidelines: An informal questioning approach: the analyst asks targeted questions to determine what information is necessary and whether or not that information is recorded within the system. Face to face discussions with user: the nouns should be recorded. The existing documentation often contains clues. Every fact that is required to support the business is almost certainly an attribute. In turn each of these attributes will belong to an entity. If no parent" entity can be found for one or more of these low level facts, then this indicates that your entity search is incomplete. Entity identification can continue once the drawing of the data model diagram has begun Each entity occurrence can be uniquely identified, by using an attribute or a combination of attributes as a key. A Super Key is the attribute (or group of attributes) that serve to uniquely identify each entity occurrence. Consider the following problem: the name and address of an individual were used as the super key for identifying the patients within a hospital. Take the example of a patient called Sameer Muhammad living in Calicut City. He has a son also called Sameer Muhammad living at the same address. Name and Address would not necessarily provide a unique identifier and confusion could easily arise. In a hospital system patients each have a Patient Number as their super key. If two or more data items are used as the unique identifier, then this represents a Compound Key. - Example: a compound key used to identify a book could be Title" together with Author". A Candidate Key is a super key such that no proper subset of its attributes is itself a super key. An entity set might have several candidate keys. - Example: A book could be identified, either by Title" together with Author" or by the widely used unique identifier for books - the ISBN number. The Primary Key is the candidate key actually chosen. DBMS Module 1 5

1.2.3 Relationships Entities are often linked by associations or relationships. Recursive Relationships A Recursive Relationship is a relationship that associates an entity type with itself. A Relationship is a connection between two or more entity sets. In an E/R diagram a diamond represents a relationship a line connects the relationship to each entity set. Or Alternative representation of relationships: Relationship link phrase should be a short description of the nature of the relationship. It is always read clockwise with respect to the entities that it links. - Example: Manager is responsible for department" and Department is responsibility of manager". Ternary Relationships A relationship set need not be an association of precisely two entities; it can involve three or more when applicable. A relationship that involves three entities is called ternary relationship. Relationship Cardinality One-to-one relationship: Each manager is responsible for only one department and each department is the responsibility of only one manager. One-to-many relationship: Each company employs one or more employees, but each employee is employed by only one company. Many-to-many relationship: Each lecturer teaches one or more courses and each course is taught by one or more lecturers Identifying Relationships In order to identify the degree of the relationship between the entities X and Y the following two questions need to be asked. Question 1: Can an occurrence of X be associated with more than one occurrence of Y? Question 2: Can an occurrence of Y be associated with more than one occurrence of X? Four possible outcomes: Question 1 Question 2 Option 1 YES NO Option 2 No YES Option 3 YES YES Option 4 NO NO Option 1 and Option 2: A one-to-many relationship has been identified. Option 3: A many-to-many relationship has been identified. Option 4: A one-to-one link has been identified. DBMS Module 1 6

Relationship Participation The final property of the relationship statement is the total and partial participation. A solid line shows that an entity occurrence must be associated with each occurrence of the other entity. - Example: Each passenger must possess a ticket, and each ticket must belong to a passenger. A dotted line shows that an entity occurrence may be associated with each occurrence of the other entity. - Example: Each book may be borrowed by a borrower, and each borrower must borrow one or more books. 1.2.4 Weak Entities A Weak Entity is an entity that cannot be uniquely identified by its own attributes alone. A weak entity can be identified uniquely only by considering another entity. Example: Each book has several editions, and certainly it is nonsense to speak about an edition if this does not happen in the context of a specific book. 1.2.5 ER Diagram Example - Small Conference We need to keep track of authors that submit papers to the conference. An author should be identified uniquely and information such as his name (first, middle and last name) and research specialization should be recorded. We need to keep track of the papers submitted to the conference. A research paper is identified by its author, title, and date. One author can submit one or more papers to the conference and some papers are submitted by more than one author. Each paper is related to one or more research topics. We need to keep track of the research topics that the conference has covered. A research topic should be uniquely identified. The founder(s) and description of each topic should also be recorded. Each author participating in the conference has an account through which he can access all conference-related material. An account is identified by a unique username. The password, issue date and validity period of an account should also be recorded. A weak entity is depicted in the ERD by drawing a double rectangle around the entity and making the relationship diamond a double diamond. DBMS Module 1 7

Summary of ER diagram notation ERD Example - Small Conference DBMS Module 1 8

EER Diagrams 1.3 Enhanced Entity-Relationship (EER) Model The basic concepts of ER modelling are not powerful enough for some complex applications. We require some additional modelling concepts to represent more semantic information than the standard ER model. The Enhanced Entity-Relationship (EER) model extends the ER model to include various types of abstraction and to express constraints more clearly. Additional concepts in EER-Model: Specialization Generalization Categorization Inheritance Some of the concepts correspond to concepts in objectoriented design. 1.3.1 Superclass and Subclass Example: Staff may be grouped into Manager, Sales personnel, Finance Personnel, and Secretary. - Each of these groupings is a subset of Staff entities. - Each of these groupings is called subclass of Staff. - Staff is the superclass for each of these subclasses. Superclass: an entity type that includes distinct subclasses that requires to be represented in a data model. Subclass: an entity type that has a distinct role and is also a member of a superclass. 1.3.2 Inheritance An entity that is a member of a subclass inherits all attributes of the entity as a member of the super class. A subclass may optionally have distinct local attributes. A subclass also inherits all relationships. Sometimes the relationship superclass and subclass is referred to as an isa relationship. 1.3.3 Specialization Specialization is the process of defining a set of subclasses of a superclass. The set of subclasses is based upon some distinguishing characteristics of the entities of the superclass. Specialization is represented in EERdiagrams by A specialization circle connected by a line to a superclass. Each subclass is connected to the circle by a line having an inheritance symbol, i.e. a subset symbol or cup, with the open side facing the super class. Example of Specialization DBMS Module 1 9

EER Diagrams 1.3.4 Generalization Generalization is the reverse of the specialization process. Several classes with common features are generalized into a superclass. - Example: Students and faculty both have IDs and names as attributes. The two entities can be generalized into a new superclass Person having the common attributes. The subclasses Student and Faculty would each retain their special attributes. Using generalization, we develop diagrams from the bottom up. Using specialization, we develop diagrams from the top down. 1.3.5 Constraints on Specialization and Generalization Disjointness Constraint: specifies that the subclasses of the specialization must be disjointed, i.e. an entity can be a member of at most one of the subclasses. The disjointness constraint is specified by D or O in the EER-diagram: If the constraint is satisfied, then we write a D in the specialization circle. If the constraint is not satisfied, then we have overlapping subclasses. We write an O in the circle. Example of Disjointness Completeness Constraints A specialization has also a completeness constraint, which shows whether every member of the entity set must participate in it. If every member of the superclass must belong to some subclass, we have total specialization. If some superclass members can be permitted not to belong to any subclass the specialization is partial. The completeness constraint is specified in the EER-diagram: Total specialization: double line connecting the superclass to the specialization circle Partial specialization: single line connecting the superclass to the specialization circle Example of Completeness DBMS Module 1 10

EER Diagrams Predicate-defined Constraints on Specialization In specialization hierarchies, it is possible to identify the subclass that an entity belongs to by checking a specific condition or predicate for each subclass. Example of Attribute-defined Specialization The specialization is called predicate-defined specialization. For the predicate-defined specialization: On an EER-diagram, we can write the defining predicate on the line from the specialization circle to the subclass. If the predicate uses the same attribute for all subclasses, we call the specialization an attribute-defined specialization. For the attribute-defined specialization: On an EERdiagram, we indicate the defining attribute on the line from the circle to the superclass, and the distinguishing value for each subclass on the line from the subclass to the circle. Specializations that are not predicate-defined are called user-defined specialization. Example of Predicate-defined Specialization DBMS Module 1 11

EER Diagrams 1.3.6 Hierarchies and Lattices A subclass may itself have further subclasses. This forms a hierarchy or a lattice. Hierarchy has a constraint that every subclass has only one superclass: Single inheritance. In a lattice, a subclass can have more than one superclass: Multiple inheritance. A subclass with more than one superclass is called shared subclass. In a lattice or hierarchy, a subclass inherits attributes not only of its direct subclass, but also of all its predecessor superclasses. Example of Hierarchy Example of Lattice 1.3.7 Categories: Union A shared subclass is a subclass having more than one superclass. A shared subclass inherits all attributes from all the superclasses. In some cases, we need to model a single superclass/subclass relationship with more than one superclass. In other words, the subclass should be related to one of the collection, called a union or category. An instance of the subclass inherits the attributes of only one of the superclass depending on which member of the union that it belongs to. - Example: A database for vehicle registration: vehicle owner can be a person, a bank, or a company. Category (subclass): Owner is a subset of the union of the three superclasses Company, Bank, and Person. A category member must exist in a least one of its superclasses. In an EER-diagram: we represent a category by a union circle connecting the subclass with its superclasses. Example of Union DBMS Module 1 12