DBMS Module 2 SEE
DBMS Module 2 SEE
Specialization
Specialization is the process of defining a set of subclasses of an entity type; this entity type is
called the superclass of the specialization. The set of subclasses that forms a specialization is
defined on the basis of some distinguishing characteristic of the entities in the superclass.
We may have several specializations of the same entity type based on different distinguishing
characteristics. For example, another specialization of the EMPLOYEE entity type may yield the
set of subclasses {SALARIED_EMPLOYEE, HOURLY_EMPLOYEE}; this specialization distinguishes
among employees based on the method of pay. Figure 8.1shows how we represent a
specialization diagrammatically in an EER diagram.The subclasses that define a specialization
are attached by lines to a circle that represents the specialization, which is connected in turn
to the superclass. The subset symbol on each line connecting a subclass to the circle indicates
the direction of the superclass/subclass relationship.5 Attributes that apply only to entities of
a particular subclass—such as TypingSpeed of SECRETARY—are attached to the rectangle
representing that subclass. These are called specific attributes (or local attributes) of the
subclass.
In summary, the specialization process allows us to do the following:
Generalization
We can think of a reverse process of abstraction in which we suppress the differences among
several entity types, identify their common features, and generalize them into a single
superclass of which the original entity types are special subclasses.
For example, consider the entity types CAR and TRUCK shown in Figure 8.3(a).Because they
have several common attributes, they can be generalized into the entity type VEHICLE, as
shown in Figure 8.3(b).Both CAR and TRUCK are now subclasses of the generalized superclass
VEHICLE. We use the term generalization to refer to the process of defining a generalized
entity type from the given entity types. Notice that the generalization process can be viewed
as being functionally the inverse of the specialization process. Hence, in Figure 8.3 we can view
{CAR, TRUCK} as a specialization of VEHICLE, rather than viewing VEHICLE as a generalization of
CAR and TRUCK. Similarly, in Figure 8.1 we can view EMPLOYEE as a generalization of
SECRETARY, TECHNICIAN,and ENGINEER.A diagrammatic notation to distinguish between
generalization and specialization is used in some design methodologies. An arrow pointing to
the generalized superclass represents a generalization, whereas arrows pointing to the
specialized subclasses represent a specialization. We will not use this notation because the
decision as to which process is followed in a particular situation is often subjective.
2. Explain ER diagram, naming conversion and design issues.
Ans:
Refer TB Page no 80 nd 81
A ternary relationship such as SUPPLY must be represented as weak entity type, with no
partial key and with three identifying relationships.
The three participating entity types SUPPLIER,PART, and PROJECT are together the
owner entity types(see figure (c)).
The ternary relationship type OFFERS in the above figure represents information on
instructors offering courses during particular semesters, hence it includes a relationship
instance (i,s,c) whenever INSTRUCTOR i offers COURSE c during SEMESTER s.
The three binary relationship types shown in above figure have the following meanings:
CAN_TEACH relates a course to the instructors who can teach that course,
TAUGHT_DURING relates a semester to the instructors who taught some courses
offered during that semester, and OFFERED_DURING relates a semester to the courses
offered during that semester by any instructor.
Her ,a 1,M, or N is specified on each participation arc( both M and N symbols stand for
many or any number).
We place 1 on the SUPPLIER participation, and M,N on the PROJECT,PART participations
in below figure.
This specifies the constraint that a particular (j,p) combination can appear at most once
in the relationship set because each such (PROJECT,PART) combination uniquely
determines a single supplier.
Hence, any relationship instance (s,j,p) is uniquely identified in the relationship set by its
(j,p) combination, which makes (j,p) a key for the relationship set.
(min,max) notation for binary relationships
A (min,max) on a participation here specifies that each entity is related to at least min
and at most max relationship instances in the relationship set.
These constraints have no bearing on determining the key of an n-ary relationship,
where n>2, but specify a different type of constraint that places restrictions on how
many relationship instances each entity can participate in.
4. Explain the characteristics of relation.
Ans:
The order of attributes and their values is not that important as long as the correspondence
between attributes and values is maintained. An alternative definition of a relation can be
given, making the ordering of values in a tuple unnecessary. In this definition A relation
schema R(A1, A2, ...,An), set of attributes and a relation state r(R) is a finite set of mappings r =
{t1, t2, ..., tm}, where each tuple ti is a mapping from R to D. According to this definition of
tuple as a mapping, a tuple can be considered as a set of (<attribute>, <value>) pairs, where
each pair gives the value of the mapping from an attribute Ai to a value vi from dom(Ai) .The
ordering of attributes is not important, because the attribute name appears with its value.
Each value in a tuple is atomic. NULL values are used to represent the values of attributes that
may be unknown or may not apply to a tuple. For example some STUDENT tuples have NULL
for their office phones because they do not have an office .Another student has a NULL for
home phone In general, we can have several meanings for NULL values, such as value
unknown, value exists but is not available, or attribute does not apply to this tuple (also known
as value undefined).
The relation schema can be interpreted as a declaration or a type of assertion. For example,
the schema of the STUDENT relation of asserts that, in general, a student entity has a Name,
Ssn, Home_phone, Address, Office_phone, Age, and Gpa. Each tuple in the relation can then
be interpreted as a particular instance of the assertion.For example, the first tuple asserts the
fact that there is a STUDENT whose Name is Benjamin Bayer, Ssn is 305-61-2435, Age is 19,
and so on.
5. Explain Insert, delete and update operation.
Ans:
The Insert Operation
INSERT may violate any of the four types of constraints:
Domain constraint:
If one of the attribute values provided for the new tuple is not of the specified attribute
domain.
Key constraint:
If the value of a key attribute in the new tuple already exists in another tuple in the relation.
Referential integrity:
If a foreign key value in the new tuple references a primary key value that does not exist in
the referenced relation.
Entity integrity:
Example:-
Operation:
Operation:
Operation:
If the primary key value of the tuple being deleted is referenced from other tuples in the
database. Can be remedied by several actions: RESTRICT, CASCADE, SET NULL. RESTRICT
option: reject the deletion.CASCADE option: propagate deletion by deleting tuples that
reference the tuple that is deleted.SET NULL option: set the foreign keys of the referencing
tuples to NULL.One of the above options must be specified during database design for each
foreign key constraint.
Example:
Operation
Operation
Operation
modified. Any of the other constraints may also be violated, depending on the attribute being
updated:
Operation
Result: Acceptable.
Operation
Operation
The SELECT Operation denoted by sigma is used to select a subset of the tuples from a relation
based on a selection condition. The selection condition acts as a filter that keeps only those
tuples that satisfy a qualifying condition. Alternatively, we can consider the SELECT operation
to restrict the tuples in a relation to only those tuples that satisfy the condition.
The SELECT operation can also be visualized as a horizontal partition of the relation into two
sets of tuples those tuples that satisfy the condition and are selected, and those tuples that do
not satisfy the condition and are discarded.
<selection condition>(R)
where,
- tuples that make the condition true are selected appear in the result of the operation
- tuples that make the condition false are filtered out discarded from the result of the
operation.
or
where
Clauses can be connected by the standard Boolean operators and, or, and not to form a
general selection condition
Examples:
DNO = 4 (EMPLOYEE).
- (cond1 AND cond2) is TRUE if both (cond1) and (cond2) are TRUE; otherwise,it is FALSE.
- (cond1 OR cond2) is TRUE if either (cond1) or (cond2) or both are TRUE; otherwise, it is
FALSE.
Hence, a sequence of SELECTs can be applied in any order.we can always combine a cascade
(or sequence) of SELECT operations into a single SELECT operation with a conjunctive (AND)
In SQL, the SELECT condition is specified in the WHERE clause of a query.For example, the
following operation:
The PROJECT operation denoted by selects certain columns from the table and discards the
other columns Used when we are interested in only certain attributes of a relation. The result
of the PROJECT operation can be visualized as a vertical partition of the relation into two
relations:
- one has the needed columns (attributes) and contains the result of the operation.
<attribute list>(R)
where
The result of the PROJECT operation has only the attributes specified in <attribute list> in the
same order as they appear in the list. Hence, its degree is equal to the number of attributes in
<attribute list>.
Example:
1. To list each employee's first and last name and salary we can use the PROJECT operation as
follows:
If the attribute list includes only non key attributes of R, duplicate tuples are likely occur. The
result of the PROJECT operation is of distinct tuples, and hence a valid relation. This is known.
duplicate elimination. For example, consider the following PROJECT operation:
The number of tuples in a relation resulting from a PROJECT operation is always less than or
equal to the number of tuples in R. Commutativity does not hold on PROJECT
as long as <list2> contains the attributes in <list1>; otherwise, the left-hand side is an
incorrect expression.
In SQL, the PROJECT attribute list is specified in the SELECT clause of a query. For example, the
following operation:
Example: Consider the the following two relations: STUDENT & INSTRUCTOR.
Single relational algebra expression:
UNION, INTERSECTION and SET DIFFERENCE are binary operations; that is, each is applied to
two sets (of tuples). When these operations are adapted to relational databases, the two
relations on which any of these three operations are applied must have the same type of
tuples; this condition has been called union compatibility or type compatibility.
Two relations R(A1, A2, ..., An) and S(B1, B2, ..., Bn) are said to be union compatible (or type
compatible) if they have the same degree n and if dom(Ai) = dom(Bi the two relations have the
same number of attributes and each corresponding pair of attributes has the same domain.
RUS = S U R and R ∩ S = S ∩ R
Both UNION and INTERSECTION can be treated as n-ary operations applicable to any number
of relations because both are also associative operations; that is,
R U (S U T) = (R U S) U T and (R∩ S∩ T = R∩ S∩ T )
R- S= S- R
In SQL, there are three operations UNION, INTERSECT, and EXCEPT that correspond to the
set operations.
Refer from TB