DBMS U2
DBMS U2
DBMS U2
Unit-2
2. Composite attribute − Composite attributes are made of more than one simple attribute.
For example, a student's complete name may have first_name and last_name.
3. Derived attribute − Derived attributes are the attributes that do not exist in the physical
database, but their values are derived from other attributes present in the database. For
example, age can be derived from data_of_birth.
5. Multi-value attribute − Multi-value attributes may contain more than one values. For
example, a person can have more than one phone number, email_address, etc.
Relationship
• The association among entities is called a relationship. For example, an employee
works_at a department, a student enrolls in a course. Here, Works_at and Enrolls
are called relationships.
Relationship Set
• A set of relationships of similar type is called a relationship set. Like entities, a
relationship too can have attributes. These attributes are called descriptive
attributes.
Degree of Relationship
• The number of participating entities in a relationship defines the degree of the
relationship.
• Binary = degree 2
• Ternary = degree 3
• n-ary = degree
1. Unary relationship -
2. Binary relationship -
Mapping Cardinalities
Cardinality defines the number of entities in one entity set, which
can be associated with the number of entities of other set via
relationship set.
Total Participation – Each entity in the entity set must participate in the
relationship. If each student must enroll in a course, the participation of student
will be total. Total participation is shown by double line in ER diagram.
Partial Participation – The entity in the entity set may or may NOT participate in
the relationship. If some courses are not enrolled by any of the student, the
participation of course will be partial.
The diagram depicts the ‘Enrolled in’ relationship set with Student Entity set
having total participation and Course Entity set having partial participation.
Concept of Keys
• KEYS in DBMS is an attribute or set of attributes which helps you to
identify a row(tuple) in a relation(table).
• A superkey is a group of single or multiple keys which identifies rows
in a table. A Super key may have additional attributes that are not
needed for unique identification. For eg. rollno + enrollno
• A Primary key is a column or group of columns in a table that
uniquely identify every row in that table. The Primary Key can't be a
duplicate meaning the same value can't appear more than once in the
table. For eg. Emp_code
• A Candidate Key is a set of attributes that uniquely identify tuples in
a table. Candidate Key is a super key with no repeated attributes.For
eg. Stud ID, Roll No, and email are candidate key
• An Alternet key is a column or group of columns in a table that
uniquely identify every row in that table. All the keys which are not
primary key are called an Alternate Key. For eg. Person_name &
Mobile.
• A Foreign key is a column that creates a relationship between two
tables. The purpose of Foreign keys is to maintain data integrity and
allow navigation between two different instances of an entity. It is a
field/column in the table that is the primary key of another table.For
eg. It_code is a primary key for Stock table which is a foreign key for
Sales table.
• A key which has multiple attributes to uniquely identify rows in a
table is called a composite key. For eg. Person_name & Mobile.
Strong & Weak Entity set
Strong Entity:
A strong entity is not dependent of any other entity in the relation. A strong
entity will always have a primary key. Strong entities are represented by a single
rectangle. The relationship of two strong entities is represented by a single
diamond.
Weak Entity:
A weak entity is dependent on a strong entity to ensure its existence. Unlike a
strong entity, a weak entity does not have any primary key. It instead has a
partial discriminator key. A weak entity is represented by a double rectangle.
The relation between one strong and one weak entity is represented by a
double diamond.
Generalization
• Generalization is a bottom-up approach in which two lower level
entities combine to form a higher level entity.
Specialization
• It is a top-down approach in which one higher level entity can be broken
down into two lower level entity.
Aggregation
• Aggregration is a process when relation between two entities is
treated as a single entity
Converting E-R model to relation schema
Converting E-R model to relation schema
Object: An object is a real world entity. There are many objects present
within a single system. It is a fundamental building block of UML.
Class: A class is a software blueprint for objects, which means that it defines
the variables and methods common to all the objects of a particular type.
Abstraction: Abstraction is the process of depicting the essential
characteristics of an object to the users while hiding the irrelevant
information. Basically, it is used to imagine the functioning of an object.
Inheritance: Inheritance is the process of deriving a new class from the
existing ones.
Polymorphism: It is a mechanism of representing objects having multiple
forms used for different purposes.
Encapsulation: It binds the data and the object together as a single unit,
enabling tight coupling between them.