Download presentation
Presentation is loading. Please wait.
Published byGinger Perkins Modified over 9 years ago
1
UNIT_2 1 DATABASE MANAGEMENT SYSTEM[DBMS] 2620003 [Unit: 2] Prepared By Lavlesh Pandit SPCE MCA, Visnagar
2
UNIT_22 The Entity-Relationship (E-R) data model perceives the real world as consisting of basic objects, called entities, and relationships among these objects. An entity-relationship (ER) diagram is a specialized graphic that illustrates the interrelationships between entities in a database. It was developed to facilitate database design by allowing specification of an enterprise schema, which represents the overall logical structure of a database. It Represent of the meaning of the data. ER diagrams often use symbols to represent Information Entity-Relationship Model
3
UNIT_23 2.1 Basic Concepts The E-R data model employs three basic notions: I. Entity sets II Attributes III Relationship sets 2.1.1 Entity Sets An Entity is a “thing” or “object” in the real world that is distinguishable from all other objects. Individual objects are called entities Groups of the same type of objects are called entity types or entity sets Entities are represented by rectangles
4
UNIT_24 Attributes An attribute is a specification that defines a property of an object. Each attribute can have any value from its domain. Attributes can be simple or composite Having single-valued or multi-valued Fname STUDENT ADD_1
5
UNIT_25 An attribute, as used in the E-R model, can be characterized by the following attribute types. Simple and composite attributes Single-valued and Multivalued attributes Derived attribute Attributes have been simple; that is, they are not divided into subparts. Simple Attributes
6
UNIT_26 Composite Attributes Composite attributes, on the other hand, can be divided into subparts. For example, an attribute name could be structured as a composite attribute consisting of first-name, middle-initial, and last-name. Composite attributes help us to group together related attributes, making the modeling cleaner.
7
UNIT_27
8
8 Single-valued Attributes The attributes in our examples all have a single value for a particular entity. For instance, the loan-number attribute for a specific loan entity refers to only one loan number. An employee‘s social security number might be the employee's key attribute. Such attributes are said to be single valued and key attributes. Attribute
9
UNIT_29 A Multivalued attribute can have more than one value. For example, an employee entity can have multiple skill values. Consider an employee entity set with the attribute phone-number. An employee may have zero, one, or several phone numbers. Multivalued attributes Attribute
10
UNIT_210 Derived attribute The value for this type of attribute can be derived from the values of other related attributes or entities. A derived attribute is based on another attribute. For example: an employee's monthly salary is based on the employee's annual salary.
11
UNIT_211 Relationship Sets The relationship is the interaction between the entities. For example, we can define a relationship that associates customer Gitesh with loan no. L-15, This relationship specifies that Gitesh is a customer with loan number L-15. A relationship set is a set of relationships of the same type. Consider the two entity sets loan and branch. We can define the relationship set loan-branch to denote the association between a bank loan and the branch in which that loan is maintained.
12
UNIT_212 Constraints There are two types of constraints 1.Mapping cardinalities 2.Participation constraints
13
UNIT_213 Mapping cardinalities, or cardinality ratios, express the number of entities to which another entity can be associated via a relationship set. Mapping cardinality must be one of the following I. One to one: An entity in A is associated with at most one entity in B, and an entity in B is associated with at most one entity in A. Mapping Cardinalities
14
UNIT_214 II. One to many: An entity in A is associated with any number (zero or more) of entities in B. An entity in B, however, can be associated with at most one entity in A.
15
UNIT_215 III. Many to one An entity in A is associated with at most one entity in B. An entity in B, however, can be associated with any number (zero or more) of entities in A.
16
UNIT_216 An entity in A is associated with any number (zero or more) of entities in B, and an entity in B is associated with any number (zero or more) of entities in A. IV. Many to many:
17
UNIT_217 Participation Constraints The participation of an entity set E in a relationship set R is said to be total if every entity in E participates in at least one relationship in R. If only some entities in E participate in relationships in R, the participation of entity set E in relationship R is said to be partial.
18
UNIT_218 Keys No two entities in an entity set are allowed to have exactly the same value for all attributes. A key allows us to identify a set of attributes that suffice to distinguish entities from each other. Keys also help uniquely identify relationships, and thus distinguish relationships from each other.
19
UNIT_219 Types of Keys I. Super Key II. Candidate key III. Primary key IV. Unique Key V. Foreign Key Super key is a set of one or more than one keys that can be used to identify a record uniquely in a table. Example : Primary key, Unique key, Alternate key are subset of Super Keys. I. Super Key
20
UNIT_220 II. Candidate Key A Candidate Key is a set of one or more fields/columns that can identify a record uniquely in a table. There can be multiple Candidate Keys in one table. Each Candidate Key can work as Primary Key. Example: In below diagram ID, RollNo and EnrollNo are Candidate Keys since all these three fields can be work as Primary Key.
21
UNIT_221 Primary key is a set of one or more fields/columns of a table that uniquely identify a record in database table. It can not accept null, duplicate values. Only one Candidate Key can be Primary Key. III. Primary Key Uniquekey is a set of one or more fields/columns of a table that uniquely identify a record in database table. It is like Primary key but it can not accept null value and it can not have duplicate values. IV. Unique Key
22
UNIT_222 Foreign Key is a field in database table that is Primary key in another table. Example : We can have a DeptID column in the Employee table which is pointing to DeptID column in a department table where it a primary key. V. Foreign Key
23
UNIT_223 Practically in database, we have only three types of keys Primary Key, Unique Key and Foreign Key. Other types of keys are only concepts of RDBMS that we need to know. NOTE:
24
UNIT_224 Entity-Relationship Diagram E-R diagram can express the overall logical structure of a database graphically. Such a diagram consists of the following major components: Rectangles: which represent entity sets Ellipses: which represent attributes Diamonds: which represent relationship sets Lines: which link attributes to entity sets and entity sets to relationship sets Double ellipses: which represent multivalued attributes Dashed ellipses: which denote derived attributes
25
UNIT_225 Double lines: which indicate total participation of an entity in a relationship set Double rectangles: which represent weak entity sets
26
UNIT_226
27
UNIT_227
28
UNIT_228 Weak Entity Sets An entity set may not have sufficient attributes to form a primary key. Such an entity set is named as a weak entity set. Weak entity set does not have a primary key, we underline the discriminator of a weak entity set with a dashed line We depict a weak entity set by double rectangles in E-R diagram. A weak entity is an entity that depends on the existence another entity.
29
UNIT_229
30
UNIT_2 30 An entity set that has a primary key is termed a strong entity set. Strong Entity Set
31
UNIT_231 Extended E-R Features(Generalization, Specialization & Aggregation) An entity set may include subgroupings of entities that are distinct in some way from other entities in the set. For instance, a subset of entities within an entity set may have attributes that are not shared by all the entities in the entity set. Consider an entity set person, with attributes name, street, and city. A person may be further classified as one of the following: customer employee Specialization
32
UNIT_232 Generalization 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. It only differs in the design process. Specialization is a top-down design process, Whereas Generalization is a bottom-up design process. The concept of generalization is similar to inheritance in Java.
33
UNIT_233 Figure :Specialization and generalization
34
UNIT_234 Aggregation A feature of the entity relationship model that allows a relationship set to participate in another relationship set. This is represented in a ER diagram by a diamond shape. For example, an 'Employee' 'works-on' a 'branch‘. An 'Employee' 'manages' some tasks. The 'Works-on' entity here can be abstracted via the use of aggregation.
35
Aggregation Suppose we want to record managers for tasks performed by an employee at a branch
36
UNIT_236 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 Aggregation (Cont.)
37
UNIT_237 Fig:E-R diagram with Aggregation
38
UNIT_238 Attribute Inheritance A crucial property of the higher- and lower-level entities created by specialization and generalization is attribute inheritance. The attributes of the higher-level entity sets are said to be inherited by the lower-level entity sets. For example, customer and employee inherit the attributes of person. Thus, customer is described by its name, street, and city attributes, and additionally a customer-id attribute; employee is described by its name, street, and city attributes, and additionally employee-id and salary attributes. A lower-level entity set (or subclass) also inherits participation in the relationship sets in which its higher-level entity (or superclass) participates.
39
UNIT_239 Constraints on Generalizations To model an enterprise more accurately, the database designer may choose to place certain constraints on a particular generalization. Constraint on which entities can be members of a given lower-level entity set. 1. Condition-defined E.g. all customers over 65 years are members of senior- citizen entity set; senior-citizen ISA person. Constraint on whether or not entities may belong to more than one lower-level entity set within a single generalization 2. User-defined
40
UNIT_240 3. Disjoint An entity can belong to only one lower-level entity set. 4. Overlapping An entity can belong to more than one lower-level entity set. 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
41
UNIT_241 Summary of Symbols Used in E-R Notation
42
UNIT_242 Summary of Symbols (Cont.)
43
UNIT_243 Alternative E-R Notations
44
UNIT_244 Example of E-R Diagram
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.