0% found this document useful (0 votes)
23 views30 pages

Database Management System Lecture 1

Websites for beginners

Uploaded by

upgradedbwire46
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views30 pages

Database Management System Lecture 1

Websites for beginners

Uploaded by

upgradedbwire46
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 30

DATABASE

MANAGEMENT SYSTEM
CS 6261Credit rating: 10

LECTURE II.
Eng.Malissa
malissaemmanuel1@gmail.com
The Entity Relationship
Model
DATABASE DESIGN.
Database design is the process of creating a detailed data model of a database. This
data model contains all the logical and physical design choices and physical storage
parameters needed to generate a design in a data definition language, which can then
be used to create a database.
Simply.
 Database design is the process of planning and organizing
how data will be stored and managed in a database. It's
like creating a blueprint for your data, defining what
information needs to be stored, how it will be structured,
and how different pieces of data relate to each other.
Steps in Database Design
 Requirements Analysis
 user needs; what must database do?
 Conceptual Design
 high level description (often done
with E-R model)
Steps in Database Design
 Logical Design
 translate ER into DBMS data model
 Schema Refinement
 consistency, normalization
 Physical Design - indexes, disk layout
 Security Design - who accesses what, and
how
ER Model
 The ER model defines the conceptual view of a
database.
 It works around real-world entities and the
associations among them.
 At view level, the ER model is considered a good
option for designing databases.
Entity.
An entity can be a real-world object, either animate or inanimate, that can be
easily identifiable.
For example, in a school database, students, teachers, classes, and courses offered
can be considered as entities. All these entities have some attributes or properties
that give them their identity.
An entity set is a collection of similar types of entities. An entity set may
contain entities with attribute sharing similar values. For example, a students set
may contain all the students of a school; likewise a Teachers set may contain all
the teachers of a school from all faculties. Entity sets need not be disjoint.
Attributes.
Entities are represented by means of their properties,
called attributes. All attributes have values.
For example, a student entity may have name, class, and age as
attributes.
There exists a domain or range of values that can be assigned
to attributes.
For example, a student's name cannot be a numeric value. It has to
be alphabetic. A student's age cannot be negative, etc.
Types of Attributes
1. Simple attribute − Simple attributes are atomic values, which cannot be
divided further. For example, a student's phone number is an atomic value of 10
digits.
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, average_salary in a department should not be saved
directly in the database, instead it can be derived. For another example, age can
be derived from data_of_birth.
4. Single-value attribute − Single-value attributes contain single value. For
example − Social_Security_Number.
5. Multi-value attribute − multi-value attributes may contain more than one
values. For example, a person can have more than one phone number,
These attribute types can come together in a way like.

simple single-valued attributes


simple multi-valued attributes
composite single-valued attributes
composite multi-valued attributes
Entity-Set and Keys.
Key is an attribute or collection of attributes that uniquely identifies an entity
among entity set.
For example, the roll_number of a student makes him/her identifiable among
students.
 Super Key − A set of attributes (one or more) that collectively identifies an
entity in an entity set.
 Candidate Key − A minimal super key is called a candidate key. An entity set
may have more than one candidate key.
 Primary Key − A primary key is one of the candidate keys chosen by the
database designer to uniquely identify the entity set.
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
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.
 One-to-one − One entity from entity set A can be associated with at most one entity of entity set B and
vice versa.

• One-to-many − One entity from entity set A can be associated with more than one entities of entity set
B however an entity from entity set B, can be associated with at most one entity.
 Many-to-one − More than one entity from entity set A can be associated with at most one entity of entity
set B, however an entity from entity set B can be associated with more than one entity from entity set A.

 Many-to-many − One entity from A can be associated with more than one entity from B and vice versa.
ER diagram.
 Let us now learn how the ER Model is represented by means
of an ER diagram. Any object, for example, entities, attributes
of an entity, relationship sets, and attributes of relationship
sets, can be represented with the help of an ER diagram.
Entity.
Entities are represented by means of rectangles. Rectangles are
named with the entity set they represent.
Attributes.
 Attributes are the properties of entities. Attributes are represented by means of
ellipses. Every ellipse represents one attribute and is directly connected to its entity
(rectangle).

 If the attributes are composite, they are further divided in a tree like structure. Every
node is then connected to its attribute. That is, composite attributes are represented
by ellipses that are connected with an ellipse.
Multivalued attributes are depicted by double ellipse.

 Derived attributes are depicted by dashed ellipse.


Relationship
Relationships are represented by diamond-shaped box. Name of the relationship is written inside
the diamond-box. All the entities (rectangles) participating in a relationship, are connected to it by a
line.
Binary Relationship and Cardinality
A relationship where two entities are participating is called a binary relationship. Cardinality is the
number of instances of an entity from a relation that can be associated with the relation.
 One-to-one − When only one instance of an entity is associated with the relationship, it is
marked as '1:1'. The following image reflects that only one instance of each entity should be
associated with the relationship. It depicts one-to-one relationship.
 One-to-many − When more than one instance of an entity is associated with a relationship, it is marked
as '1:N'. The following image reflects that only one instance of entity on the left and more than one
instance of an entity on the right can be associated with the relationship. It depicts one-to-many
relationship.

 Many-to-one − When more than one instance of entity is associated with the relationship, it is marked
as 'N:1'. The following image reflects that more than one instance of an entity on the left and only one
instance of an entity on the right can be associated with the relationship. It depicts many-to-one
relationship.

 Many-to-many − The following image reflects that more than one instance of an entity on the left and
more than one instance of an entity on the right can be associated with the relationship. It depicts many-
to-many relationship.
Participation Constraints.
 Total Participation − Each entity is involved in the relationship. Total participation is represented by
double lines.
 Partial participation − Not all entities are involved in the relationship. Partial participation is
represented by single lines.

The ER Model has the power of expressing database entities in a conceptual hierarchical manner. As the
hierarchy goes up, it generalizes the view of entities, and as we go deep in the hierarchy, it gives us the detail
of every entity included.
Generalization
Going up in this structure is called generalization, where entities are clubbed together to represent a more
generalized view. For example, a particular student named Mira can be generalized along with all the students.
The entity shall be a student, and further, the student is a person. The reverse is called specialization where a
person is a student, and that student is Mira.
As mentioned above, the process of generalizing entities, where the generalized entities contain the properties
of all the generalized entities is called generalization. In generalization, a number of entities are brought
together into one generalized entity based on their similar characteristics. For example, pigeon, house sparrow,
crow and dove can all be generalized as Birds.
Specialization.
Specialization is the opposite of generalization. In specialization, a group of entities is divided
into sub-groups based on their characteristics. Take a group ‘Person’ for example. A person has
name, date of birth, gender, etc. These properties are common in all persons, human beings. But
in a company, persons can be identified as employee, employer, customer, or vendor, based on
what role they play in the company.

Similarly, in a school database, persons can be specialized as teacher, student, or a staff, based on
what role they play in school as entities.
Inheritance.
We use all the above features of ER-Model in order to create classes of objects in object-oriented
programming. The details of entities are generally hidden from the user; this process known
as abstraction.
Inheritance is an important feature of Generalization and Specialization. It allows lower-level entities to
inherit the attributes of higher-level entities.

For example, the attributes of a Person class such as name, age, and gender can be inherited by lower-level entities
such as Student or Teacher.
Example:
The set of entities STUDENTS of the college database has the attributes
student identification number (stno), student name (name), street address
(addr), city (city), state of residence (state), zip code (zip). The student
Edwards P. David, who lives at 10 Red Rd. in Newton, MA, 02129, has been
assigned ID number 1011. The values of his attributes are:
We assume that domains of attributes consist of atomic values. This means that
the elements of such domains must be “simple” values such as integers, dates, or
strings of characters. If e is an entity and A is an attribute of that entity, then the
value of the domain of A is denoted by A(e) that the attribute associates with the
entity e.
Similarly, when r is a relationship, the value associated by an attribute B to r is
denoted by B(r). For example, if s is a student entity, then the values associated
to s are denoted by

stno(s), name(s), addr(s), city(s), state(s), zip(s).

Dom(name) is the set of all possible names for students. Dom(name) is defined
as the set of all strings of length less or equal to a certain length n.
Attributes of Sets of Entities
Attributes of Sets of Relationships

 If several sets of entities that occur in the same context each have an
attribute A, we qualify the attribute with the name of the entity set to be
able to differentiate between these attributes. For example, because both
STUDENTS and INSTRUCTORS have the attribute name, we use the
qualified attributes STUDENTS.name and INSTRUCTORS.name.
Attributes of relationships may either be attributes of the entities they
relate, or be new attributes, specific to the relationship.
The E/R Diagram of the College Database
END.

You might also like