0% found this document useful (0 votes)
18 views

Lesson 8 Database Management System M5

Uploaded by

lloydcatulin
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

Lesson 8 Database Management System M5

Uploaded by

lloydcatulin
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 15

UNIVERSITY OF SAINT LOUIS

Tuguegarao City

SCHOOL OF ENGINEERING ARCHITECTURE AND


INFORMATION TECHNOLOGY EDUCATION
Second Semester
S.Y. 2020-2021

CORRESPONDENCE LEARNING MODULE


Software Design

Prepared by:

Ceferino Llamelo
Instructor

Reviewed by:

Jay Ventura, MIT


Program Chair/Department Head

Recommended by:

Engr. Ronald Villaverde, ME-ECE, PECE


Academic Dean

Approved by:

Dr. Emmanuel James Pattaguan


VP for Academics

COME 1044 – Software Design | 1


School of Engineering Architecture and Information Technology Education
Computer Engineering Department
Curriculum 2020-2021

CORRESPONDENCE LEARNING MODULE


COME1044 – Software Design

This Weeks’ Time Table:

For this week of this grading period, the following shall be your guide for the different lessons and tasks that
you need to accomplish. Be patient, read it carefully before proceeding to the tasks expected of you.
GOOD LUCK! Have Fun

Date Topics Activities or Tasks


April 26 Database Management System Read the lessons on Database
Basic Concepts of Entity Relationship Model Management System including Entity
ER Diagram Representation Relationship Diagram
Generalization Aggregation

April 27 Relational Data Model Read the lessons on Relational Data


ER Model to Relational Model Model and comply with the Learning
Task
Learning Task

COME 1044 – Software Design | 2


LEARNING MODULE
COME 1044 – Software Design
AY 2020-2021

Lesson 8 - Database Management System

Topic: Database Management System


Basic Concepts of Entity Relationship Model
ER Diagram Representation
Generalization Aggregation
Relation Data Model
ER Model to Relational Model

Learning Outcomes: At the end of this module, you are expected to:

1. Describe the fundamental elements of database management systems


2. Explains the basics of DBMS such as data models, E-R model, relation model, and relational
database design
3. Explain the basic concepts of relational data model and entity-relationship model
4. Apply ER model in a practical system

LEARNING CONTENT

Lesson Proper:

Database Management System


Database Management System or DBMS in short refers to the technology of storing and retrieving usersí
data with utmost efficiency along with appropriate security measures. This tutorial explains the basics of
DBMS such as its architecture, data models, data schemas, data independence, E-R model, relation model,
relational database design, and storage and file structure and much more.
Why to Learn DBMS?
Traditionally, data was organized in file formats. DBMS was a new concept then, and all the research was
done to make it overcome the deficiencies in traditional style of data management. A modern DBMS has the
following characteristics −
 Real-world entity − A modern DBMS is more realistic and uses real-world entities to design its
architecture. It uses the behavior and attributes too. For example, a school database may use
students as an entity and their age as an attribute.
 Relation-based tables − DBMS allows entities and relations among them to form tables. A user can
understand the architecture of a database just by looking at the table names.
 Isolation of data and application − A database system is entirely different than its data. A database
is an active entity, whereas data is said to be passive, on which the database works and organizes.
DBMS also stores metadata, which is data about data, to ease its own process.
 Less redundancy − DBMS follows the rules of normalization, which splits a relation when any of its
attributes is having redundancy in values. Normalization is a mathematically rich and scientific process
that reduces data redundancy.
 Consistency − Consistency is a state where every relation in a database remains consistent. There
exist methods and techniques, which can detect attempt of leaving database in inconsistent state. A
DBMS can provide greater consistency as compared to earlier forms of data storing applications like
file-processing systems.

COME 1044 – Software Design | 3


 Query Language − DBMS is equipped with query language, which makes it more efficient to retrieve
and manipulate data. A user can apply as many and as different filtering options as required to retrieve
a set of data. Traditionally it was not possible where file-processing system was used.
Applications of DBMS
Database is a collection of related data and data is a collection of facts and figures that can be processed to
produce information.
Mostly data represents recordable facts. Data aids in producing information, which is based on facts. For
example, if we have data about marks obtained by all students, we can then conclude about toppers and
average marks.
A database management system stores data in such a way that it becomes easier to retrieve, manipulate,
and produce information. Following are the important characteristics and applications of DBMS.
 ACID Properties − DBMS follows the concepts of Atomicity, Consistency, Isolation, and Durability
(normally shortened as ACID). These concepts are applied on transactions, which manipulate data in
a database. ACID properties help the database stay healthy in multi-transactional environments and in
case of failure.
 Multiuser and Concurrent Access − DBMS supports multi-user environment and allows them to
access and manipulate data in parallel. Though there are restrictions on transactions when users
attempt to handle the same data item, but users are always unaware of them.
 Multiple views − DBMS offers multiple views for different users. A user who is in the Sales department
will have a different view of database than a person working in the Production department. This
feature enables the users to have a concentrate view of the database according to their requirements.
 Security − Features like multiple views offer security to some extent where users are unable to access
data of other users and departments. DBMS offers methods to impose constraints while entering data
into the database and retrieving the same at a later stage. DBMS offers many different levels of
security features, which enables multiple users to have different views with different features. For
example, a user in the Sales department cannot see the data that belongs to the Purchase
department. Additionally, it can also be managed how much data of the Sales department should be
displayed to the user. Since a DBMS is not saved on the disk as traditional file systems, it is very hard
for miscreants to break the code.
Basic Concepts of Entity Relationship 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
 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.
 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.
 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
COME 1044 – Software Design | 4
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.
 Single-value attribute − Single-value attributes contain single value. For example −
Social_Security_Number.
 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.
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.

COME 1044 – Software Design | 5


 Many-to-one − More than one entities 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 Representation
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.

COME 1044 – Software Design | 6


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
instance 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.

COME 1044 – Software Design | 7


 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.

Generalization Aggregation
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.
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.
Generalization
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

COME 1044 – Software Design | 8


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.
Relation Data Model
Relational data model is the primary data model, which is used widely around the world for data storage and
processing. This model is simple and it has all the properties and capabilities required to process data with
storage efficiency.
Concepts
Tables − In relational data model, relations are saved in the format of Tables. This format stores the relation
among entities. A table has rows and columns, where rows represents records and columns represent the
attributes.
Tuple − A single row of a table, which contains a single record for that relation is called a tuple.
Relation instance − A finite set of tuples in the relational database system represents relation instance.
Relation instances do not have duplicate tuples.
Relation schema − A relation schema describes the relation name (table name), attributes, and their names.
Relation key − Each row has one or more attributes, known as relation key, which can identify the row in the
relation (table) uniquely.
Attribute domain − Every attribute has some pre-defined value scope, known as attribute domain.
Constraints
Every relation has some conditions that must hold for it to be a valid relation. These conditions are
called Relational Integrity Constraints. There are three main integrity constraints −
 Key constraints
 Domain constraints
 Referential integrity constraints
Key Constraints
There must be at least one minimal subset of attributes in the relation, which can identify a tuple uniquely.
This minimal subset of attributes is called key for that relation. If there are more than one such minimal
subsets, these are called candidate keys.
Key constraints force that −
 in a relation with a key attribute, no two tuples can have identical values for key attributes.
 a key attribute can not have NULL values.
Key constraints are also referred to as Entity Constraints.
Domain Constraints

COME 1044 – Software Design | 9


Attributes have specific values in real-world scenario. For example, age can only be a positive integer. The
same constraints have been tried to employ on the attributes of a relation. Every attribute is bound to have a
specific range of values. For example, age cannot be less than zero and telephone numbers cannot contain a
digit outside 0-9.
Referential integrity Constraints
Referential integrity constraints work on the concept of Foreign Keys. A foreign key is a key attribute of a
relation that can be referred in other relation.
Referential integrity constraint states that if a relation refers to a key attribute of a different or same relation,
then that key element must exist.
ER Model to Relational Model
ER Model, when conceptualized into diagrams, gives a good overview of entity-relationship, which is easier to
understand. ER diagrams can be mapped to relational schema, that is, it is possible to create relational
schema using ER diagram. We cannot import all the ER constraints into relational model, but an approximate
schema can be generated.
There are several processes and algorithms available to convert ER Diagrams into Relational Schema. Some
of them are automated and some of them are manual. We may focus here on the mapping diagram contents
to relational basics.
ER diagrams mainly comprise of
 Entity and its attributes
 Relationship, which is association among entities.
Mapping Entity
An entity is a real-world object with some attributes.

Mapping Process (Algorithm)


 Create table for each entity.
 Entity's attributes should become fields of tables with their respective data types.
 Declare primary key.
Mapping Relationship
A relationship is an association among entities.

Mapping Process
 Create table for a relationship.
 Add the primary keys of all participating Entities as fields of table with their respective data types.
 If relationship has any attribute, add each attribute as field of table.
 Declare a primary key composing all the primary keys of participating entities.
 Declare all foreign key constraints.
Mapping Weak Entity Sets
A weak entity set is one which does not have any primary key associated with it.

COME 1044 – Software Design | 10


Mapping Process
 Create table for weak entity set.
 Add all its attributes to table as field.
 Add the primary key of identifying entity set.
 Declare all foreign key constraints.
Mapping Hierarchical Entities
ER specialization or generalization comes in the form of hierarchical entity sets.

Mapping Process
 Create tables for all higher-level entities.
 Create tables for lower-level entities.
 Add primary keys of higher-level entities in the table of lower-level entities.
 In lower-level tables, add all other attributes of lower-level entities.
 Declare primary key of higher-level table and the primary key for lower-level table.
 Declare foreign key constraints.
*** END of LESSON 7***

ITEM TEST EVALUATION

Multiple choice: Write your answer on the space provided. Select the best answer that suits the question or
statement

COME 1044 – Software Design | 11


1. He was one of the driving forces behind Britain’s remarkable efforts during World War II to break the codes of the
German Enigma machines.
a) Charles Babbage
b) Lord Byron
c) Augusta Ada Byron
d) Alan Turing

APPLICATION

TITLE:
Entity Relationship diagram
OBJECTIVES:
To draw a sample ENTITY RELATIONSHIP DIAGRAM diagram for real project or system.
ALLOTED TIME: 60 minutes
INSTRUCTION:
1. Create the SRS of the problem statement created in activity 1
THEORY
Entity Relationship Diagrams are a major data modelling tool and will help organize the data in your project
into entities and define the relationships between the entities. This process has proved to enable the analyst
to produce a good database structure so that the data can be stored and retrieved in a most efficient manner.
Entity
A data entity is anything real or abstract about which we want to store data. Entity types fall into five classes:
roles, events, locations, tangible things or concepts. E.g. employee, payment, campus, book. Specific
examples of an entity are called instances. E.g. the employee John Jones, Mary Smith's payment, etc.
Relationship
A data relationship is a natural association that exists between one or more entities. E.g. Employees process
payments. Cardinality defines the number of occurrences of one entity for a single occurrence of the related
entity. E.g. an employee may process many payments but might not process any payments depending on the
nature of her job.
Attribute
A data attribute is a characteristic common to all or most instances of a particular entity. Synonyms include
property, data element, field. E.g. Name, address, Employee Number, pay rate are all attributes of the entity
employee. An attribute or combination of attributes that uniquely identifies one and only one instance of an
entity is called a primary key or identifier. E.g.
Employee Number is a primary key for Employee.
AN ENTITY RELATIONSHIP DIAGRAM METHODOLOGY: (One way of doing it)
Identify the roles, events, locations, tangible things or concepts about
1. Identify Entities which the end-users want to store data.
Find the natural associations between pairs of entities using a
2. Find Relationships relationship
matrix.
Put entities in rectangles and relationships on line segments connecting the
3. Draw Rough ERD entities.
Determine the number of occurrences of one entity for a single
4. Fill in Cardinality occurrence
of the related entity.
Identify the data attribute(s) that uniquely identify one and only one
5. Define Primary Keys
COME 1044 – Software Design | 12
occurrence of each entity.
Eliminate Many-to-Many relationships and include primary and foreign
6. Draw Key-Based ERD keys in each entity.
Name the information details (fields) which are essential to the system
7. Identify Attributes under development.
8. Map Attributes For each attribute, match it with exactly one entity that it
describes.
9. Draw fully attributed ERD Adjust the ERD from step 6 to account for entities or relationships
discovered in step 8.
Does the final Entity Relationship Diagram accurately depict the system
10. Check Results data?

A SIMPLE EXAMPLE
A company has several departments. Each department has a supervisor and at least one employee.
Employees must be assigned to at least one, but possibly more departments. At least one employee is
assigned to a project, but an employee may be on vacation and not assigned to any projects. The important
data fields are the names of the departments, projects, supervisors and employees, as well as the supervisor
and employee number and a unique project number.
1. Identify Entities
The entities in this system are Department, Employee, Supervisor and Project. One is tempted to make
Company an entity, but it is a false entity because it has only one instance in this problem. True entities must
have more than one instance.
2. Find Relationships
We construct the following Entity Relationship Matrix:
Department Employee Supervisor Project
Department is assigned run by
Employee belongs to works on
Supervisor runs
Project uses
3. Draw Rough ERD
We connect the entities whenever a relationship is shown in the entity Relationship Matrix.

COME 1044 – Software Design | 13


4. Fill in Cardinality
From the description of the problem we see that:
 Each department has exactly one supervisor.
 A supervisor is in charge of one and only one department.
 Each department is assigned at least one employee.
 Each employee works for at least one department.
 Each project has at least one employee working on it.
 An employee is assigned to 0 or more projects.

5. Define Primary Keys


The primary keys are Department Name, Supervisor Number, Employee Number, Project Number.
6. Draw Key-Based ERD
There are two many-to-many relationships in the rough ERD above, between Department and Employee and
between Employee and Project. Thus we need the associative entities Department-Employee and Employee-
Project. The primary key for Department-Employee is the concatenated key Department Name and Employee
Number. The primary key for Employee- Project is the concatenated key Employee Number and Project
Number.
7. Identify Attributes
The only attributes indicated are the names of the departments, projects, supervisors and employees, as well
as the supervisor and employee NUMBER and a unique project number.
8. Map Attributes

Attribute Entity Attribute Entity


Department Department Supervisor Supervisor
Name Number
Employee Employee Supervisor Supervisor
Number Name
Employee Employee Project Name Project
Name
Project Project
Number

COME 1044 – Software Design | 14


9. Draw Fully Attributed ERD

10. Check Results


The final ERD appears to model the data in this system well.

REFERENCES

Internet Sites

Software Development Lifer Cycle. Retrieved January 2021 from http://www.tutorialspoint.com

COME 1044 – Software Design | 15

You might also like