0% found this document useful (0 votes)
215 views65 pages

DataBase System CH - 1 and 2

The document provides an overview of database systems and their components. It discusses how a database system collects and organizes related data in an organized manner. It also describes the key components of a database system including hardware, software, data, and users. The document summarizes the functions of a database management system and the different types of languages it uses including DDL, DML, DQL, and DCL.

Uploaded by

Frtuna Haile
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)
215 views65 pages

DataBase System CH - 1 and 2

The document provides an overview of database systems and their components. It discusses how a database system collects and organizes related data in an organized manner. It also describes the key components of a database system including hardware, software, data, and users. The document summarizes the functions of a database management system and the different types of languages it uses including DDL, DML, DQL, and DCL.

Uploaded by

Frtuna Haile
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/ 65

Chapter One

Introduction

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


04/15/2021 Database System 1
Introduction to Database
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

04/15/2021 Database System 2


Con’t..

Limitations Traditional Database :


Prone to error
Data loss
Redundancy
Inconsistency
Difficult to update, retrieve, integrate
difficult to compile the information
Limited to small size information
Cross referencing is difficult
04/15/2021 Database System 3
Database

Is a collection of related data in an organized way.

Is logically related data where these logically related data


comprises: entities, attributes, relationships, and business rules
of an organization's information.

Also contains a description of the data which called as


“Metadata” or “Data Dictionary” or “Systems Catalogue” or
“Data about Data”.

E.g. book database

04/15/2021 Database System 4


Database

Databases and database technology are having a major impact on the


growing use of computers.

Play a critical role in almost all areas where computers are used,
including Business, Engineering, Medicine, Law, Education, And
Library Science, Etc.

Designed once and used simultaneously by many users.

04/15/2021 Database System 5


Database

The advantages of a database approach over the traditional and paper-


based methods of record keeping will :-
Compactness: no need for possibly voluminous paper files.
Speed: can retrieve and change data faster than a human can.

Accuracy: timely, accurate and up-to-date information is available


at any time
Data can be shared: two or more users can access and use same
data instead of storing data in redundant manner for each user.
Redundancy can be reduced: In non database or non centralized
systems each application or department keeps its own private files.

04/15/2021 Database System 6


Database

Integrity can be maintained: The problem of integrity is the problem


of ensuring the data in the database is accurate

Security restrictions can be applied: Different rules can be


established for each type of access (retrieve, insert, delete, etc.) to each
of information to the database.

04/15/2021 Database System 7


Con’t..

Limitations and risk of Database

Complexity in designing and managing data

The cost and risk during conversion from the old to the new system

High cost to be incurred to develop and maintain the system

Complex backup and recovery services from the users perspective

Reduced performance due to centralization and data independency

High impact on the system when failure occurs to the central


system.

04/15/2021 Database System 8


Database Systems
A computerized record keeping system. Users of the database can perform a
variety of operations. Such as:

Retrieving data from existing file

Adding new data to existing file

Adding new data to empty file

Receives data and instruction

Modifying data to existing file

Deleting data from existing file

Searching for target information


04/15/2021 Database System 9
component of database system

A database system involves four major components:


Hardware :consists of secondary storage media.
Data :The actual data stored in the database system may be stored as a
single database or distributed in many distinct files and treated as one.
Software :DBMS is responsible for the overall management of
communications between the user and the database
User and designer of database:there are group of roles played by
different stakeholders of the designing and operation of a database system.

04/15/2021 Database System 10


Con’t..

Database Administrator (DBA)


Responsible to oversee, control and manage the database resources
(the database itself, the DBMS and other related software)
Authorizing access to the database
Coordinating and monitoring the use of the database
Responsible for determining and acquiring hardware and software
resources
Accountable for problems like poor security, poor performance of
the system
Involves in all steps of database development

04/15/2021 Database System 11


Database Management System(DBMS)
Is a collection of programs that enables users to create and
maintain a database.

Example: Ms Access, SQL Server, My SQL, Oracle etc.

Is general-purpose software system that facilitates the processes of

Defining database

Constructing database

Manipulating databases for various applications

Defining a database: involves specifying the data types,


structures, and constraints for the data to be stored in the database.
04/15/2021 Database System 12
Con’t…

Constructing the database: is the process of storing the data

itself on some storage medium that is controlled by the

DBMS.

Manipulating a database: to retrieve specific data, updating

the database to reflect changes in the mini world, and

generating reports from the data.

Sharing: allows multiple users to access data.

04/15/2021 Database System 13


Components of DBMS Environment

A DBMS is software package used to design, manage, and

maintain databases.

It facilities to define the database, manipulate the content of the

database and control the database.

These facilities will help the designer, the user as well as the

database administrator to discharge their responsibility in

designing, using and managing the database.

It provides the following facilities:

04/15/2021 Database System 14


Con’t…

Data Definition Language (DDL):


A Language used to define each data element

required by the organization.

Used to setup a database to create, drop, rename

and alter table with the facility of handling

constraints
04/15/2021 Database System 15
Con’t…

Data Manipulation Language (DML):


Is a core command used by end-users and programmers to insert,

delete, and update the data in the database.

Provides basic data manipulation operations on data held in the

database.

Language for manipulating the data organized by the appropriate

data model

04/15/2021 Database System 16


Con’t…

Data Query Language (DQL):


Language for accessing or retrieving the data organized by the

appropriate data model

Since the required data or Query by the user will be extracted using

this type of language, it is also called "Query Language“ model

Procedural DQL: user specifies what data is required and how to

get the data.

Non-Procedural DQL: user specifies what data is required but not

how
04/15/2021 it is to be retrieved
Database System 17
Con’t…

Data Control Language (DCL):


The database administrator should have the facility to control the
overall operation of the system.

The commands include grant or revoke privileges to access the


database or particular object within the database and to store or
remove database transactions

04/15/2021 Database System 18


Types Of Database Model
A model is a representation of real world objects and events and their
associations. Data model can be divided into four:
Hierarchical database model: Consists of an ordered set of
trees in a parent child mode.
Connection between child and its parent is called a Link.
1-1 or 1-M link is allowed.
It is inflexible
Used widely in applications like bank, tecom etc.
Easy to understood
Top down ways of viewing business entity
Allows a node to have only one parent.

04/15/2021 Database System 19


Con’t..
Network model: is the extension of the hierarchical structure because
it allows many-to-many relationships to be managed in a tree-like

structure that allows multiple parents.

Records data in a database as a collection of records, but unlike in the

case of hierarchical model, here a node can have any number of

parents.

Linked records are called set.

Object-oriented Database Model: information is represented in the

form of objects as used in object-oriented programming.

04/15/2021 Database System 20


Con’t..

Relational model: It is stored along with its


entities. A table has two properties rows and columns.

Rows represent records and columns represent

attributes.

 Most current DBMS technologies use relational

model

04/15/2021 Database System 21


Steps of Database Design
Information Systems Design in general involves three steps

Requirements analysis – specifies what the system is required to do


based on user input.

Design – specifies how the system will address the requirements.

Implementation – translates design specifications into a working


system.

04/15/2021 Database System 22


Steps In Requirements Analysis for Database
Identify scope of the design effort.
Establish metadata collection standards - who to interview, what to
collect - how to structure interview.
Identify user views – extracted by reviewing user tasks, types of
decisions. Forms, reports, graphs, maps can be useful information
for defining views. User view- subset of data used by a user in a
specific context
Build a data dictionary - define and describe each item in detail:
name, description, type, length, range and relationships
Identify data volumes and usage patterns how much data is used
and how frequently is data change.
Identify operational (functional) requirements..

04/15/2021 Database System 23


Con’t..

Design of a database involves three types of designing


steps:
Conceptual Design: Synthesis of information from
requirements analysis according to semantic rules.
Outcome is a conceptual model. The conceptual model
describes entities, attributes and relations among entities
independent of implementation details.
Logical Design: Transforms the conceptual data model
into an internal model - schema that can be processed by
a particular DBMS. For example E/R model to relational
model mapping.
04/15/2021 Database System 24
Con’t..

Physical Design: Involves design of internal storage


structures, record formats, access methods, record
blocking and soon.

04/15/2021 Database System 25


Chapter two
Conceptual level data design: Refers to the Entity Relationship(E/R) Data Model .

Entity - Relationship (E/R) : Views the real world as a set of basic objects (entities)
and relationships among these objects.

It represents the overall logical structure of the database

The three basic notions of the E/R model are:

Entity: represents existing real-world objects or concepts, such as places, objects,


events, persons, orders, customers, and so on.

Relationship: represents associations between objects, such as the fact that a


customer may place an order.

Attribute: describes the entity, such as the invoice date or the customer first name.

04/15/2021 Database System 2-1


Entity set
An entity set is a set consisting of the same type of entities that share the
same properties.

Eg “EMPLOYEES”(EMPLOYEE1, EMPLOYEE2,
EMPLOYEE3,etc ) entity set represents all the set of employees

Entities are classified as independent (Strong) or dependent (Weak).


A strong (independent) entity: is one that does not rely on other
entities for identification.
A weak (dependent) entity: is one that relies on other entities for
identification.
An individual occurrence of an entity set is also known as an
instance (object ).
04/15/2021 Database System 2-2
Types of attributes
Are descriptive properties that are associated with an entity. A set of
attributes describe an entity.

A particular instance of an attribute is called a value. For example,


“Employee Id” and “Name” are the attributes of the
“EMPLOYEES” entity set; and “XYZ” is one value of the attribute
“Name”.

Attributes can be classified as:

Identifiers or

Descriptors.

04/15/2021 Database System 2-3


Cont..
Identifiers: more commonly called keys, uniquely identify an instance
of an entity.
Example:“Employee Id” uniquely identifies an employee entity from
the entity set.
Descriptor: describes a non-unique characteristic of an entity instance.
Example: “Name” is a descriptor for the “EMPLOYEES” entity set
Other way of categorizing Attributes is as Simple and Composite
attributes.
Simple Attributes: are attributes also known as Atomic Attributes that
can not be divided into subparts.
Example: “Age” and “Gender” of the “EMPLOYEES” entity set.

04/15/2021 Database System 2-4


Cont..
Composite Attributes: are attributes that are composed of
smaller subparts that can be subdivided into the subparts
(Attributes).

04/15/2021 Database System 2-5


Cont..
Another classification of attributes is based on the values that they can
hold as:
Single-valued and
Multi-valued attributes.
Single-valued Attributes: are attributes having only one possible value
at any time.
 Example: “Name” and “Gender” of the “EMPLOYEES” entity set.
Multi-valued Attributes: are attributes that are having possibly more
than one value.
 Example: “PERSON_OF_DEGREE” .

04/15/2021 Database System 2-6


Cont..
Attributes can also be categorized Stored and Derived attributes.

Derived Attributes: are attributes that can be calculated from the


related stored attributes, entities or general states.

Stored Attributes: are attributes that can not be calculated in any


way from the stored attributes.
 Example: “Birth Date” of the “EMPLOYEES” entity set is a stored

attribute, where as “Age” is a derived attribute that can be calculated


from the “Birth Date” and “Current Date”.

04/15/2021 Database System 2-7


Relationship
A Relationship represents an association between two or more entities.
An example of a relationship would be:
 “EMPLOYEES” Assigned “TEAMS”

 “CUSTOMERS” Owns “PROJECTS”

 “TEAMS” works on “PROJECTS”


Relationships are classified in terms of degree, connectivity,
cardinality, and existence.
Degree: of a relationship is the number of entities associated with
the relationship. The multi-way relationship is the general form for
degree n. Special cases are the binary, and ternary, where the degree
is 2, and 3, respectively
04/15/2021 Database System 2-8
Cont..
Connectivity: The connectivity of a relationship describes the
mapping of associated entity instances in the relationship. The values
of connectivity are “one” or “many”.

Cardinality: The cardinality of a relationship is the actual number


of related occurrences for each of the two entities. The basic types of
connectivity for relations are: one-to-one, one-to-many,many-to-one
and many-to-Many.

04/15/2021 Database System 2-9


Cont..
Existence: The existence of a entity in a relationship is defined as
either mandatory or optional.

04/15/2021 Database System 2-10


Summery

04/15/2021 Database System 2-11


Types of keys
Keys – are attributes or set of attributes that can be used to uniquely
identify an entity within the entity set.

Why we need a Key?

Keys help you to identify any row of data in a table.

In a real-world application, a table could contain thousands of


records.

Allows you to establish a relationship between and identify the


relation between tables.
Help you to enforce identity and integrity in the relationship.

04/15/2021 Database System 2-12


Cont..

A super key (super set) is a group of single or multiple keys which


identifies rows in a table. A Super key may have additional attributes
that are not needed for unique identification.

In the above-given example, EmpSSN and “EmpNum +Empname” are

superkeys.

04/15/2021 Database System 2-13


Cont..

Primary Key: A column or group of columns in a table which


helps us to uniquely identifies every row in that table is called a
primary key. The same value can't appear more than once in the table.

Rules for defining Primary key:

Two rows can't have the same primary key value

It must for every row to have a primary key value.

The primary key field cannot be null.

The value in a primary key column can never be modified or


updated if any foreign key refers to that primary key.

04/15/2021 Database System 2-14


Cont..

Alternate key: All the keys which are not primary key are called an
alternate key. It is a candidate key which is currently not the primary
key. However, A table may have single or multiple choices for the
primary key.
 Example: In this table. StudID, Roll No, Email are qualified to become
a primary key. But since StudID is the primary key, Roll No, Email
becomes the alternative key.

04/15/2021 Database System 2-15


Cont..
Candidate Key: A super key with no repeated attribute is called
candidate key.

The Primary key should be selected from the candidate keys. Every
table must have at least a single candidate key.

Properties of Candidate key:

It must contain unique values

Candidate key may have multiple attributes

Must not contain null values

Uniquely identify each record in a table

04/15/2021 Database System 2-16


Cont..
Example: In the given table below Stud ID, Roll No, and email are
candidate keys which help us to uniquely identify the student record in
the table.

04/15/2021 Database System 2-17


Cont..
Foreign Key A foreign key is a column which is added to create a
relationship with another table.

Foreign keys help us to maintain data integrity and also allows


navigation between two different instances of an entity.

This concept is also known as Referential Integrity.

04/15/2021 Database System 2-18


Cont..
Composite key: A key which has multiple attributes to uniquely
identify rows in a table is called a composite key.

the composite key may or maybe not a part of the foreign key.

04/15/2021 Database System 2-19


Constraints

Constraints: The whole purpose of constraints is to maintain


the data integrity during an update/delete/insert into a table.

Types of constraints
NOT NULL
UNIQUE
DEFAULT
CHECK
Key Constraints – PRIMARY KEY, FOREIGN KEY
Mapping constraints
Domain constraints
04/15/2021 Database System 2-20
Cont..
NOT NULL: constraint makes sure that a column does not hold NULL
value. When we don’t provide value for a particular column while
inserting a record into a table, it takes NULL value by default.

UNIQUE: Constraint enforces a column or set of columns to have


unique values.

DEFAULT: constraint provides a default value to a column when there


is no value provided while inserting a record into a table.

04/15/2021 Database System 2-21


Cont..
CHECK: is used for specifying range of values for a particular
column of a table.

Key constraints:

Eg: CREATE TABLE STUDENT( ROLL_NO   INT  NOT NULL


CHECK(ROLL_NO >1000) , STU_NAME VARCHAR (35)  NOT
NULL UNIQUE, STU_AGE INT  NOT NULL EXAM_FEE
INT DEFAULT 10000, STU_ADDRESS VARCHAR (35) ,
PRIMARY KEY (ROLL_NO) );

04/15/2021 Database System 2-22


Mapping Constraints

Mapping Cardinality:

One to One: An entity of entity-set A can be associated with at


most one entity of entity-set B and an entity in entity-set B can be
associated with at most one entity of entity-set A.

One to Many: An entity of entity-set A can be associated with any


number of entities of entity-set B and an entity in entity-set B can
be associated with at most one entity of entity-set A.

Many to One: An entity of entity-set A can be associated with at


most one entity of entity-set B and an entity in entity-set B can be
associated with any number of entities of entity-set A.
04/15/2021 Database System 2-23
Cont..
Many to Many: An entity of entity-set A can be associated with any
number of entities of entity-set B and an entity in entity-set B can be
associated with any number of entities of entity-set A.

Domain constraints: Each table has certain set of columns and each
column allows a same type of data, based on its data type. The column
does not accept values of any other data type.
Domain Constraint = data type + Constraints (NOT NULL /
UNIQUE / PRIMARY KEY / FOREIGN KEY / CHECK /
DEFAULT)

04/15/2021 Database System 2-24


Database Design Guidelines
What are the steps in designing a database.

Determine the purpose of your database.

Find and organize the required information.

Divide the information into tables.

Turn information items into columns.

Specify primary keys.

Set up the table relationships.

Refine your design.

Apply the normalization rules

04/15/2021 Database System 2-25


Chapter three
Relational database design:
Relational database design (RDD)  use tables to store information.
The standard fields and records are represented as columns (fields/
attributes) and rows (records/ tuple) in a table.

The design of a relational database is composed of four stages,


where the data are modeled into a set of related tables. The stages
are:
Define relations/attributes
Define primary keys
Define relationships
Normalization

04/15/2021 Database System 3-1


Functional dependency in DBMS
The attributes of a table is said to be dependent on each other when an
attribute of a table uniquely identifies another attribute of the same
table.

For example: Suppose we have a student table with attributes:


Stu_Id, Stu_Name, Stu_Age.

Here Stu_Id attribute uniquely identifies the Stu_Name attribute of


student table because if we know the student id we can tell the
student name associated with it.

This is known as functional dependency and can be written as


Stu_Id->Stu_Name or in words we can say Stu_Name is
functionally dependent on Stu_Id.
04/15/2021 Database System 3-2
Cont..
 Normalization: is the process of minimizing redundancy from a
relation or set of relations.
 It ensures optimum structure .

 It ensures data atomic.

 It eliminates data inconsistencies and anomalies.

 It improves data integrity.

Anomalies in DBMS: There are three types of anomalies that occur


when the database is not normalized. These are – Insertion, update and
deletion anomaly.

04/15/2021 Database System 3-3


Cont..
Example: Suppose a library management system database store details
of a table and it has six attributes:

The above table is not normalized. We will see the problems that we
face when a table is not normalized.

04/15/2021 Database System 3-4


Cont..
Update anomaly: In the above table we have two rows that have the
same value gae for a table, If we want to update the age of mulu then
we have to update only one rows.

Therefore the data will become inconsistent.

04/15/2021 Database System 3-5


Cont..
Insert anomaly: if we want to add five new records in to a database ,
then we would not be able to insert the data into the table if Roll_No
field doesn’t allow nulls.

Delete anomaly: Suppose, if at a point of time the manager closes the


Book_No B10 then deleting the rows that are having Book_No as
B10 would also delete the information of student Alex since he is
assigned only to the table .
To overcome these anomalies we need to normalize the data

04/15/2021 Database System 3-6


Cont..
  First Normal Form: If a relation is in 1NF:
It should not contain multi-valued attribute.
every attribute should be  singled valued attribute
It should be atomic .

04/15/2021 Database System 3-7


Cont..
Second normal form (2NF): A table is said to be in 2NF if the
following conditions hold:

Table is in 1NF (First normal form)

No non-prime attribute is dependent on the proper subset of any


candidate key of table.

No partial dependency exist.

An attribute that is not part of any candidate key is known as non-


prime attribute.

04/15/2021 Database System 3-8


Cont..

Conversion to 2NF

04/15/2021 Database System 3-9


Cont..
Third Normal form (3NF): A table is in 3NF for each functional
dependency X-> Y at least one of the following conditions hold:
Table must be in 2NF
Transitive functional dependency of non-prime attribute on any
super key should be removed.
In other words 3NF can be explained like this:
X is a super key of table
Y is a prime attribute of table
An attribute that is a part of one of the candidate keys is known as
prime attribute.

04/15/2021 Database System 3-10


Cont..

04/15/2021 Database System 3-11


Cont..
Boyce-Codd Normal Form (BCNF): is a stronger generalization of
third normal form.

A table is in Boyce-Codd Normal form if and only if at least one of


the following conditions are met for each functional dependency

A → B:

It should no non-trivial dependency(A trivial functional dependency


means that all columns of B are contained in the columns of A)

A is a super key

A relation is in BCNF if every determinant is a candidate key

04/15/2021 Database System 3-12


Cont..

04/15/2021 Database System 3-13


Individual Assignment One (5%)
1. Explain functionality of database system.

2. What is participation in DBS? explain briefly.

3. What is multiplicity in DBS? explain briefly

4. What are the basic difference between multiplicity and participation ?

5. What is ODL ? Explain with neat diagram and compare with E/R.

6. What is anomalies? Explain briefly with examples

Submission date 28/02/2012

04/15/2021 Database System 1


Individual Assignment Two (5%)
Convert in to the highest normal form for the following relation.

A. R(ABCDE) Then {A->BC, AD->E,B->C}

B. R(ABCDE) Then {AB->C,C->D,E->A,D->B}

C. R(ABCDEFGHI) Then {ABC->DE,E->GHI,H->G,G->HI}

D. R(ABCDEF) Then {AB->C,CD->E,E->F}

Submission date 12/03/2012

04/15/2021 Database System 2

You might also like