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

Similar documents
Chapter 6: Entity-Relationship Model

The Entity-Relationship Model

Chapter 6: Entity-Relationship Model

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

The Entity-Relationship Model

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

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

The Entity-Relationship (ER) Model

The Entity-Relationship Model. Overview of Database Design

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

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

Chapter 2: Entity-Relationship Model

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

MIS Database Systems Entity-Relationship Model.

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

Introduction to Database Design

Database Applications (15-415)

Database Management Systems. Chapter 2 Part 2

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

Chapter 6: Entity-Relationship Model

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

6.1 RELATIONSHIP CONCEPTS

Example: specific person, company, event, plant

COMP Instructor: Dimitris Papadias WWW page:

The Entity-Relationship (ER) Model 2

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

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

Database Applications (15-415)

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

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

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

OVERVIEW OF DATABASE DEVELOPMENT

The Entity-Relationship Model. Steps in Database Design

The Entity-Relationship Model

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

CIS 330: Applied Database Systems

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

Chapter 7: Entity-Relationship Model

Chapter 7: 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 7: Entity-Relationship Model

Modeling Your Data. Chapter 2. cs542 1

Introduction to Database Design

Introduction to Data Management. Lecture #3 (Conceptual DB Design)

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

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

The Relational Model. Chapter 3

CSIT5300: Advanced Database Systems

Database Design CENG 351

Introduction to Data Management. Lecture #3 (Conceptual DB Design)

Introduction to Database Design

Entity-Relationship Diagrams

Database Management Systems. Chapter 3 Part 2

High Level Database Models

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

Database Applications (15-415)

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

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

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

Database Management Systems. Syllabus. Instructor: Vinnie Costa

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

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

Chapter 7: Entity-Relationship Model

The Relational Model 2. Week 3

Entity-Relationship Model

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

CSCC43H: Introduction to Databases

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

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

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

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

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

Intro to DB CHAPTER 6

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

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

Database Systems ( 資料庫系統 )

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

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

Database Design. ER Model. Overview. Introduction to Database Design. UVic C SC 370. Database design can be divided in six major steps:

Entity Relationship Data Model. Slides by: Shree Jaswal

Database Systems. Course Administration

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

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

The En'ty Rela'onship Model

Overview. Introduction to Database Design. ER Model. Database Design

Database Applications (15-415)

The Relational Model (ii)

High-Level Database Models (ii)

CSE 530A. ER Model. Washington University Fall 2013

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

From ER to Relational Model. Book Chapter 3 (part 2 )

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

Conceptual Design. The Entity-Relationship (ER) Model

DATABASE MANAGEMENT SYSTEMS

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

CONCEPTUAL DESIGN: ER TO RELATIONAL TO SQL

Unit I. By Prof.Sushila Aghav MIT

UNIT II A. ENTITY RELATIONSHIP MODEL

ER Model. CSC 343 Winter 2018 MICHAEL LIUT

Introduction to Data Management. Lecture #5 (E-R Relational, Cont.)

Transcription:

1 VARDHAMAN COLLEGE OF ENGINEERING Shamshabad 501 218, Hyderabad B.Tech. CSE IV Semester (VCE - R11) T P C 3+1* -- 4 (A1511) DATABASE MANAGEMENT SYSTEMS UNIT - I INTRODUCTION: History of database systems, introduction to database management systems, database system applications, database systems versus file systems, view of data, data models, database languages- DDL & DML commands and examples of basic SQL queries, database users and administrators, transaction management, database system structure, application architectures. DATABASE DESIGN: Introduction to database design and E-R diagrams, entities, attributes and entity sets, relationships and relationship sets, additional features of the E-R model, conceptual design with the E-R model, conceptual design for large enterprises.

2 VARDHAMAN COLLEGE OF ENGINEERING Shamshabad 501 218, Hyderabad B.Tech. CSE IV Semester (VCE - R11) T P C 3+1* -- 4 (A1511) DATABASE MANAGEMENT SYSTEMS UNIT - II THE RELATIONAL MODEL: Introduction to the relational model, integrity constraints over relations, enforcing integrity constraints, querying relational data, logical database design: E-R to relational, introduction to views, destroying/altering tables and views. RELATIONAL ALGEBRA AND CALCULUS: Preliminaries, relational algebra operators, relational calculus - tuple and domain relational calculus, expressive power of algebra and calculus. SQL: Overview, the form of a basic SQL query, union, intersect and except operators, nested queries, aggregate operators, null values, complex integrity constraints in SQL, triggers and active databases, designing active databases.

3 VARDHAMAN COLLEGE OF ENGINEERING Shamshabad 501 218, Hyderabad B.Tech. CSE IV Semester (VCE - R11) T P C 3+1* -- 4 (A1511) DATABASE MANAGEMENT SYSTEMS UNIT - III SCHEMA REFINEMENT AND NORMAL FORMS: Introduction to schema refinement, functional dependencies, reasoning about FDs. Normal forms: 1NF, 2NF, 3NF, BCNF, properties of decompositions, normalization, schema refinement in database design, other kinds of dependencies: 4NF, 5NF, DKNF, case studies.

4 VARDHAMAN COLLEGE OF ENGINEERING Shamshabad 501 218, Hyderabad B.Tech. CSE IV Semester (VCE - R11) T P C 3+1* -- 4 (A1511) DATABASE MANAGEMENT SYSTEMS UNIT - IV TRANSACTIONS MANAGEMENT: Transaction concept, transaction state, implementation of atomicity and durability, concurrent executions, serializability, recoverability, implementation of isolation, transaction definition in SQL, testing for serializability. CONCURRENCY CONTROL AND RECOVERY SYSTEM: Concurrency control - lock based protocols, time-stamp based protocols, validation based protocols, multiple granularity, and deadlock handling. Recovery system - failure classification, storage structure, recovery and atomicity, log-based recovery, shadow paging, recovery with concurrent transactions, buffer management, failure with loss of non-volatile storage, advanced recovery techniques, remote backup systems.

5 VARDHAMAN COLLEGE OF ENGINEERING Shamshabad 501 218, Hyderabad B.Tech. CSE IV Semester (VCE - R11) T P C 3+1* -- 4 (A1511) DATABASE MANAGEMENT SYSTEMS UNIT - V OVERVIEW OF STORAGE AND INDEXING: Data on external storage, file organizations and indexing, index data structures, comparison of file organizations, indexes and performance tuning. Tree structured indexing - intuition for tree indexes, indexed sequential access method (ISAM), B+ Trees - a dynamic tree structure. IBM DB2 FUNDAMENTALS*: DB2 product family - versions and editions, DB2 database and its objects, DB2 pure XML, backup and recovery, concurrency and its isolation levels, working with SQL, DB2 programming fundamentals - UDF, stored procedures. * This topic is designed in collaboration with IBM India Private Limited.

6 VARDHAMAN COLLEGE OF ENGINEERING Shamshabad 501 218, Hyderabad B.Tech. CSE IV Semester (VCE - R11) T P C 3+1* -- 4 (A1511) DATABASE MANAGEMENT SYSTEMS TEXT BOOKS: 1. Raghurama Krishnan, Johannes Gehrke (2007), Database Management Systems, 3rd edition, Tata McGraw Hill, New Delhi, India. REFERENCE BOOKS: 1. Elmasri Navate (1994), Fundamentals of Database Systems, Pearson Education, India. 2. Abraham Silberschatz, Henry F. Korth, S. Sudarshan (2005), Database System Concepts, 5th edition, McGraw-Hill, New Delhi, India. 3. Peter Rob, Carlos Coronel (2009), Database Systems Design, Implementation and Management, 7th edition, India.

UNIT I (Part-2) 7 Database Design: Introduction to Database Design Entity - Relationship (E-R) Diagrams Additional Features of the E-R Model Conceptual design with the E-R Model Conceptual design for large enterprises

Databases Model the Real World 8 Data Model allows us to translate real world things into structures computers can store Many models: Relational, E-R, O-O, Network, Hierarchical, etc. Relational Rows & Columns Keys & Foreign Keys to link Relations 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 3.2 53650 Smith smith@math 19 3.8

Steps in Database Design 9 Requirements Analysis user needs; what must database do? Conceptual Design high level description (often done with ER model) Logical Design translate ER into DBMS data model Schema Refinement consistency, normalization Physical Design - indexes, disk layout Security Design - who accesses what, and how

Conceptual Design 10 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? A database `schema in the ER Model can be represented pictorially (ER diagrams). Can map an ER diagram into a relational schema.

Entity - Relationship (E-R) Model Basics 11 A Conceptual Level Data Model Mainly for database design Provides the concepts of entities, relationships and attributes. Models an enterprise as a collection of entities and relationships Entity: a thing or object in the enterprise that is distinguishable from other objects Described by a set of attributes Relationship: an association among several entities

The Entity - Relationship Diagram (ERD) 12 Developing a database model based on the E-R diagram involves identifying the entities and the relationships between them. These are usually displayed in an E-R diagram. The ERD or Entity-Relationship Diagram marks a culmination in the process of database design. Once this is done, the database design can proceed with the process of actually creating the tables. ERDs graphically represent the entities, the attributes of an entity, and the relationships that exist between these entities.

The Entity - Relationship Diagram (ERD) 13 Case Study: Customer-Orders A customer places an order for several items. The Order- Processing Executive checks for the availability of the items and accordingly proceeds with processing the order. The nouns in the above-mentioned scenario form the entities. Therefore, we can say that Customer, Order, Order-Processing Executive and Item are the entities. The customer would have a Customer Code, a Name and perhaps a Phone No and Address. These comprise the attributes or properties of the entity Customer. Customer places an order is the relationship between the entities customer and order. Similarly, an order consist of Items.

The Entity - Relationship Diagram (ERD) 14 Case Study: Customer-Orders In our case study, Customer, Order and Item were entities. These entities along with their attributes are identified and listed, as shown below. Entity Customer Order Item Attributes Customer Code, Customer Name, Address, Phone No Order No, Order Data, Customer Code, Item Code, Qty Ordered Item Code, Item Name, Rate, Quantity On Hand, ReOrder Level Table: Entities and Attributes

The Entity - Relationship Diagram (ERD) 15 Case Study: Customer-Orders The Relationships that exist between the entities could be described as follows: A Customer places an Order An Order comprises of several Items Once we have this as an outline, we could proceed with creating an ERD that would look as shown in Figure.

The Entity - Relationship Diagram (ERD) 16 Figure: An Entity Relationship Diagram Customer Places Order Customer Name Customer Code Phone No. Address Order No. Order Date Qty Ordered Item Code Customer Code The relationship b/n customer & order is One to Many i.e. one customer can place many orders and an order can contain more than one item

The Entity - Relationship Diagram (ERD) 17 Case Study: Customer-Orders The symbols used in ERD are explained below: - Denote an Entity in an ERD - Represents an Attribute of an Entity - Denotes the relationship between Entities

The Entity - Relationship Diagram (ERD) 18 Case Study: Customer-Orders A customer could place more than one order, and an order can contain more than one item. In such a case it is said that the relationship between Customer and order is that of one to many, as one Customer can place many orders. On the other hand, the relationship between an Item and its Item Code is that of one to one, as one Item can have only one code. Similarly, the relationship between Order and Item can be considered to be a many to many relationship. In this case, one Order can have many Items, and a particular Item could be a part of several Orders.

The Entity - Relationship Diagram (ERD) 19 Relationship Types: One to One (represented in ERD as 1:1) One to Many (represented in ERD as 1:N) Many to One (represented in ERD as N:1) Many to Many (represented in ERD as M:N)

Relationship Types One to One Company 1 1 director Employee One to Many Company 1 N director Employee Many to Many Company M director N Employee

Entity, Entity Set 21 Entity: Real-world object, distinguishable from other objects. An entity is described using a set of attributes. Entity Set: A collection of similar entities that share the same properties. E.g., all employees, set of all persons, companies. All entities in an entity set have the same set of attributes. (Until we consider hierarchies, anyway!) Each entity set has a key (underlined). Each attribute has a domain. ssn name Employees lot

Entity Sets customer and loan 22 customer_id customer_ customer_ customer_ loan_ amount name street city number

Relationship, Relationship Set 23 name since dname ssn lot did budget Employees Works_In Departments Relationship: Association among two or more entities. E.g.,1. Attishoo works in Pharmacy department. 2. Hayes depositor A-102 customer entity relationship set account entity relationships can have their own attributes.

Relationship, Relationship Set 24 Relationship Set: Collection of similar relationships. An n-ary relationship set R relates n entity sets E 1... E n ; each relationship in R involves entities e 1 E 1,..., e n E n A relationship set is a mathematical relation among n 2 entities, each taken from entity sets {(e1, e2, en) e1 E1, e2 E2,, en En} where (e1, e2,, en) is a relationship Example: (Hayes, A-102) depositor

25 Relationship Set borrower

Relationship Set 26 An attribute can also be property of a relationship set. For instance, the depositor relationship set between entity sets customer and account may have the attribute access-date

Degree of a Relationship Set 27 Refers to number of entity sets that participate in a relationship set. Relationship sets that involve two entity sets are binary (or degree two). Generally, most relationship sets in a database system are binary. Relationship sets may involve more than two entity sets. Example: Suppose employees of a bank may have jobs (responsibilities) at multiple branches, with different jobs at different branches. Then there is a ternary relationship set between entity sets employee, job, and branch Relationships between more than two entity sets are rare. Most relationships are binary.

Relationship Set 28 name ssn lot did dname budget since supervisor Employees subordinate Departments Works_In Reports_To Same entity set can participate in different relationship sets, or in different roles in the same set.

Binary vs. Ternary Relationships 29 If each policy is owned by just 1 employee: Key constraint on Policies would mean policy can only cover 1 dependent! name ssn lot pname age Employees Bad design name ssn lot Employees Covers Dependents Policies policyid cost pname age Dependents Think through all the constraints in the 2nd diagram! Purchaser Better design Beneficiary Policies policyid cost

30 Binary vs. Ternary Relationships (Contd.) Previous example illustrated a case when two binary relationships were better than one ternary relationship. An example in the other direction: a ternary relation Contracts relates entity sets Parts, Departments and Suppliers, and has descriptive attribute qty. No combination of binary relationships is an adequate substitute.

31 Binary vs. Ternary Relationships (Contd.) qty Parts Contract Departments Suppliers VS. Parts needs Departments can-supply Suppliers deals-with S can-supply P, D needs P, and D deals-with S does not imply that D has agreed to buy P from S. How do we record qty?

32 The Entity - Relationship Diagram (ERD)

Attributes 33 An entity is represented by a set of attributes, that is descriptive properties possessed by all members of an entity set. Example: customer = (customer_id, customer_name, customer_street, customer_city ) loan = (loan_number, amount ) Domain the set of permitted values for each attribute Attribute types: Simple and composite attributes. Single-valued and multi-valued attributes Example: multivalued attribute: phone_numbers Derived attributes Can be computed from other attributes Example: age, given date_of_birth

34 Composite Attributes

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

E-R Diagram With Composite, Multivalued, and Derived Attributes

Relationship Sets with Attributes

Mapping Cardinality Constraints 38 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 One to many Many to one Many to many

Mapping Cardinalities 39 One to one One to many Note: Some elements in A and B may not be mapped to any elements in the other set

Mapping Cardinalities 40 Many to one Many to many Note: Some elements in A and B may not be mapped to any elements in the other set

Mapping Cardinalities 41 Relationship Types: One to One (represented in ERD as 1:1) One to Many (represented in ERD as 1:N) Many to One (represented in ERD as N:1) Many to Many (represented in ERD as M:N)

Relationship Types 42 One to One Company 1 1 director Employee One to Many Company 1 N director Employee Many to Many Company M director N Employee

Cardinality Constraints We express cardinality constraints by drawing either a directed line ( ), signifying one, or an undirected line ( ), signifying many, between the relationship set and the entity set. One-to-one relationship: A customer is associated with at most one loan via the relationship borrower A loan is associated with at most one customer via borrower

One-To-Many Relationship In the one-to-many relationship a loan is associated with at most one customer via borrower, a customer is associated with several (including 0) loans via borrower

Many-To-One Relationships In a many-to-one relationship a loan is associated with several (including 0) customers via borrower, a customer is associated with at most one loan via borrower

Many-To-Many Relationship A customer is associated with several (possibly 0) loans via borrower A loan is associated with several (possibly 0) customers via borrower

Alternative Notation for Cardinality Limits Cardinality limits can also express participation constraints

Keys 48 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 candidate key of customer account_number is candidate key of account Although several candidate keys may exist, one of the candidate keys is selected to be the primary key.

Keys for Relationship Set 49 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 NOTE: this means a pair of entity sets can have at most one relationship in a particular relationship set. Example: if we wish to track all access_dates to each account by each customer, we cannot assume a relationship for each access. We can use a multivalued attribute though Must consider the mapping cardinality of the relationship set when deciding what are the candidate keys Need to consider semantics of relationship set in selecting the primary key in case of more than one candidate key

Roles Entity sets of a relationship need not be distinct The labels manager and worker are called roles; they specify how employee entities interact via the works_for relationship set. Roles are indicated in E-R diagrams by labeling the lines that connect diamonds to rectangles. Role labels are optional, and are used to clarify semantics of the relationship

Participation of an Entity Set in a Relationship Set Total participation (indicated by double line): every entity in the entity set participates in at least one relationship in the relationship set E.g. participation of loan in borrower is total every loan must have a customer associated to it via borrower Partial participation: some entities may not participate in any relationship in the relationship set Example: participation of customer in borrower is partial

Participation Constraints 52 Does every employee work in a department? If so, this is a participation constraint the participation of Employees in Works_In is said to be total (vs. partial) What if every department has an employee working in it? Basically means at least one ssn name lot since did dname budget Employees Manages Departments Works_In since Means: exactly one

E-R Diagram with a Ternary Relationship

Cardinality Constraints on Ternary Relationship We allow at most one arrow out of a ternary (or greater degree) relationship to indicate a cardinality constraint E.g. an arrow from works_on to job indicates each employee works on at most one job at any branch. If there is more than one arrow, there are two ways of defining the meaning. E.g a ternary relationship R between A, B and C with arrows to B and C could mean 1. each A entity is associated with a unique entity from B and C or 2. each pair of entities from (A, B) is associated with a unique C entity, and each pair (A, C) is associated with a unique B Each alternative has been used in different formalisms To avoid confusion we outlaw more than one arrow

Weak Entities 55 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. name ssn lot cost pname age Employees Policy Dependents Weak entities have only a partial key (dashed underline)

56 Weak Entities

57 Weak Entities

Weak Entity Sets 58 An entity set that does not have a primary key is referred to as a weak entity set. The existence of a weak entity set depends on the existence of a identifying entity set it must relate to the identifying entity set via a total, one-tomany relationship set from the identifying to the weak entity set Identifying relationship depicted using a double diamond The discriminator (or partial key) of a weak entity set is the set of attributes that distinguishes among all the entities of a weak entity set. The primary key of a weak entity set is formed by the primary key of the strong entity set on which the weak entity set is existence dependent, plus the weak entity set s discriminator.

Weak Entity Sets (Cont.) 59 We depict a weak entity set by double rectangles. We underline the discriminator of a weak entity set with a dashed line. payment_number discriminator of the payment entity set Primary key for payment (loan_number, payment_number)

Weak Entity Sets (Cont.) 60 Note: the primary key of the strong entity set is not explicitly stored with the weak entity set, since it is implicit in the identifying relationship. If loan_number were explicitly stored, payment could be made a strong entity, but then the relationship between payment and loan would be duplicated by an implicit relationship defined by the attribute loan_number common to payment and loan

More Weak Entity Set Examples 61 In a university, a course is a strong entity and a course_offering can be modeled as a weak entity The discriminator of course_offering would be semester (including year) and section_number (if there is more than one section) If we model course_offering as a strong entity we would model course_number as an attribute. Then the relationship with course would be implicit in the course_number attribute

UNIT I (Part-2) 62 Database Design: Introduction to Database Design Entity - Relationship (E-R) Diagrams Additional Features of the E-R Model Conceptual design with the E-R Model Conceptual design for large enterprises

Additional or Extended E-R Features: Specialization 63 Top-down design process; we designate subgroupings within an entity set that are distinctive from other entities in the set. These subgroupings become lower-level entity sets that have attributes or participate in relationships that do not apply to the higher-level entity set. Depicted by a triangle component labeled ISA (E.g. customer is a person). Attribute inheritance a lower-level entity set inherits all the attributes and relationship participation of the higher-level entity set to which it is linked.

64 Specialization Example

Specialization Example

ISA (`is a ) Hierarchies ssn name lot 66 Employees hourly_wages hours_worked ISA contractid Hourly_Emps Contract_Emps As in C++, or other PLs, attributes are inherited. If we declare A ISA B, every A entity is also considered to be a B entity.

ISA (`is a ) Hierarchies 67 Overlap constraints: Can Simon be an Hourly_Emps as well as a Contract_Emps entity? (Allowed/disallowed) Covering constraints: Does every Employees entity also have to be an Hourly_Emps or a Contract_Emps entity? (Yes/no) Reasons for using ISA: To add descriptive attributes specific to a subclass. i.e. not appropriate for all entities in the superclass To identify entities that participate in a particular relationship i.e., not all superclass entities participate

Extended ER Features: Generalization 68 A bottom-up design process combine a number of entity sets that share the same features into a higher-level entity set. Specialization and generalization are simple inversions of each other; they are represented in an E-R diagram in the same way. The terms specialization and generalization are used interchangeably.

Specialization and Generalization (Cont.) 69 Can have multiple specializations of an entity set based on different features. E.g. permanent_employee vs. temporary_employee, in addition to officer vs. secretary vs. teller Each particular employee would be a member of one of permanent_employee or temporary_employee, and also a member of one of officer, secretary, or teller The ISA relationship also referred to as superclass - subclass relationship

70 Design Constraints on a Specialization/Generalization Constraint on which entities can be members of a given lowerlevel entity set. condition-defined Example: all customers over 65 years are members of senior-citizen entity set; senior-citizen ISA person. user-defined Constraint on whether or not entities may belong to more than one lower-level entity set within a single generalization.

71 Disjoint Design Constraints on a Specialization/Generalization an entity can belong to only one lower-level entity set Noted in E-R diagram by writing disjoint next to the ISA triangle Overlapping an entity can belong to more than one lower-level entity set

72 Design Constraints on a Specialization/Generalization (cont.) Completeness constraint -- specifies whether or not an entity in the higher-level entity set must belong to at least one of the lower-level entity sets within a generalization. total : an entity must belong to one of the lower-level entity sets partial: an entity need not belong to one of the lower-level entity sets

Aggregation 73 Consider the ternary relationship works_on, which we saw earlier Suppose we want to record managers for tasks performed by an employee at a branch

Aggregation ssn name lot 74 Used to model a relationship involving a relationship set. Allows us to treat a relationship set as an entity set for purposes of participation in (other) relationships. pid started_on Projects Employees Monitors pbudget since Sponsors did until dname Departments Aggregation vs. ternary relationship? Monitors is a distinct relationship, with a descriptive attribute. Also, can say that each sponsorship is monitored by at most one employee. budget

Aggregation (Cont.) 75 Relationship sets works_on and manages represent overlapping information Every manages relationship corresponds to a works_on relationship However, some works_on relationships may not correspond to any manages relationships So we can t discard the works_on relationship Eliminate this redundancy via aggregation Treat relationship as an abstract entity Allows relationships between relationships Abstraction of relationship into new entity Without introducing redundancy, the following diagram represents: An employee works on a particular job at a particular branch An employee, branch, job combination may have an associated manager

76 E-R Diagram With Aggregation

Aggregation 77 Consider the ternary relationship proj_guide Suppose we want to record evaluations of a student by a guide on a project

78 Aggregation

E-R Design Decisions 79 The use of an attribute or entity set to represent an object. Whether a real-world concept is best expressed by an entity set or a relationship set. The use of a ternary relationship versus a pair of binary relationships. The use of a strong or weak entity set. The use of specialization/generalization contributes to modularity in the design. The use of aggregation can treat the aggregate entity set as a single unit without concern for the details of its internal structure.

80 Complete Example for E - R Schema

81 Complete Example for E - R Schema

82 Complete Example for E - R Schema

83 Complete Example for E - R Schema

84 E-R Diagram for a Banking Enterprise

85 E-R Diagram for a University Enterprise

86 E-R Diagram for BANK MANAGEMENT SYSTEM

87 E-R Diagram for MOVIE DATABASE

88

89

90

91

92

93

94

95 Summary of Symbols Used in E-R Notation

96 Summary of Symbols (Cont.)

UNIT I (Part-2) 97 Database Design: Introduction to Database Design Entity - Relationship (E-R) Diagrams Additional Features of the E-R Model Conceptual design with the E-R Model Conceptual design for large enterprises

Conceptual Design Using the ER Model ER modeling can get tricky! 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: Binary or ternary? Aggregation? Note constraints of the ER Model: A lot of data semantics can (and should) be captured. But some constraints cannot be captured in ER diagrams. We ll refine things in our logical (relational) design

Entity vs. Attribute Should address be an attribute of Employees or an entity (related to Employees)? Depends upon how we want to use address information, and the semantics of the data: If we have several addresses per employee, address must be an entity (since attributes cannot be set-valued). If the structure (city, street, etc.) is important, address must be modeled as an entity (since attribute values are atomic). 99

Entity vs. Attribute (Cont.) 100 Works_In2 does not allow an employee to work in a department for two or more periods. Similar to the problem of wanting to record several addresses for an employee: we want to record several values of the descriptive attributes for each instance of this relationship. ssn name Employees ssn name lot Employees from lot from to Works_In2 Works_In3 Duration did did dname budget Departments to dname budget Departments

101 OK as long as a manager gets a separate discretionary budget (dbudget) for each dept. What if manager s dbudget covers all managed depts? (can repeat value, but such redundancy is problematic) Entity vs. Relationship name ssn Employees name ssn Employees since dbudget lot did Manages2 lot did dname budget Departments dname budget Departments is_manager managed_by since apptnum Mgr_Appts dbudget

Summary of Conceptual Design 102 Conceptual design follows requirements analysis, Yields a high-level description of data to be stored ER model popular for conceptual design Constructs are expressive, close to the way people think about their applications. Note: There are many variations on ER model Both graphically and conceptually Basic constructs: entities, relationships, and attributes (of entities and relationships). Some additional constructs: weak entities, ISA hierarchies, and aggregation.

UNIT I (Part-2) 103 Database Design: Introduction to Database Design Entity - Relationship (E-R) Diagrams Additional Features of the E-R Model Conceptual design with the E-R Model Conceptual design for large enterprises

Conceptual design for large enterprises 104 The process of conceptual design consists of more than just describing small fragments of the application in terms of ER diagrams. For a large enterprise, the design may require the efforts of more than one designer and span data and application code used by a number of user groups. An important aspect of the design process is the methodology used to structure the development of the overall design and to ensure that the design takes into account all user requirements and is consistent.

Conceptual design for large enterprises 105 The usual approach is that the requirements of various user groups are considered, any conflicting requirements are somehow resolved, and a single set of global requirements is generated at the end of the requirements analysis phase. An alternative approach is to develop separate conceptual schemas for different user groups and to then integrate these conceptual schemas. To integrate multiple conceptual schemas, we must establish correspondences between entities, relationships, and attributes, and we must resolve numerous kinds of conflicts.

END OF UNIT I (Part-2) 106 Database Design: Introduction to Database Design Entity - Relationship (E-R) Diagrams Additional Features of the E-R Model Conceptual design with the E-R Model Conceptual design for large enterprises