Unit2 dbms
Unit2 dbms
SYSTEM
BDA202
Unit-2
Database Design, ER-Diagram, and Unified Modeling Language
INTRODUCTION DATA MODEL
The data model describes the structure of a database.
It is a collection of conceptual tools for describing data, data
relationships and consistency constraints and various types of
data model.
Types of data model:
Entity sets:
An entity is a “thing” or “object” in the real world that is
distinguishable from all other objects.
For example, each person in an enterprise is an entity. An
entity has a set properties and the values for some set of
properties may uniquely identify an entity.
BOOK is entity and its properties(calles as attributes)
bookcode, booktitle, price etc .
An entity set is a set of entities of the same type that share
the same properties, or attributes.
The set of all persons who are customers at a given bank, for
example, can be defined as the entity set customer.
ATTRIBUTES:
An entity is represented by a set of attributes.
Attributes are descriptive properties possessed by each
member of an entity set.
Customer is an entity and its attributes are customerid,
custmername, custaddress etc.
An attribute as used in the E-R model , can be characterized
by the following attribute types.
c) Derived Attribute:
The values for this type of attribute can be derived from the
values of existing attributes, e.g.
age which can be derived from (currentdate-birthdate)
experience_in_year can be calculated as (currentdate-joindate)
Degree of a Relationship
Degree of a relationship is the number of entity types involved.
The n-ary relationship is the general form for degree n.
Special cases are unary, binary, and ternary ,where the degree is 1, 2, and 3, respectively.
Example for unary relationship : An employee is a manager of another employee
Example for binary relationship : An employee works-for department.
Example for ternary relationship : customer purchase item from a shop keeper
Cardinality of a Relationship
Relationship cardinalities specify how many of each entity type is allowed. Relationships can have
four possible
connectivities as given below.
1. One to one (1:1) relationship
2. One to many (1:N) relationship
3. Many to one (M:1) relationship
4. Many to many (M:N) relationship
The minimum and maximum values of this connectivity is called the cardinality of the
relationship
Example for Cardinality – One-to-One (1:1)
Employee is assigned with a parking space.
RELATIONSHIP
A relationship is an association among several entities.
A relationship set is a set of relationships of the same type.
Formally, it is a mathematical relation on n>=2 entity sets.
If E1,E2…En are entity sets, then a relation ship set R is a
subset of
{(e1,e2,…en)|e1 Є E1, e2 Є E2.., en Є En} where (e1,e2,…en)
is a relation ship.
Consider the two entity sets customer and loan. We define the
relationship set borrow to denote the association between
customers and the bank loans that the customers have.
MAPPING CARDINALITIES
Mapping cardinalities or cardinality ratios, express the number
of entities to which another entity can be associated via a
relationship set.
Mapping cardinalities are most useful in describing binary
relationship sets, although they can contribute to the
description of relationship sets that involve more than two
entity sets.
For a binary relationship set R between entity sets A and B, the
mapping cardinalities must be one of the following:
One to One:
An entity in A is associated with at most one entity in B, and
an entity in B is associated with at most one entity in A.
e.g.: relationship between college and principal
CONTD…
One to many:
An entity in A is associated with any number of entities in B.
An entity in B is associated with at the most one entity in A.
e.g.: Relationship between department and faculty
Many to one:
An entity in A is associated with at most one entity in B. An
entity in B is associated with any number in A.
CONTD…
Many-to-Many (M:N):
Students enrolls for courses. One student can enroll for many
courses and one course can be enrolled by many students.
Hence it is a M:N relationship and cardinality is Many-to-Many
(M:N)
RELATIONSHIP PARTICIPATION
1. Total : In total participation, every entity instance will be
connected through the relationship to another instance of the
other participating entity types