Capstone in Interprofessional Informatic // IMPACT OF COVID 19 ON EDUCATION
DBMS Unit 2 ppt.ppt
1. Entity
Entity in DBMS can be a real-world object with an
existence.
For example, in a College database, the entities can be
Professor, Students, Courses, etc.
Entities has attributes, which can be considered as
properties describing it, for example, for Professor
entity, the attributes are Professor_Name,
Professor_Address, Professor_Salary, etc. The
attribute value gets stored in the database.
2. Example of Entity in DBMS
<Professor>
Here, Professor_Name, Professor _Address and
Professor _Salary are attributes.
Professor_ID is the primary key
Professor_ID Professor_Name Professor_City Professor_Salary
P01 Tom Sydney $7000
P02 David Brisbane $4500
P03 Mark Perth $5000
3. Types of Entities
strong entity
The strong entity has a primary key.
Weak entities are dependent on strong entity.
4. Strong Entity
The strong entity has a primary key.
Strong Entity is represented by a single rectangle −
Continuing our previous example, Professor is a strong
entity here, and the primary key is Professor_ID.
Strong
Entity
5. Weak Entity
The weak entity in DBMS do not have a primary key and are
dependent on the parent entity. It mainly depends on other
entities.
Weak Entity is represented by double rectangle −
Weak
entity
Continuing our previous example, Professor is a strong
entity, and the primary key is Professor_ID. However,
another entity is Professor_Dependents, which is our
Weak Entity.
6. Example of Strong and Weak Entity
The example of strong and weak entity can be understood
by the below figure.
The Strong Entity is Professor, whereas Dependent is a
Weak Entity.
ID is the primary key (represented with a line) and Name
in Dependent entity is called Partial Key (represented
with a dotted line).
7. Entity Set
An entity set is a group of similar entities and
these entities can have attributes.
In terms of DBMS, an entity is a table or attribute of a
table in database, so by showing relationship among tables
and their attributes.
ER diagram shows the complete logical structure of a
database.
8. Types of Entity Set
Entity set can be classified into two
categories as shown below:
Strong Entity Set
Weak Entity Set
9. Strong Entity Set
An entity set that has a primary key using which,
entities in the table can be uniquely identified. This
kind of entity set is termed as a strong entity set.
Strong entity set is also known as a regular entity set.
In an ER diagram, the strong entity set is represented
by the rectangle. Here, the primary key is underlined
with the solid line.
10. Weak Entity Sets
A weak entity set doesn’t have any primary key which
can identify each entity in a set distinctly. But, for
discriminating the entities in a set, the weak entity set
is dependent on a particular strong entity set.
A weak entity is also said to be existence dependent as
for the existence of its entities it has to be dependent
on identifying entity set i.e. a particular ‘strong entity
set’. The relation between a weak entity set and a strong
entity set is said to be identifying relationship.
11. Attributes
An attribute is a property or characteristic of an
entity. An entity may contain any number of
attributes. One of the attributes is considered as
the primary key. In an Entity-Relation model,
attributes are represented in an elliptical shape.
Example: Student has attributes like name, age,
roll number and many more. To uniquely
identify the student, we use the primary key as
roll number as it is not repeated. Attributes can
also be subdivided into another set of attributes.
13. 1. Simple Attributes-
Simple attributes are those attributes which can not be
divided further.
Here, all the attributes are simple attributes as they can
not be divided further.
Example
14. 2. Composite Attributes-
Composite attributes are those attributes which are
composed of many other simple attributes.
Here, the attributes “Name” and “Address” are
composite attributes as they are composed of many
other simple attributes.
Example-
15. 3. Single Valued Attributes-
Single valued attributes are those attributes which can
take only one value for a given entity from an entity set.
Here, all the attributes are single valued attributes as they
can take only one specific value for each entity.
Example
16. 4. Multi Valued Attributes
Multi valued attributes are those attributes which can take
more than one value for a given entity from an entity set.
Here, the attributes “Mob_no” and “Email_id” are multi
valued attributes as they can take more than one values for
a given entity.
Example
17. 5. Stored attribute
Stored attribute is an attribute which are
physically stored in the database. Assume a table called as
student. ... We cannot derive value of
these attribute using other attributes. So,
these attributes are called as stored attribute.
Example
18. 5. Derived Attributes
Derived attributes are those attributes which can be derived
from other attribute(s).
Here, the attribute “Age” is a derived attribute as it can be
derived from the attribute “DOB”.
Example
19. 6. Null Value Attribute
An attribute, which has not any value for an entity is
known as null valued attribute. For example, assume
Student is an entity and its attributes are Name, Age,
Address and Phone no. There may be chance when a
student has no phone no. In that case, phone no is
called null valued attributes.
Example
Middle Name
E-Mail ID
20. 7. Key Attributes
Key attributes are those attributes which can identify an
entity uniquely in an entity set.
Here, the attribute “Roll_no” is a key attribute as it can
identify any student uniquely.
Example
21. 8. Complex attributes
The attributes that are formed by arbitrarily nesting the
composite and multivalued attributes are called complex
attributes.
22. Keys in DBMS
A key is a set of attributes that can identify
each tuple uniquely in the given relation.
24. A super key is a set of attributes that can identify each
tuple(row) uniquely in the given relation(table).
A super key is not restricted to have any specific number
of attributes.
Thus, a super key may consist of any number of attributes.
1. Super Key
25. Example
Consider the following Student schema-
Student ( roll , name , age , address , class ,
section )
Given below are the examples of super keys since
each set can uniquely identify each student in the
Student table-
( roll , name , age , address , class , section )
( class , section , roll )
(class , section , roll )
( name , address )
26. 2. Candidate Key
A minimal super key is called as a candidate key.
OR
A set of minimal attribute(s) that can identify each tuple
uniquely in the given relation is called as a candidate key.
Example-
Consider the following Student schema-
Student ( roll , name , age , address , class , section )
Given below are the examples of candidate keys since each
set consists of minimal attributes required to identify each
student uniquely in the Student table-
( class , section , roll )
( name , address )
27. NOTES
All the attributes in a candidate key are sufficient as well
as necessary to identify each tuple uniquely.
Removing any attribute from the candidate key fails in
identifying each tuple uniquely.
The value of candidate key must always be unique.
The value of candidate key can never be NULL.
It is possible to have multiple candidate keys in a relation.
28. 3. Primary Key
A primary key is a candidate key that the database
designer selects while designing the database.
OR
Candidate key that the database designer implements is
called as a primary key.
29. NOTES
The value of primary key can never be NULL.
The value of primary key must always be unique.
The values of primary key can never be changed i.e. no
updation is possible.
The value of primary key must be assigned when inserting
a record.
A relation is allowed to have only one primary key.
30. 4. Alternate Key
Candidate keys that are left unimplemented or unused
after implementing the primary key are called as alternate
keys.
OR
Unimplemented candidate keys are called as alternate
keys.
31. 5. Foreign Key
An attribute ‘X’ is called as a foreign key to some other
attribute ‘Y’ when its values are dependent on the values of
attribute ‘Y’.
The attribute ‘X’ can assume only those values which are
assumed by the attribute ‘Y’.
Here, the relation in which attribute ‘Y’ is present is called
as the referenced relation.
The relation in which attribute ‘X’ is present is called as
the referencing relation.
The attribute ‘Y’ might be present in the same table or in
some other table.
32. NOTES
Foreign key references the primary key of the table.
Foreign key can take only those values which are
present in the primary key of the referenced relation.
Foreign key may have a name other than that of a
primary key.
Foreign key can take the NULL value.
There is no restriction on a foreign key to be unique.
In fact, foreign key is not unique most of the time.
Referenced relation may also be called as the master
table or primary table.
Referencing relation may also be called as the foreign
table.
33. 6. Partial Key
Partial key is a key using which all the records of the table
can not be identified uniquely.
However, a bunch of related tuples can be selected from
the table using the partial key.
34. Example
Consider the following schema-
Department ( Emp_no , Dependent_name , Relation )
Here, using partial key Emp_no, we can not identify a
tuple uniquely but we can select a bunch of tuples from
the table.
35. 7. Composite Key
A primary key comprising of multiple attributes and not
just a single attribute is called as a composite key.
36. 8. Unique Key
Unique key is a key with the following properties-
It is unique for all the records of the table.
Once assigned, its value can not be changed i.e. it is non-
updatable.
It may have a NULL value.
37. Example
The best example of unique key is Adhaar Card
Numbers.
The Adhaar Card Number is unique for all the citizens
(tuples) of India (table).
If it gets lost and another duplicate copy is issued, then the
duplicate copy always has the same number as before.
Thus, it is non-updatable.
Few citizens may not have got their Adhaar cards, so for
them its value is NULL.
38. 9. Surrogate Key
Surrogate key is a key with the following properties-
It is unique for all the records of the table.
It is updatable.
It can not be NULL i.e. it must have some value.
Example-
Mobile Number of students in a class where every student
owns a mobile phone.
39. 10. Secondary Key
Secondary key is required for the indexing purpose for
better and faster searching.
40. Relationships
Any association between two entity types is called a
relationship. Entities take part in the relationship. It is
represented by a diamond shape.
For example, A teacher teaches students. Here,
"teaches" is a relationship and this is the relationship
between a Teacher entity and a Student entity.
41. Degree of relationship type:
The number of entity sets that participate in a
relationship set.
The degree of a relationship is the number of
entity types that participate(associate) in
a relationship.
E-R diagram, we can simply tell the degree of
a relationship i.e the number of an
entity type that is connected to
a relationship is the degree of
that relationship.
45. Constraints on Relationship Types:
Relationship types usually have certain constraints
that limit the possible combination of entity that
may participate in the relationship instance.
Ex: If the company has a rule that each employee
must work for exactly one department. The two
main types of constraints are cardinality ration and
participation constraints.
47. One-to-Many:
An entity of entity set A is associated with two
or more entities of entity set B. However, each
and every entity in entity set B can be
associated with almost one entity in entity set
A.
48. Many-to-One:
An entity of entity set A is associated with
almost one entity of entity set B. However, an
entity of entity set B can be associated with
two or more entities of entity set A.
49. Many-to-Many:
An entity of entity set A is associated with two or
more entities of entity set B. Similarly, an entity of
entity set B is associated with two or more entities of
entity set A.