Fundamentals of Database System Note Unit 1-4 PDF
Fundamentals of Database System Note Unit 1-4 PDF
DMU
UNIT ONE
Introduction
Data, information, information System
Data: is a collection of raw facts.
Information: is a processed data in the form that is meaningful to the user.
Information System is a system that:
Receives data and instruction
Processes the data as per the instruction
Produces output
Stores data/information for future use
Information System and Organization, Database system
Information System doesnt exist without organization. That is, organization of data is necessary if data is
voluminous. Information System is a support system for the organizational activity to achieve a certain
goal.
A database system is basically a computerized record keeping system. Users of the database can perform a
variety of operations. Such as:
Adding new data to empty file
Adding new data to existing file
Retrieving data from existing file
Modifying data to existing file
Deleting data from existing file
Searching for target information
Department of IT
Page 1
DMU
In the manual data handling approach, data storage and retrieval follows the primitive and traditional way
of data/information handling where cards and paper are used for the purpose. Typing the data on paper and
put in a file cabinet. The data storage and retrieval will be performed using human labour. This approach
Works well if the number of items to be stored is small.
Limitations of the Manual approach
Prone to error
Data loss: due to damaged papers or unable to locate it.
Redundancy: multiple copies of the same data within the organization.
Inconsistency: Modifications are not reflected on all multiple copies
Difficult to update, retrieve, integrate
You have the data but it is difficult to compile the information
Limited to small size information
Cross referencing is difficult
An alternative approach of data handling is a computerized way of dealing with the information. The
computerized approach could also be either decentralized or centralized base on where the data resides in
the system.
2. File based Approach
After the introduction of computer for data processing to the business community, the need to use the
device for data storage and processing increase. File based data handling approaches were an early attempt
to computerize the manual filing system. There were, and still are, several computer applications with file
based processing used for the purpose of data handling. It is a collection of application programs that
performs services for the end users. In such systems, every application program that provides service to end
users define and manage its own data. Such systems have number of programs for each of the different
applications in the organization. And this approach is the decentralized computerized data handling
method.
Department of IT
Page 2
DMU
When data is isolated in separate files, it is difficult to access data that should be available. This is because;
there is no concept of relationship between files. Therefore, we need to create a temporary file for the
participating files.
Duplication of data (Redundancy)
This is concerning with storage of similar information in multiple files.
The following are some of the disadvantage of redundancy:
It costs time and money to enter the data
It takes up additional storage space (memory space)
Inconsistency: this is loss of data integrity. For instance, if modification in the child table is unable
to be reflected on the parent table.
Data Dependence
Changes to an existing structure are difficult to make. Example: change in the size of Student Name (from
20 characters to 30 characters) requires a new program to convert student file to a new format. The new
program opens original student file, open a temporary file, read records from original student file and write
to the temporary file, delete the original student file and finally rename the temporary file as student file. It
is time consuming and Prone to error.
Incompatible file formats
The structure of file is dependent on the application programs. Incompatibility of files makes them difficult
to process jointly. Example: consider two files with in the same enterprise but in different departments, or
in different branches: If the first file is constructed using COBOL and the second file is written using C++,
then there will be a problem of integrity.
3. Database Approach
What is a Database?
A database is a collection of related data in an organized way. Most of the time, organization is in tabular
form. E.g. book database
The organization of the database becomes necessary when the data is voluminous. Otherwise, managing
data will be very difficult.
Department of IT
Page 3
DMU
Department of IT
Page 4
Department of IT
Page 5
Department of IT
Page 6
DMU
Department of IT
Page 7
Responsible to oversee, control and manage the database resources (the database itself, the DBMS
and other related software)
Accountable for problems like poor security, poor performance of the system
We can have further classifications of this role in big organizations having huge amount of data and
user requirement.
Data Administrator (DA): is responsible on management of data resources. Involves in
database planning, development, maintenance of standards policies and procedures at the
conceptual and logical design phases.
DataBase Administrator (DBA): is more technically oriented role. Responsible for the
physical realization of the database. Involves in physical design, implementation, security
and integrity control of the database.
Database Administrator a person that is responsible for all technical operations or details of the database
system. The user that controls the enterprises data resource. The functions of the DBA include the
following.
o Defining the conceptual schema: Will directly participate or help on the process of identifying the
content of the database, i.e., what information is to be held in the database and create the
corresponding conceptual schema using the conceptual DDL.
o Defining the internal schema: The DBA must also decide how the data is to be represented in the
stored database and then create the corresponding storage structure definition (the internal
schema) using the internal DDL (including associated mapping between the internal and
conceptual schema).
o Liaising with users: By communicating with users the DBA will ensure that the data they require
is available, and to write (or help users write) the necessary external schemas using the applicable
external DDL. Other functions include consulting on application design, providing technical
Department of IT
Page 8
Department of IT
Page 9
DMU
System analyst determines the user requirement and how the user wants to view the database.
The application programmer implements these specifications as programs; code, test, debug,
document and maintain the application program.
Determines the interface on how to retrieve, insert, update and delete data in the database.
The application could use any high level programming language according to the availability, the
facility and the required service.
Application programmers who are responsible for writing application programs that use the database
using some programming language such as COBOL, Pascal, or a programming language built-in to the
DBMS.
4. End-users: These are those people who are engaged on processing different types of operations on the
database system. Users are workers, whose job requires accessing the database frequently for various
purpose. There are different group of users in this category.
Nave Users:
Sizable proportion of users
Unaware of the DBMS
Only access the database based on their access level and demand
Use standard and pre-specified types of queries.
Sophisticated Users
Are users familiar with the structure of the Database and facilities of the DBMS.
Have complex requirements
Have higher level queries
Are most of the time engineers, scientists, business analysts, etc
Casual Users
Users who access the database occasionally.
Need different information from the database each time.
Use sophisticated database queries to satisfy their needs.
Are most of the time middle to high level managers.
Generally, End users are those that interact with the system from online workstations or terminals that use
an application program developed by application programmers or those that query the system through an
interface provided by the DBMS.
Department of IT
Page 10
DMU
These users can be again classified as Actors on the Scene and Workers Behind the Scene.
Actors On the Scene:
Data Administrator
Database Administrator
Database Designer
End Users
Workers Behind the Scene
DBMS designers and implementers: who design and implement different DBMS software.
Tool Developers: experts who develop software packages that facilitates database system
designing and use. Prototype, simulation, code generator developers could be an example.
Independent software vendors could also be categorized in this group.
Operators and Maintenance Personnel: system administrators who are responsible for actually
running and maintaining the hardware and software of the database system and the information
technology facilities.
Database Management System (DBMS)
Database Management System (DBMS) is the tool for creating and managing the large amounts of data
efficiently and allowing it to persist for a long periods of time. Hence DBMS is a general-purpose software
that facilities the processes of defining, constructing, manipulating, and sharing database.
- Defining: involves specifying data types, structure and constraints.
- Constructing: is the process of storing the data into a storage media.
- Manipulating: is retrieving and updating data from and into the storage.
- Sharing: allows multiple users to access data.
A DBMS is software that enables users to define, create, maintain and control access to the database.
Example: Ms Access, FoxPro, SQL Server, MySQL, Oracle.
The phrase Database System is used to colloquially refer to database and database management system
(DBMS).
Database Management System (DBMS) is a Software package used for providing EFFICIENT,
CONVENIENT and SAFE MULTI-USER (many people/programs accessing same database, or even
same data, simultaneously) storage of and access to MASSIVE amounts of PERSISTENT (data
outlives programs that operate on it) data.
Department of IT
Page 11
Department of IT
Page 12
DMU
o Is a core command used by end-users and programmers to store, delete, and upate the data in the
database e.g. SQL
o Provides basic data manipulation operations on data held in the database.
o Language for manipulating the data organized by the appropriate data model
Data Query Language (DQL):
o Language for accessing or retrieving the data organized by the appropriate data model
o Since the required data or Query by the user will be extracted using this type of language, it is also
called "Query Language"
o Procedural DQL: user specifies what data is required and how to get the data.
o Non-Procedural DQL: user specifies what data is required but not how it is to be retrieved
Data Dictionary (DD):
o Due to the fact that a database is a self describing system, this tool, Data Dictionary, is used to store
and organize information about the data stored in the database.
Data Control Language (DCL):
o Database is a shared resource that demands control of data access and usage. The database
administrator should have the facility to control the overall operation of the system.
o Data Control Languages are commands that will help the Database Administrator to control the
database.
o The commands include grant or revoke privileges to access the database or particular object within
the database and to store or remove database transactions
Database Development Life Cycle
As it is one component in most information system development tasks, there are several steps in
developing a database system. Here more emphasis is given to the design phases of the database system
development life cycle. The major steps in database system development are;
1. Planning: that is identifying information gap in an organization and propose a database solution to
solve the problem.
2. Analysis: that concentrates more on fact finding about the problem or the opportunity. Feasibility
analysis, requirement determination and structuring, and selection of best design method are also
performed at this phase.
3. Design: in database system development more emphasis is given to this phase. The phase is further
divided into three sub-phases.
Department of IT
Page 13
C. Physical Design: physical implementation of the upper level design of the database with
respect to internal storage and file structure of the database for the selected DBMS.
4. Implementation: the testing and deployment of the designed database for use.
5. Operation and Support: administering and maintaining the operation of the database system and
providing support to users.
Basic Conceptes
Database Design: The activity of specifying the schema of a database in a given data model
Changes infrequently
Data Model:
o
Database Instance or State: The actual data contained in a database at a given time.
Database Systems Architecture
There may be several types of architectures of database systems. However, American National Standards
Institute/ Standards Planning And R Commitee (ANSI/SPARC) architecture is applicable to most modern
database systems. External level, Conceptual level and Internal level.
All users should be able to access same data. This is important since the database is having a
shared data feature where all the data is stored in one location and all users will have their own
customized way of interacting with the data.
Department of IT
Page 14
Department of IT
Page 15
DMU
The Database System Architecture is consists of the three levels: External level, conceptual level, Internal
level.
External Level:
The external level is the one closest to the users, i.e., it is the one concerned with the way the data is
viewed by individual users. An external view is the content of the database as seen by some particular user
(i.e., to that user the database is similar to the view he is working/accessing).
Each external view is defined by a means of an external schema, which consists basically of definitions of
each of the various external record types in that external view. The external schema is written using the
external DDL portion of the users data sub language.
External level is users' view of the database. Describes that part of database that is relevant to a particular
user. Different users have their own customized view of the database independent of other users.
Conceptual Level:
o The conceptual level is found in between the other two. It is a representation of the entire information
content of the database including the relations with one another and security and integrity rules, etc.
o It is the view of the data as it really is or by its entirety rather than as users are forced to see it by the
constraints of (for example) the particular language or hardware they might be using.
Department of IT
Page 16
Department of IT
Page 17
Department of IT
Page 18
DMU
paths.
Department of IT
Page 19
Department of IT
Page 20
Department of IT
Page 21
DMU
UNIT TWO
Database Model
A database model is a conceptual description of how the database works. It describes how the data
elements are stored in the database and how the data is presented to the user and programmer for access;
and the relationship between different items in the database.
A specific DBS has its own specific Data Definition Language, but this type of language is too low level to
describe the data requirements of an organization in a way that is readily understandable by a variety of
users. We need a higher-level language. Such a higher-level is called database model.
Database Model: a set of concepts to describe the structure of a database, and certain constraints that the
database should obey.
A database model is a description of the way that data is stored in a database. Database model helps to
understand the relationship between entities and to create the most effective structure to hold data.
Database Model is a collection of tools or concepts for describing:
Data
Data relationships
Data semantics
Data constraints
The main purpose of database model is to represent the data in an understandable way.
Categories of database models include:
Object-based
Record-based
Physical
Department of IT
Page 22
DMU
In this model, the data is organized in a tree structure that originates from a root, and each class of data
resides at different levels along a particular branch of the root. The data structure at each class level is
called a node. There is always a single root node which is usually owned by the system or DBMS. Each of
the pointers in the root then will point to (child) nodes there by depicting a parent-child sort of relationship.
Searches are done by traversing the tree up and down with known search algorithms and modules supplied
by the DBMS or may, for special cases, be designed by the application programmer. The initial structure of
the database must be defined by the application programmer when the database is created. From this point
on, the parent-children structure cant be changed without redesigning the whole structure.
Generally, Hierarchical database model is:
Relation is established by creating physical link between stored records (each is stored with a
predefined access path to other records)
To add new record type or relationship, the database must be redefined and then stored in a new
form.
Department
Employee
Time Card
Department of IT
Job
Activity
Page 23
DMU
Allows record types to have more that one parent unlike hierarchical
A network database models sees records as set members
Each set has an owner and one or more members
Allows/supports many to many relationship between entities
Like hierarchical model network model is a collection of physically linked records.
Allow member records to have more than one owner
Department of IT
Page 24
DMU
Job
Department
Employee
Activity
Time Card
Advantages of Network Data Model:
Network Model is able to model complex relationships and represents semantics of add or
delete on the relationships.
Can handle most situations for modeling using record types and relationship types.
Language is navigational; uses constructs like FIND, FIND member, FIND owner, FIND
NEXT within set, GET etc. Programmers can do optimal navigation through the database.
Disadvantages of Network Data Model:
Navigational and procedural nature of processing.
Database contains a complex array of pointers that thread through a set of records.
Little scope for automated "query optimization.
3. Relational Database Model
The relational database model is a way of looking at data- that is, it is a prescription for a way of
representing data (namely, by means of tables), and a prescription for a way of manipulating such data (by
means of operators). More precisely, the relational database model is concerned with three aspects of data:
data structure (objects), data integrity, and data manipulation (operators).
The primary purpose behind the relational database model is the preservation of data integrity. To be
considered truly relational, a DBMS must completely prevent access to the data by any means other than
queries handled by the DBMS itself. While the relational model does not specify how the data is stored on
the disk, the preservation of data integrity implies that the data must be stored in a format that prevents it
from being accessed from outside the DBMS that created it.
Department of IT
Page 25
Developed by Dr. Edgar Frank Codd in 1970 (famous paper, 'A Relational Model for Large
Shared Data Banks').
Terminologies originates from the branch of mathematics called set theory and relation.
Records are related by the data stored jointly in the fields of records in two tables or files. The
related tables contain information that creates the relation.
Many tables are merged together to come up with a new virtual view of the relationship.
Department of IT
Page 26
DMU
Relation
Table
File
Tuple
Row
Record
Attribute
Column
Field
Conducts searches by using data in specified columns of one table to find additional data in another
table.
In conducting searches, a relational database model matches information from a field in one table
with information in a corresponding field of another table to produce a third table that combines
requested data from both tables.
Department of IT
Page 27
DMU
UNIT THREE
Database Modeling Using the Entity-Relationship (ER) Database Model
Properties of Relational Databases - Basic Concepts in Relational Database
Each row of a table is uniquely identified by a primary key (can be composed of one or more
columns).
Each tuple in a relation must be unique.
Group of columns, that uniquely identifies a row in a table is called a candidate key.
Entity integrity rule of the model states that no component of the primary key may contain a NULL
value.
A column or combination of columns that matches the primary key of another table is called a foreign
key. This key is used to cross-reference tables.
The referential integrity rule of the model states that, for every foreign key value in a table there must
be a corresponding primary key value in another table in the database or it should be NULL.
All tables are logical entities.
A table is either a base tables (named relations) or views (Unnamed Relations).
Only base tables are physically stores.
Views are derived from base tables with SQL instructions like:
[select .. from .. where .. order by].
Relatioal database is the collection of tables.
Each entity in one table.
Attributes are fields (columns) in table.
Order of rows and columns is immaterial or irrelevant.
Entries with repeating groups are said to be un-normalized.
Entries are single-valued.
Each column (field or attribute) has a distinct name.
All values in a column represent the same attribute and have the same data format.
Constraints: Rules that should be obeyed or followed while manipulating the data.
1. ENTITIES: The entities (persons, places, things etc.) which the organization has to deal with.
Relations can also describe relationships. The name given to an entity should always be a singular noun
Department of IT
Page 28
The domain: from which attribute values are taken (A domain is a set of values from which
attribute values may be taken.) Each attribute has values taken from a domain. For
example, the domain of Name is string and that for salary is real.
Whether the attribute is part of the entity identifier (attributes which just describe an entity
and those which help to identify it uniquely).
Whether it is permanent or time-varying (which attributes may change their values over time).
Whether it is required or optional for the entity (whose values will sometimes be unknown
or irrelevant).
Types of Attributes
(1) Simple (atomic) Vs Composite attributes
Single-valued : Have only single value (the value may change but has only one value at one time).
E.g. Name, Sex, Id. No. color_of_eyes, etc.
Department of IT
Page 29
DMU
Derived: The value may be derived (computed) from the values of other attributes.
E.g. Age (current year year of birth).
Length of employment (current date- start date).
Profit (earning-cost).
G.P.A (grade point/credit hours).
NULL applies to attributes which are not applicable or which do not have values.
given city, address must be modeled as an entity (attribute values are atomic).
3. RELATIONSHIPS :The relationships between entities which exist and must be taken into account
when processing information. In any business processing one object may be associated with another
object due to some event. Such kind of association is what we call a relationship between entity
objects.
Related entities require setting of links from one part of the database to another.
Role names are different from the names of entities forming the relationship: one entity may
take on many roles, the same role may be played by different entities.
Department of IT
Page 30
Cardinality of a Relationship
Another important concept about relationship is the number of instances/tuples that can be associated with
a single instance from one entity in a single relationship. The number of instances participating or
associated with a single instance from an entity in a relationship is called the cardinality of the relationship.
The major cardinalities of a relationship are:
One-to-one: one tuple is associated with only one other tuple.
o E.g. Building -to- Location as a single building will be located in a single location and as a
single location will only accommodate a single Building.
One-to-many: one tuple can be associated with many other tuples, but not the reverse.
o E.g. Department-to-Student as one department can have multiple students.
Many-to-one: many tuples are associated with one tuple but not the reverse.
o E.g. Employeeto-Department: as many employees belong to a single department.
Many-to-many: one tuple is associated with many other tuples and from the other side, with a
different role name one tuple will be associated with many tuples.
o E.g. Studentto-Course as a student can take many courses and a single course can be
attended by many students.
Department of IT
Page 31
DMU
Relational Integrity:
Domain integrity: No value of the attribute should be beyond the allowable limits.
Entity integrity: In a base relation, no attribute of a Primary Key can assume a value of NULL.
Referential integrity: If a Foreign Key exists in a relation, either the Foreign Key value must
match a Candidate Key value in its home relation or the Foreign Key value must be NULL.
Enterprise integrity: Additional rules specified by the users or database administrators of a
database are incorporated.
Keys and constraints
If tuples are need to be unique in the database, and then we need to make each tuple distinct. To do this we
need to have relational keys that uniquely identify each relation.
A super key : A super key also know as super set is then a set of one or more attributes that in group
(collectively) can identify an entity uniquely from the entity set.
Example: Consider the EMPLOYEES entity set, then
- EmpId, EmpId, Name, NationalId, NationalId, BDate, are super keys
- Name, BDate are NOT super keys
Super Key: an attribute or set of attributes that uniquely identifies a tuple within a relation.
Note: If K is a super set (super key) then a set consisting of K is also a super set.
The more interesting super set is the minimal super set that is referred to as the candidate key.
The candidate key is the sufficient and the necessary set of attributes to distinguish an entity set.
Example: In the EMPLOYEES entity set
- EmpId, NationalId, Name, BDate (assuming that there is no coincidence that employees with the
same name may born on the same day) are candidate keys.
The designer of the database is the one that makes the choice of the candidate keys for implementation, but
the choice has to be made carefully. Primary key is a term used to refer to the candidate key that is selected
by the designer for implementation.
Candidate Key: an attribute or set of attributes that uniquely identifies individual occurrences of an entity
type or tuple within a relation.
A candidate key has two properties:
1. Uniqueness
2. Irreducibility
Candidate Key: a super key such that no proper subset of that collection is a Super Key within the relation.
Department of IT
Page 32
DMU
Primary key: the candidate key that is selected to identify tuples uniquely within the relation. The entire set
of attributes in a relation can be considered as a primary case in a worst case.
In another way, an entity type may have one or more possible candidate keys, one of which is selected to
be a primary key.
Foreign key: an attribute, or set of attributes, within one relation that matches the candidate key of some
relation. A foreign key is a link between different relations to create the view or the unnamed
relation.
Relational Views
Relations are perceived as a table from the users perspective. Actually, there are two kinds of relation in
relational database. The two categories or types of relations are Base (Named) and View (Unnamed)
Relations. The basic difference is on how the relation is created, used and updated:
1. Base Relation: A named relation corresponding to an entity in the conceptual schema, whose tuples
are physically stored in the database.
2. View (Unnamed Relation): A View is the dynamic result of one or more relational operations
operating on the base relations to produce another virtual relation that does not actually exist as
presented. So a view is virtually derived relation that does not necessarily exist in the database but
can be produced upon request by a particular user at the time of request. The virtual table or relation
can be created from single or different relations by extracting some attributes and records with or
without conditions.
Purpose of a view
Hides unnecessary information from users: since only part of the base relation (Some collection of
attributes, not necessarily all) are to be included in the virtual table.
Provide powerful flexibility and security: since unnecessary information will be hidden from the
user there will be some sort of data security.
Provide customized view of the database for users: each users are going to be interfaced with their
own preferred data set and format by making use of the Views.
A view of one base relation can be updated.
Update on views derived from various relations is not allowed since it may violate the integrity of
the database.
Update on view with aggregation and summary is not allowed. Since aggregation and summary
results are computed from a base relation and does not exist actually.
Department of IT
Page 33
DMU
When a database is designed using a relational data model, all the data is represented in a form of a table.
In such definitions and representation, there are two basic components of the database. The two
components are the definition of the relation or the table and the actual data stored in each table. The data
definition is what we call the Schema or the skeleton of the database and the relations with some
information at some point in time is the Instance or the flesh of the database.
Schemas
Schema describes how data is to be structured, defined at setup/design time (also called "metadata"). Since
it is used during the database development phase, there is rare tendency of changing the schema unless
there is a need for system maintenance which demands change to the definition of a relation.
Database Schema (Intension): specifies name of relation and the collection of the attributes
(specifically the Name of attributes).
refer to a description of database (or intention)
specified during database design
should not be changed unless during maintenance
Schema Diagrams: convention to display some aspect of a schema visually.
Schema Construct: refers to each object in the schema (e.g. STUDENT)
E.g.: STUNEDT (FName,LName,Id,Year,Dept,Sex)
Instances
Instance: is the collection of data in the database at a particular point of time (snap-shot).
Also called State or Snap Shot or Extension of the database.
Refers to the actual data in the database at a specific point in time.
State of database is changed any time we add, delete or update an item.
Valid state: the state that satisfies the structure and constraints specified in the schema and is
enforced by DBMS.
Since instance is actual data of database at some point in time, changes rapidly. To define a new database,
we specify its database schema to the DBMS (database is empty). Database is initialized when we first load
it with data.
ENTITY - RELATIONSHIP DIAGRAMS
As one important aspect of E-R modeling, database designers represent their data model by E-R diagrams.
These diagrams enable designers and users to express their understanding of what the planned database is
Department of IT
Page 34
Weak Entity
Attribute
Ovals
Ovals
Multi-valued
Attribute
Composite
Attribute
Oval
s
Oval
s
Oval
s
Ovals
Key
Strong Relationship
Weak Relationship
An entity-relationship model (ERM) is a model that provides a high-level description of a conceptual data model. Data modeling that
provides a graphical notation for representing such data models in the form of entity-relationship diagrams (ERD).
The whole purpose of ER modeling is to create an accurate reflection of the real world in a database. The ER model doesnt actually give us a
database description. It gives us an intermediate step from which it is easy to define a database.
The E-R data model is based on a perception of a real world that consists of a set of basic objects called entities, and of relationships among
these objects. It was developed to facilitate database design by allowing the specification of an enterprise schema, which represents the overall
logical structure of a database.
The E-R data model is one of several semantic data models; the semantic aspect of the model lies in the attempt to represent the meaning of the
data. The E-R model is extremely useful in mapping the meanings and interactions of real-world enterprises onto a conceptual scheme.
Because of this utility, many database design tools draw on concepts from the E-R model.
A data model in which information stored in the database is viewed as sets of entities and sets of relationships among entities. There are three
basic notions that the ER Model employs: entity sets, relationships, and attributes.
Department of IT
Page 35
DMU
UNIT FOUR
Database Design
Database design is the process of coming up with different kinds of specification for the data to be stored in
the database. The database design part is one of the middle phases we have in information systems
development (DBS) where the system uses a database approach. Design is the part on which we would be
engaged to describe how the data should be perceived at different levels and finally how it is going to be
stored in a computer system.
Information System with Database application (DBS development life cycles)consists of several tasks
which include:
Planning of Information systems Design
Requirements Analysis
Design (Conceptual, Logical and Physical Design)
Tuning
Implementation
Operation and Support
From these different phases, the prime interest of a database system development will be the design part
which is again sub divided into other three sub-phases. These sub-phases are:
1. Conceptual Database Design
2. Logical Design Database, and
3. Physical Database Design
In general, one has to go back and forth between these tasks to refine a database design, and decisions in
one task can influence the choices in another task. In developing a good design, one should answer such
questions as:
What are the relevant Entities for the Organization
What are the important features of each Entity
What are the important Relationships
What are the important queries from the user
What are the other requirements of the Organization and the Users
Department of IT
Page 36
DMU
Conceptual
Design
Logical
Design
Physical
Design
Conceptual Database Design
Conceptual design is the process of constructing a model of the information used in an enterprise,
independent of any physical considerations.
It is the source of information for the logical design phase.
Mostly uses an Entity Relationship Model to describe the data at this level.
After the completion of Conceptual Design one has to go for refinement of the schema, which is
verification of Entities, Attributes, and Relationships.
Logical Database Design
Logical design is the process of constructing a model of the information used in an enterprise based on a
specific database model (e.g. Relational, Hierarchical or Network or Object), but independent of a
particular DBMS and other physical considerations.
Normalization process
Department of IT
Page 37
DMU
NOTE:
In conceptual data model/Design
o Identify what are the entities/entity types
o Identify what are the attributes: - the information about entities and relationship should we store in
the database.
o
o Draw entity-relationship diagram: - representing the database in the ER model using pictorial
representation called ER diagram
o
NB: Startng from this we are going to design database using the relational database model.
Department of IT
Page 38
DMU
An entity-relationship (E-R) data model is a high-level conceptual model that describes data as entities,
attributes, and relationships. The E-R model is represented by E-R diagrams that show how data will be
represented and organized in the various components of the final database. However, the model diagrams
do not specify the actual data, or even exactly how it is stored. The users and applications will create the
data content and the database management system will create the database to store the content.
Entity-Relationship modeling is used to represent conceptual view of the database. The main components
of ER Modeling are:
Entities
o Corresponds to entire table, not row
o Represented by Rectangle
Attributes
o Represents the property used to describe an entity or a relationship
o Represented by Oval
Relationships
o Represents the association that exist between entities
o Represented by Diamond
Constraints
o Represent the constraint in the data
Before working on the conceptual design of the database, one has to know and answer the following
basic questions.
What are the entities and relationships in the enterprise?
What information about these entities and relationships should we store in the database?
What are the integrity constraints that hold? Constraints on each data with respect to update,
retrieval and store.
Represent this information pictorially in ER diagrams, then map ER diagram into a relational
schema.
Developing an E-R Diagram
Designing conceptual model for the database is not a one linear process but an iterative activity where the
design is refined again and again. To identify the entities, attributes, relationships, and constraints on the
data, there are different set of methods used during the analysis phase. These include information
gathered by.
Department of IT
Page 39
DMU
Questionnaire survey
Direct observation
Examining different documents
The basic E-R model is graphically depicted and presented for review. The process is repeated until the end
users and designers agree that the E-R diagram is a fair representation of the organizations activities and
functions. Checking for Redundant Relationships in the ER Diagram. Relationships between entities indicate
access from one entity to another - it is therefore possible to access one entity occurrence from another entity
occurrence even if there are other entities and relationships that separate them - this is often referred to as
Navigation' of the ER diagram. The last phase in ER modeling is validating an ER Model against requirement
of the user.
Example 1: Build an E-R Diagram for the following information:
A student record management system will have the following two basic data object categories with their
own features or properties: Students will have an Id, Name, Dept, Age, GPA and Course will have an Id,
Name, Credit Hours. Whenever a student enroll in a course in a specific Academic Year and Semester, the
Student will have a grade for the course.
Dept
Name
DoB
Id
Name
Credit
GPA
Id
Course
s
Students
Age
Academic
Year
Enrolled_In
Semester
Grade
Department of IT
Page 40
Employee
1..1
Manages
0..1
Branch
One-To-Many Relationships
In the one-to-many relationship a loan is associated with at most one customer via borrower, a
customer is associated with several (including 0) loans via borrower.
Department of IT
Page 41
DMU
Employee
1..1
Leads
0..*
Project
Many-To-Many Relationship
A customer is associated with several (possibly 0) loans via borrower. A loan is associated with
several (possibly 0) customers via borrower.
0..*
Instructor
Department of IT
Teaches
1..*
Course
Page 42
DMU
Participation constraint of a relationship is involved in identifying and setting the mandatory or optional
feature of an entity occurrence to take a role in a relationship. There are two distinct participation
constraints with this respect, namely: Total Participation and Partial Participation.
1. Total participation: every tuple in the entity or relation participates in at least one relationship by
taking a role. This means, every tuple in a relation will be attached with at least one other tuple. The
entity with total participation in a relationship will be connected to the relationship using a double
line.
2. Partial participation: some tuple in the entity or relation may not participate in the relationship.
This means, there is at least one tuple from that Relation not taking any role in that specific
relationship. The entity with partial participation in a relationship will be connected to the
relationship using a single line.
E.g. 1: Participation of EMPLOYEE in belongs to relationship with DEPARTMENT is
total since every employee should belong to a department. Participation of DEPARTMENT in
belongs to relationship with EMPLOYEE is total since every department should have more
than one employee.
Employee
Belongs To
Department
Employee
Manages
Department
Problem in ER Modeling
The Entity-Relationship Model is a conceptual data model that views the real world as consisting of entities
and relationships. The model visually represents these concepts by the Entity-Relationship diagram. The
basic constructs of the ER model are entities, relationships, and attributes. Entities are concepts, real or
abstract, about which information is collected. Relationships are associations between the entities.
Attributes are properties which describe the entities.
While designing the ER model one could face a problem on the design which is called a connection traps.
Connection traps are problems arising from misinterpreting certain relationships.
Department of IT
Page 43
DMU
1. Fan trap:
Occurs where a model represents a relationship between entity types, but the pathway between
certain entity occurrences is ambiguous.
May exist where two or more one-to-many (1:M) relationships fan out from an entity. The problem
could be avoided by restructuring the model so that there would be no 1:M relationships fanning out
from a singe entity and all the semantics of the relationship is preserved.
Example:
EMPLOYEE
1..*
Works
1..1
BRANCH
1..1
1..*
IsAssigned
CAR
For
Bra1
Car1
Emp2
Bra2
Car2
Emp3
Bra3
Car3
Emp4
Bra4
Car4
Emp5
Car5
Emp6
Car6
Emp7
Car7
Problem: Which car (Car1 or Car3 or Car5) is used by Employee 6. Emp6 working in Branch 1 (Bra1).
Thus from this ER Model one can not tell which car is used by which staff since a branch can have more
than one car and also a branch is populated by more than one employee. Thus we need to restructure the
model to avoid the connection trap.
To avoid the Fan Trap problem we can go for restructuring of the E-R Model. This will result in the
following E-R Model.
BRANCH
1..1
1..*
Has
CAR
1..*
By
Used
1..*
EMPLOYEE
Department of IT
Car1
Car2
Car3
Car4
Car5
Car6
Car7
Emp1
Emp2
Emp3
Emp4
Emp5
Emp6
Emp7
Page 44
DMU
2. Chasm Trap:
Occurs where a model suggests the existence of a relationship between entity types, but the path
way does not exist between certain entity occurrences.
May exist when there are one or more relationships with a minimum multiplicity on cardinality of
zero forming part of the pathway between related entities.
Example:
BRANCH
1..1
1..*
Has
EMPLOYEE
0..1
0..*
Manages
PROJECT
If we have a set of projects that are not active currently then we can not assign a project manager for these
projects. So there are project with no project manager making the participation to have a minimum value of
zero.
Problem:
How can we identify which BRANCH is responsible for which PROJECT? We know that whether the
PROJECT is active or not there is a responsible BRANCH. But which branch is a question to be answered,
and since we have a minimum participation of zero between employee and PROJECT we cant identify the
BRANCH responsible for each PROJECT.
The solution for this Chasm Trap problem is to add another relationship between the extreme entities
(Branch and Project).
BRANCH
1..1
1..*
Has
1..1
1..*
Department of IT
EMPLOYEE
0..1
0..*
Manages
PROJECT
Responsible for
Page 45
DMU
Department of IT
Page 46
DMU
Specialization
Specialization is the result of subset of a higher level entity set to form a lower level entity set. The
specialized entities will have additional set of attributes (distinguishing characteristics) that distinguish
them from the generalized entity. Is considered as Top-Down definition of entities. Specialization process
is the inverse of the Generalization process. Identify the distinguishing features of some entity occurrences,
and specialize them into different subclasses.
Reasons for Specialization are:
Attributes only partially applying to superclasses.
Relationship types only partially applicable to the superclass.
In many cases, an entity type has numerous sub-groupings of its entities that are meaningful and need to be
represented explicitly. This need requires the representation of each subgroup in the ER model. The
generalized entity is a superclass and the set of specialized entities will be subclasses for that specific
Superclass.
Example: Saving Accounts and Current Accounts are Specialized entities for the generalized entity
Accounts. Manager, Sales, Secretary: are specialized employees.
Subclass/Subtype
An entity type whose tuples have attributes that distinguish its members from tuples of the generalized or
Superclass entities. When one generalized Superclass has various subgroups with distinguishing features
and these subgroups are represented by specialized form, the groups are called subclasses. Subclasses can
be either mutually exclusive (disjoint) or overlapping (inclusive). A single subclass may inherit attributes
from two distinct superclasses. A mutually exclusive category/subclass is when an entity instance can be
in only one of the subclasses. E.g.: An EMPLOYEE can either be SALARIED or PART-TIMER but not
both.
An overlapping category/subclass is when an entity instance may be in two or more subclasses. E.g.: A
person who works for a university can be both employee and a student at the same time.
Superclass /Supertype
An entity type whose tuples share common attributes. Attributes that are shared by all entity occurrences
(including the identifier) are associated with the supertype. Superclass /Supertype Is the generalized entity.
Department of IT
Page 47
DMU
The relationship between a superclass and any of its subclasses is called a superclass/subclass or
class/subclass relationship. An instance can not only be a member of a subclass. i.e. Every instance of a
subclass is also an instance in the Superclass. A member of a subclass is represented as a distinct database
object, a distinct record that is related via the key attribute to its super-class entity. An entity cannot exist in
the database merely by being a member of a subclass; it must also be a member of the super-class. An
entity occurrence of a sub class not necessarily should belong to any of the subclasses unless there is full
participation in the specialization. A member of a subclass is represented as a distinct database object, a
distinct record that is related via the key attribute to its super-class entity. The relationship between a
subclass and a Superclass is an IS A or IS PART OF type.
Manager IS AN Employee
All subclasses or specialized entity sets should be connected with the superclass using a line to a circle
where there is a subset symbol indicating the direction of subclass/superclass relationship.
We can also have subclasses of a subclass forming a hierarchy of specialization. Superclass attributes are
shared by all subclasses f that superclass. Subclass attributes are unique for the subclass.
Attribute Inheritance
An entity that is a member of a subclass inherits all the attributes of the entity as a member of the
superclass. The entity also inherits all the relationships in which the superclass participates. An entity may
have more than one subclass categories. All entities/subclasses of a generalized entity or superclass share a
common unique identifier attribute (primary key). i.e. The primary key of the superclass and subclasses are
always identical.
Department of IT
Page 48
DMU
Consider the EMPLOYEE supertype entity shown above. This entity can have several different subtype
entities (for example: HOURLY and SALARIED), each with distinct properties not shared by other
subtypes. But whether the employee is Hourly or Salaried, same attributes (EmployeeId, Name, and
DateHired) are shared. The Supertype EMPLOYEE stores all properties that subclasses have in common.
And HOURLY employees have the unique attribute Wage (hourly wage rate), while SALARIED
employees have two unique attributes, StockOption and Salary.
Constraints on specialization and generalization
Completeness Constraint.
The Completeness Constraint addresses the issue of whether or not an occurrence of a Superclass must also
have a corresponding Subclass occurrence. The completeness constraint requires that all instances of the
subtype be represented in the supertype. The Total Specialization Rule specifies that an entity occurrence
should at least be a member of one of the subclasses. Total Participation of superclass instances on
subclasses is diagrammed with a double line from the Supertype to the circle as shown below. E.g.: If we
have Extention and regular as subclasses of a superclass student, then it is mandatory that each student to
be either Extention or regular student. Thus the participation of instances of student in Extention and
regular subclasses will be total.
Department of IT
Page 49
Department of IT
Page 50