dbmsch-2
TRANSCRIPT
-
8/3/2019 DBMSCH-2
1/16
CHAPTER-2
ENTITY RELATIONSHIPS
-
8/3/2019 DBMSCH-2
2/16
ENTITY
An entity is a real-world item or concept that exists on its own. Theset of all possible values for an entity is the entity type.
In our example, a particular student (such as, Ram"), team,
lab section, or experiment is an entity.
The set of all possible values for an entity, such as all possiblestudents, is the entity type.
In an ER model, we diagram an entity type as a rectangle
containing the type name, such asstudent
(see Figure 1).
-
8/3/2019 DBMSCH-2
3/16
-
8/3/2019 DBMSCH-2
4/16
-
8/3/2019 DBMSCH-2
5/16
ER Model.
This data model is based on real world thatconsists of basic objects called entities and ofrelationship among these objects.
Entities are described in a database by a set ofattributes.
-
8/3/2019 DBMSCH-2
6/16
Attribute
An attribute of an entity is a particular property that describes the entity. The setof all possible values of an attribute is the attribute domain.
Each entity has attributes, or particular properties that describe the entity.
The set of all possible values of an attribute, such as integers from 0 to 100 forgrade is the attribute domain.
In an ER model, an attribute name appears in an oval that has a line to thecorresponding entity box, shown in figure 2.
ER diagram notation for an attribute domain (Student Grade) of an entity type
(student)
-
8/3/2019 DBMSCH-2
7/16
-
8/3/2019 DBMSCH-2
8/16
A simple attribute is one component that is atomic. A composite attribute has
multiple components, each of which is atomic or composite.
A composite attribute, such as RAM VYAS", has multiplecomponents, suchas RAM" and "VYAS"; and each component is atomic or composite. We
illustrate this composite nature in the ER model by branching off the
component attributes, such as in Figure 3.
ER diagram notation for composite attribute domain,
name
-
8/3/2019 DBMSCH-2
9/16
A derived attribute can be obtained from other attributes or related entities. For
example, the radius of a sphere can be determined from the circumference.
We request the derived attribute with a dotted oval and line, such as in Figure 5.
Figure 6. ER diagram notation for derived attribute, radius
-
8/3/2019 DBMSCH-2
10/16
ER Modeling Symbols.
-
8/3/2019 DBMSCH-2
11/16
-
8/3/2019 DBMSCH-2
12/16
Sub class Specialization.
As you are developing a class diagram, you might discover that one ormore attributes of a class are characteristics of only someindividuals ofthat class, but not of others. This probably indicates that you need todevelop a subclass of the basic class type.
We call the process of designing subclasses from top downspecialization; a class that represents a subset of another class typecan also be called a specialization of its parent class.
Example:we will model the graduate students at a university. Some are
employed by the university as teaching associates (TAs); some are employed as
research associates (RAs); some are not employed by the university at all.
-
8/3/2019 DBMSCH-2
13/16
Sub class Specialization continues..
Two specialized classes of students: TAs and RAs. The UMLsymbol for subclass association is an open arrowhead thatpoints to the parent class.
-
8/3/2019 DBMSCH-2
14/16
Generalization
The reverse of the specialization process
Several classes with common features are generalizedinto a superclass; original classes become itssubclasses
Example: CAR, TRUCK generalized into VEHICLE; bothCAR, TRUCK become subclasses of the superclassVEHICLE.
We can view {CAR, TRUCK} as a specialization ofVEHICLE
Alternatively, we can view VEHICLE as ageneralization of CAR and TRUCK
-
8/3/2019 DBMSCH-2
15/16
Superclass Generalization
Bottom up design
Sometimes, instead of finding unique attributes in a single class type, you mightfind two or more classes that have many of the sameattributes. This probably
indicates that you need to develop a superclass of the classes with commonattributes
We call the process of designing subclasses from bottom up generalization; aclass or entity that represents a superset of other class types can also be called a
generalization of the child types.
Example.It seemed as if there were two class types:
-
8/3/2019 DBMSCH-2
16/16
Superclass Generalization continues..
Actually, a few of the lots were identified by both address schemes. The common
attributes should go in a generalization or superclass that is simply called a lot.
The relation scheme is identical in structure to the previous example