2 UnitII DBMS
2 UnitII DBMS
• E1
• Attribute(s):
Attributes are the properties which define the entity type.
• For example, Roll_No, Name, DOB, Age, Address, Mobile_No are the attributes
which defines entity type Student.
• In ER diagram, attribute is represented by an oval.
• 1. Key Attribute –
The attribute which uniquely identifies each entity in the entity set is called key
attribute.
• For example, Roll_No will be unique for each student. In ER diagram, key
attribute is represented by an oval with underlying lines.
• 2. Composite Attribute –
An attribute composed of many other attribute is called as composite attribute.
For example, Address attribute of student Entity type consists of Street, City,
State, and Country. In ER diagram, composite attribute is represented by an oval
comprising of ovals.
• Multivalued Attribute –
An attribute consisting of more than one value for a given entity.
• For example, Phone_No (can be more than one for a given student). In ER
diagram, multivalued attribute is represented by double oval.
• 4. Derived Attribute –
An attribute which can be derived from other attributes of the entity type is
known as derived attribute. e.g.; Age (can be derived from DOB). In ER diagram,
derived attribute is represented by dashed oval.
• The complete entity type Student with its attributes can be represented as:
•
• Data association between entities
• A relationship type represents the association between entity types.
• For example,‘Enrolled in’ is a relationship type that exists between entity type
Student and Course.
• In ER diagram, relationship type is represented by a diamond and connecting the
entities with lines.
•
•
• A set of relationships of same type is known as relationship set. The following
relationship set depicts S1 is enrolled in C2, S2 is enrolled in C1 and S3 is enrolled
in C3.
•
• Degree of a relationship set:
The number of different entity sets participating in a relationship set is called as
degree of a relationship set.
• 1. Unary Relationship –
When there is only ONE entity set participating in a relation, the relationship is
called as unary relationship. For example, one person is married to only one
person.
•
• 2. Binary Relationship –
When there are TWO entities set participating in a relation, the relationship is
called as binary relationship.For example, Student is enrolled in Course.
• 3. n-ary Relationship –
When there are n entities set participating in a relation, the relationship is called
as n-ary relationship.
• Data Model
• Data Model gives us an idea that how the final system will look like after its
complete implementation.
• It defines the data elements and the relationships between the data elements.
• Data Models are used to show how data is stored, connected, accessed and
updated in the database management system.
• Hierarchical Model
• Network Model
• Entity-Relationship Model
• Relational Model
• Object-Oriented Data Model
• Hierarchical Model
• Hierarchical Model was the first DBMS model.
• The hierarchy starts from the root which has root data and then it expands in
the form of a tree adding child node to the parent node.
• This model easily represents some of the real-world relationships like food
recipes, sitemap of a website.
• This model easily represents some of the real-world relationships like food
recipes, sitemap of a website etc.
• Parent-Child Relationship:
• Each child node has one parent node but a parent node can have more than one
child node.
• Multiple parents are not allowed.
• Deletion Problem:
• If a parent node is deleted then the child node is automatically deleted.
• Pointers:
• Pointers are used to link the parent node with the child node and are used to
navigate between the stored data.
• Example: In the above example the 'shoes' node points to the two other nodes
'women shoes' node and 'men's shoes' node.
• Network Model
• This model is an extension of the hierarchical model.
• This model is the same as the hierarchical model, the only difference is that a
record can have more than one parent.
• Many paths:
• As there are more relationships so there can be more than one path to the
same record.
• This makes data access fast and simple.
• Circular Linked List: The operations on the network model are done with the
help of the circular linked list.
• Entity-Relationship Model
• Entity-Relationship Model or simply ER Model is a high-level data model
diagram.
• It is also very easy for the developers to understand the system by just looking
at the ER diagram.
• Attributes:
• An entity contains a real-world property called attribute. This is the
characteristics of that attribute.
• Example: The entity teacher has the property like teacher id, salary, age, etc.
• Relationship type:
• Relationship type tells how two entities are related.
• Example: Teacher works for a department.
• In the below diagram, the entities are Teacher and Department. The attributes
of Teacher entity are Teacher_Name, Teacher_id, Age, Salary, Mobile_Number.
• The attributes of entity Department entity are Dept_id, Dept_name. The two
entities are connected using the relationship.
• Here, each teacher works for a department.
• Features of ER Model
• Graphical Representation for Better Understanding:
• It is very easy and simple to understand so it can be used by the developers to
communicate with the end users.
• ER Diagram:
• ER diagram is used as a visual tool for representing the model.
• Database Design:
• This model helps the database designers to build the database and is widely
used in database design.
• Relational Model
• Relational Model is the most widely used model.
• In this model, the data is maintained in the form of a two-dimensional table.
• All the information is stored in the form of row and columns.
• The basic structure of a relational model is tables. So, the tables are also
called relations in the relational model.
• Example: In this example, we have an Employee table.
• Features of Relational Model
• Tuples:
• Each row in the table is called tuple.
• A row contains all the information about any instance of the object.
• In the above example, each row has all the information about any specific
individual like the first row has information about John.
• Attribute or field:
• Each column in the table is called attribute or field.
• Attributes are the property which defines the table or relation.
• In the above example, we have different attributes of the employee like Salary,
Mobile_no.
• Object-Oriented Data Model
• The real-world problems are more closely represented through the object-
oriented data model.
• In this model, both the data and relationship are present in a single structure
known as an object.
• We can store audio, video, images, etc in the database which was not possible
in the relational model.
• In this ER diagram, both entities customer and driving license having an arrow
which means the entity Customer is participating in the relation “has a” in a one-
to-one fashion. It could be read as ‘Each customer has exactly one driving license
and every driving license is associated with exactly one customer.
• 2. One to many relationship (1:M) :
• This relationship is one to many because “There are some employees who
manage more than one team while there is only one manager to manage a
team”.
• Any number of credit cards can belong to a customer and there might be some
customers who do not have any credit card, but every credit card in a system has
to be associated with an employee(i.e. total participation). While a single credit
card can not belong to multiple customers.
• Example: