[go: up one dir, main page]

0% found this document useful (0 votes)
33 views49 pages

Database

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1/ 49

Chapter 2

Data base
data
Data: The value we get from real world measurement.

 It can be in the form of numbers, words, images, or other forms of information.

 It is often used to represent specific information about people, places, things, or events, and
can help understand patterns, trends, and relationships related to the information being
collected.
DATA HIERARCHY
The data in a computer system are organized in a hierarchy known as the data
hierarchy chain.
The hierarchy in ascending order bits, bytes, fields, records, files and database.
A database is made up of records, records consist of fields, fields contain bytes, and bytes are
made up of bits.

1. Bit: A bit is a value that represents the presence or absence of an electronic signal and is
represented as a 1 or 0.

2. Byte: Eight bits make up a byte and a byte is required to represent a character (number,
alphabetic and so on) in a computer.
 Ex: “BADASA= Six bytes= 6*8 bits, BADASA = 48 bits.
DATA HIERARCHY

3. Field: A meaningful group of characters or bytes.


 For example BADASA’s last name, first name and phone no. are 3 fields.
4. Record: it is a group of interrelated fields.
 For example thus BADASA’s last name, first name and phone no.,
identity no. and home address can make up a record.
5. File: It is a collection of interrelated records
6. Database: It is an integrated repository of logically related data that facilitate
easy access and processing of data.
Data Handling Approaches in Organizations
Data Handling Approaches can be categorizing into three levels of development.
 Even though there is an advantage and a problem to overcome at each new level, all
methods of data handling are in use even today to some extent.
 The major three levels are:

a. Manual Approach i. Traditional file-based approach


b. Traditional File Based Approach ii. The Shared File Approach
c. Database Approach
iii. Database Approach
Manual Approach
 Cards and paper are used for the purpose

 Files for as many event and objects as the organization has are used to store information.

 Each of the files containing various kinds of information is labelled and stored in one or more
cabinets.

 The cabinets could be kept in safe places for security purpose (Cabinet Lockers).

 Insertion and retrieval is done by searching;


i. First For The Right Cabinet

ii. Then For The Right File

iii. Then The Information.

 One could have an indexing system to facilitate access to the data


Limitations of the Manual approach
Prone to error

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


File-Based Systems
Collection of application programs that perform services for the end users (e.g. reports).

Each program defines and manages its own data.

Limitations of File-Based Approach


a. Data dependence (Program Data Dependence)
 File structure is defined in the program code.
 Any change in the data structure need to changes the program as well

b. Incompatible file formats


 Programs are written in different languages, and so cannot easily access each other’s files.

c. Fixed Queries/Proliferation of application programs



Database Approach
Problems of file approach arose because
Definition of data was embedded in application programs, rather than being stored
separately and independent of the applications.
No control over access and manipulation of data beyond that imposed by application
programs.

Solution(Result)
The database and Database Management System (DBMS).
This approach solves the problems of the File-based Approach
Database Approach
A database is a collection of data that is organized and stored in a structured format,
allowing for easy access, manipulation, and analysis of the data.

A database is an electronic system that allows data to be easily accessed, manipulated and
updated.

A database is information that is set up for easy access, management and updating.

Databases are used for storing, maintaining and accessing any sort of data.

They collect information on people, places or things.

Databases can be thought of as an organized collection of information.


Traditional file-based approach
 The term ‘file-based approach’ refers to the situation where data is stored in one or more
separate computer files defined and managed by different application programs.
 Computer programs access the stored files to perform the various tasks required by the
business.
 Each program, or some- times a related set of programs, is called a computer application.

Limitations Traditional File-based Approach


a. Data duplication
b. Data inconsistency
c. Difficult to implement data security
The Shared File Approach
One approach to solving the problem of each application having its own set of files is to
share files between different applications.

This will alleviate the problem of duplication and inconsistent data between different
applications.

Problems of Shared File Approach


 File incompatibility

 Difficult to control access

 Physical data dependence

 Difficult to implement concurrency


The database approach
The database approach is an improvement on the shared file solution as the use of a database management

system (DBMS) provides facilities for querying, data security and integrity, and allows simultaneous access to

data by a number of different users.

Database: A database is a collection of related data.

Database management system: DBMS, refers to a software system used to create and manage databases.

System catalogue/Data dictionary: The description of the data in the database management system.

Database application: Database application refers to a program, or related set of programs, which use the

database management system to perform the computer-related tasks of a particular business function, such as

order processing.
Benefits of the database approach
1. Ease of application development
2. Minimal data redundancy: All data files are integrated into a composite data structure.
 In practice, not all redundancy is eliminated, but at least the redundancy is controlled.
3. Enforcement of standards: The database administrator can define standards for …
4. Data can be shared. New applications can use existing data definitions.
5. Physical data independence:
 Data descriptions are independent of the application programs.
 Data is stored independently of the program that uses it.
Benefits of the database approach
6. Logical data independence: Data can be viewed in different ways by different users

7. Better modelling of real-world data: Databases are based on semantically rich data
models that allow the accurate representation of real-world in-formation.

8. Uniform security and integrity controls:


Security control ensures that applications can only access the data they are required to
access.
Integrity control ensures that the database represents what it purports to represent.

9. Economy of scale: Concentration of processing, control personal and technical expertise.


Benefits of the database approach
In addition to the above benefit, also database approach has the following benefits:

1. Improved accessibility of data

2. Quality data can be maintained

3. Inconsistency can be avoided

4. Transaction support can be provided

5. Improved decision support

6. Compactness

7. Speed

8. Less labor
Risks of the database approach
1. New specialized personnel: Need to hire or train new personnel e.g. database administrators
and application programmers.

2. Need for explicit backup.

3. Organizational conflict: Different departments have different information needs and data
representation.

4. Large size: Often needs alarmingly large amounts of processing power.

5. Expensive: Software and hardware expenses.

6. High impact of failure: Concentration of processing and resources makes an organization


vulnerable if the system fails for any length of time.
Fundamental Database Concepts

1. Tables: The table is the basic data-storage unit in a relational database.

Tables consist of columns and rows.

The columns are the attributes or qualities that we want to express

A column is a specific set of values in a table of the same type.

The rows/ record hold the actual data, with one (or no) items per row.

Every record in a table has exactly the same structure, but of course different data.
Fundamental Database Concepts
2. Relationship: Relationships are THE reason why relational databases work so well.

In a relational databases, a relationship exists between two tables when one of them has a

foreign key that references the primary key of the other table.

 Primary Key: is a special column or combination of columns that uniquely identifies each record (row) in the

table and must not contain any nulls (non-values).

 Foreign Key: is used to reference the same record from another table.

3. Structured Query Language (SQL): is the de facto language used for the management and

manipulation of data in relational databases.


 SQL can be used to query, insert, update and modify data.
Database Components
1. Data: The data stored in the database.

2. Schema: The structure and organization of the data in the database, including the tables,

columns, data types, and relationships between the data.

3. Query language: A language or interface that is used to retrieve and manipulate data in the

database.

4. Indexes: Data structures that are used to improve the performance of queries and searches in

the database.
Database Components
5. Transactions: A mechanism for ensuring the consistency and integrity of the data in the database.

6. Users: The individuals or application programs that access and manipulate the data in the database.

7. Security: Tools and mechanisms for controlling access to the data and protecting it from unauthorized
access or tampering.

8. Backup and recovery: Tools and procedures for protecting the data in the event of a failure /disaster.

9. Performance monitoring: Tools and techniques for monitoring the performance and usage of the
database and identifying and resolving any issues.
Roles in Database Design and Use
1. Data Administrator (DA): is responsible on management of data resources.
 It involves in database planning, development, maintenance of standards policies and procedures at the conceptual and
logical design phases.

2. Database Administrator (DBA): is more technically oriented role.


 Responsible to oversee, control and manage the database resources.
 It involves in physical design, implementation, security and integrity control of the database
 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
Roles in Database Design and Use
3. Database Designer (DBD)
Identifies the data to be stored and choose the appropriate structures to represent and store the
data.

Should understand the user requirement and should choose how the user views the database.

Involve on the design phase before the implementation of the database system.

We have two distinctions of database designers, one involving in the logical and conceptual
design and another involving in physical design.
Roles in Database Design and Use
1. Logical and Conceptual DBD: Identifies data (entity, attributes and relationship) relevant to the organization.
 Identifies constraints on each data.

 Understand data and business rules in the organization.

 Sees the database independent of any data model at conceptual level and consider one specific data model at
logical design phase.

2. Physical DBD: Take logical design specification as input and decide how it should be physically realized.

Map the logical data model on the specified DBMS with respect to tables and integrity constraints.

 (DBMS dependent designing).

Select specific storage structure and access path to the database.

Design security measures required on the database.


Roles in Database Design and Use
3. Application Programmer and Systems Analyst
System analyst determines the user requirement and how the user wants to view the database.

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.
Roles in Database Design and Use
4. End Users
Workers, whose job requires accessing the database frequently for various purposes
It includes:
A. Naive Users,
B. Sophisticated Users,
C. Casual Users

A. Naive 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.


Roles in Database Design and Use

B. Sophisticated Users: Are users familiar with the structure of the Database and facilities
of the DBMS?
Have complex requirements and higher level queries.

Have Are most of the time engineers, scientists, business analysts, etc.

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


Database Management System (DBMS)
DBMS is a set of programs that are used to define, administer, and process databases and their
associated applications.

A DBMS is software that is designed to store, manage, and retrieve data from a database.

The DBMS serves as the intermediary between the database and the users or application programs that
need to access the data.

It is responsible for managing the data stored in the database, including:
 Storing and organizing the data
 Enforcing data integrity
 Providing access to the data for users and application programs.

It also provides tools and interfaces for creating, modifying, and querying the data in the database.
Components of DBMS environment
To design and use a database, there will be the interaction or integration of Hardware, Software,
Data, Procedure and People.
I. Hardware: are components that one can touch and feel.
II. Software: are collection of commands and programs used to manipulate the hardware to
perform a function.
III. Data: Operational and Metadata.
IV. Procedure: The rules and regulations on how to design and use a database.
V. People: the people that are responsible or play a role in designing, implementing, managing,
administering and using the resources in the database.
Advantages and Disadvantages of DBMS
Advantages of DBMS Disadvantages of DBMS

Cost: DBMSs can be expensive to set up and maintain


Data organization
Complexity: DBMSs can be complex to set up and manage,
Data integrity and may require specialized knowledge or expertise.

Dependency: Applications that use a DBMS may be too


Data security
dependent on the DBMS,
 This can cause a constraint on their flexibility and portability.
Data scalability
Performance: DBMSs can have overhead that can affect the
Data interoperability performance of the application
Languages Supported by Database Systems
Database Systems comprise of specific languages that are used by operators, programmers and end-users to
interact with Database queries and updates. There are generally 4 types of Database Languages:

i. Data Definition Language (DDL)

ii. Data Control Language (DCL)

iii. Data Manipulation Language (DML)

iv. Transaction Control Language (TCL)


Languages Supported by Database Systems
1) Data Definition/ Description Language (DDL): Is used to describe data structures, create and modify
data.

2) Data Control Language (DCL): To describe the ‘‘Rights & Permissions’’ across the Database system
 DCL commands include Revoke and Grant used to retrieve previously stored and saved data.

3) Data Manipulation Language (DML): used to access and manipulate data in the Database.
 These statements are commonly meant for handling user requests.

 DML commands include Select, Insert, Update, Delete, Merge and Call.

4) Transactional Control Language (TCL)

TCL is used to handle all the transactions within Database Systems.


TCL commands include Commit, Rollback and SavePoint.
Types of Database Systems
There are mainly 4 types of Database Systems:
i. Hierarchical Database System

ii. Network Database System

iii. Relational Database System

iv. Object-Oriented Database System


1. Hierarchical Database System
The Hierarchical Database System follows a tree-like procedure to present the data.

It arranges data in either Top-Down or Down-Up flow and defines the flow through the
parent-child relationship.

The Hierarchical Database System includes two types of relationships;


1. One-to-One: A parent can have only one child One-to-One relationship

2. One-to-Many a parent can have more than one child in a One-to-Many relationship

Example: IBM Information Management Systems (IMS), Windows Registry, RDM


Mobile, XML, and XAML.
2. Network Database System
Enables users to build Many-to-Many relationships due to which it is more complicated and
intricate than the other types of DBMS.

data is arranged in a graphical format and can be acquired through different data routes.

A child can have more than one parent and vice versa.

In this way, multiple relationships can be built in a Network Database System, permitting
enterprises to achieve efficiency.
2. Network Database System

Example:

Integrated Database Management System (IDMS),

Raima Database Manager,

TurboIMAGE,

Integrated Data Store (IDS) and Univac DMS-1100.


3. Relational Database System
Is one of the most extensive and complicated ones.

It allows developers and programmers to normalize data and organize information as rationally independent
tables.

Connections are made by using ‘‘Select’’ and ‘‘Join’’ options.

Example: DB2 and Informix Dynamic Server, Microsoft Access & SQL Server, RDB and Oracle.
4. Object-Oriented Database System
Diverse programming languages, such as Perl, Scala, .NET, Java, Python, JavaScript, Delphi,
Visual Basic and C++, are used by programmers to build relationships between variables and
establish schemas. Example: Cache, ConceptBase.cc, Db4o (Database 4 objects).
Database Models
Database Models are used to show:
How data is stored,

How it is connected,

How it can be updated, and

How to access the DBMS that is nothing but its own structure.

Some of the Database Models in DBMS are as below:

1) Entity-Relationship Model/ ER model


Graphically shows the logical relationships of entities (or say objects) to create a database.

It is also beneficial for the developers to understand the overall system by just looking at the “ER
diagram”.
1) Entity-Relationship Model/ ER model
Entity:- An entity is a real-world object, which is distinguishable from different objects.
 Like it can be a place, concept, or thing.
 Example:- Enrollment=000968347, Teacher, Building, etc
Entity Set: - Collection of entity is called entity set.
Example: - Employee Records table, Students Records table.
Relationship (Mapping): - The Relations between attributes of any two entity sets are called Mapping.
 There are four types of relationships as follow: -
a) 1: 1 (One to One) Mapping
b) 1: M (One to Many) Mapping
c) M: 1 (Many toOne) Mapping
d) M: M (Many to Many) Mapping
2) Network Model
The network model is the same as the hierarchical model, there is the only difference is that
a “record can have more than one parent”.

It can replace the Hierarchical tree with a Graph.

For Example: In the example below, we can see that the node student has two parents i.e.
Dept and Library of college. Hence It is not possible in the hierarchical model.
3 Hierarchical Model
The hierarchical model was the first “DBMS model”.

This model arranges the data in the hierarchical tree structure.

The hierarchy starts from the root which has root data, and then it expands in the form of a
tree adding child node to the parent node and so on.

The hierarchical model easily describes some real-world relationships like Food Recipes, etc
Applications of Database Systems
Some of the most common applications of Database Systems or DBMS are listed below:

Telecommunication

Sales and Marketing

Airlines

Human Resources

Banks

Education

Economics and Finance


Normalization
Normalization

 Normalization: is the process of reorganizing data in a database so that it meets two basic
requirements:
 There is no data redundancy: All data is stored in only one place
 Data dependencies are logical: All related data items are stored together
 Normalization may reduce system performance since data will be cross referenced from
many tables.
 Thus de-normalization is sometimes used to improve performance, at the cost of reduced
consistency guarantees.
 Normalization normally is considered as good if it is lossless decomposition.
Steps of Normalization:
We have various levels or steps in normalization called Normal Forms.

The level of complexity, strength of the rule and decomposition increases as we move from
one lower level Normal Form to the higher.

A table in a relational database is said to be in a certain normal form if it satisfies certain


constraints.

Normal form below represents a stronger condition than the previous one
 Normalization towards a logical design consists of the following steps:
I. Un-Normalized Form: Identify all data elements
II. First Normal Form: Find the key with which you can find all data
III. Second Normal Form: Remove part-key dependencies. Make all data dependent on the whole
key.
IV. Third Normal Form: Remove non-key dependencies. Make all data dependent on nothing but
the key.
 For most practical purposes, databases are considered normalized if they adhere to third
normal form.
First Normal Form (1NF)
Requires that all column values in a table are atomic (e.g., a number is an atomic value, while
a list or a set is not). We have two ways of achieving this: -
1. Putting each repeating group into a separate table and connecting them with a primary key
foreign key relationship.

2. Moving these repeating groups to a new row by repeating the common attributes. If so then find
the key with which you can find all data

Definition: a table (relation) is in 1NF If

a. There are no duplicated rows in the table. Unique identifier.

b. Each cell is single-valued (i.e., there are no repeating groups).

c. Entries in a column (attribute, field) are of the same kind.


Example for First Normal form (1NF)
UNNORMALIZED
FIRST NORMAL FORM (1NF)
Remove all repeating groups. Distribute the multi-valued attributes into different rows and
identify a unique identifier for the relation so that is can be said is a relation in relational
database

You might also like