01 DatabaseConcepts
01 DatabaseConcepts
Databases
Objectives
The objective of this session is to make participants
understand the Database Concepts and enable to design the
Database Schema
2
© 2017, Syntel, Inc.
Contents
Database Fundamentals
Database Views and Users
Data Models
Normalization
3
© 2017, Syntel, Inc.
Introduction to Database
DB - A set of inter-related data
MS - A software that manages the data
SCHEMA - A set of tables and relationships, which meet a specific
need
ENDUSER TOOLS
DBMS
DATA
END END
USER USER
APPLICATIONS
4
© 2017, Syntel, Inc.
Database Administrator
Is a database architect who is responsible for design and
implementation of new databases.
Manages the database centrally
Decides on the type of data, internal structures and their
relationships
Ensures the security of the database
Controls access to the data through the user codes and passwords
Can restrict the views or operations that the users can perform on
the database.
5
© 2017, Syntel, Inc.
Characteristics of DBMS
Sharing of Data
Maintenance of Integrity
6
© 2017, Syntel, Inc.
Characteristics of DBMS
Support for Transaction Control and Recovery
DBMS ensures that updates take place physically after a logical transaction is
complete.
Data Independence
Tools like query language, screen and report painter and other 4GL tools are
available.
7
© 2017, Syntel, Inc.
Characteristics of DBMS
Control over Security
DBMS provide tools by which the DBA can ensure security of the database.
Hardware Independence
Most DBMS are available across hardware platforms and operating systems.
8
© 2017, Syntel, Inc.
Levels of Abstraction
Conceptual Level :-the overall integrated structural organization of
the database
View / External Level :- the user view of the database. Different for
different user based on application requirement.
9
© 2017, Syntel, Inc.
The Data Model
Data model defines the range of data structures supported and the
availability of data handling languages
10
© 2017, Syntel, Inc.
Contd…
What is A Data Model
11
© 2017, Syntel, Inc.
Contd…
To use a common analogy, the data model is equivalent to an
architect's building plans.
A data model is independent of hardware or software constraints.
Rather than try to represent the data as a database would see it, the
data model focuses on representing the data as the user sees it in
the "real world". It serves as a bridge between the concepts that
make up real-world events and processes and the physical
representation of those concepts in a database.
12
© 2017, Syntel, Inc.
Contd…
Why is Data Modeling Important?
The goal of the data model is to make sure that the all data objects
required by the database are completely and accurately represented.
Because the data model uses easily understood notations and
natural language , it can be reviewed and verified as correct by the
end-users.
13
© 2017, Syntel, Inc.
Contd…
The data model is also detailed enough to be used by the database
developers to use as a "blueprint" for building the physical
database. The information contained in the data model will be used
to define the relational tables, primary and foreign keys, stored
procedures, and triggers. A poorly designed database will require
more time in the long-term. Without careful planning you may create
a database that omits data required to create critical reports,
produces results that are incorrect or inconsistent, and is unable to
accommodate changes in the user's requirements.
14
© 2017, Syntel, Inc.
Hierarchical Structure
In this model data is represented by simple tree structure
Relationships between entities are represented as parent-child.
Many-to-many relationships are not allowed.
Parents and children are tied together by links called "pointers"
Root
Level 1 Level 1
Child Child
15
© 2017, Syntel, Inc.
The Hierarchical Model
16
© 2017, Syntel, Inc.
Possibilities in Hierarchical Model
INSERT
DELETE
Deleting a student- the only one to take the course deletes course information.
UPDATE
To change the course name of one course, the whole database has to be
searched, this may result in data inconsistency.
17
© 2017, Syntel, Inc.
The Network Model
Network model solves the problem of data redundancy by
representing relationships in terms of sets rather than hierarchy
18
© 2017, Syntel, Inc.
The Network Model
The student and course records are linked together through a marks
record
No restrictions on number of parents
Record type can have number of parent and child record types
It is more complex than the hierarchical model because of links
Is a superset of the hierarchical model
19
© 2017, Syntel, Inc.
Possibilities in Network Model
INSERT
Inserting a course record or student record poses no problems as they can exist
without any connectors till a student takes the course.
DELETE
UPDATE
20
© 2017, Syntel, Inc.
The Relational Model
21
© 2017, Syntel, Inc.
The Relational Model
Because of lack of linkages relational model is easier to understand
and implement.
22
© 2017, Syntel, Inc.
Possibilities in Relational Model
INSERT
DELETE
UPDATE
23
© 2017, Syntel, Inc.
Relational DBMS
Examples of Relational Tables
DEPT table
Deptno Dname Loc
10 Accounting New York
20 Research Dallas
30 Sales Chicago 'row' or 'tuple'
40 Operations Boston
'column' or 'attribute'
EMPLOYEE table
Empno Empname Job Mgr Deptno
7369 Smith Clerk 7902 20
7499 Allen Salesman 7839 30
7566 Jones Manager 7839 20
7839 King President 10
7902 Ford Analyst 7566 20
24
© 2017, Syntel, Inc.
Properties of Relational Data Structures
Tables must satisfy the following properties to be classified as
relational.
25
© 2017, Syntel, Inc.
Data Integrity
Data integrity is the assurance that data is consistent, correct, and accessible
Entity Integrity:
Entity integrity ensures that no records are duplicated and that no attributes that make up the
The referential integrity rule : If a foreign key in table A refers to the primary key in table B, then
every value of the foreign key in table A must be null or must be available in table B
26
© 2017, Syntel, Inc.
Data Integrity (Cont…)
Unique Constraint:
Unique constraints ensure that every value in the specified key is unique
A table can have any number of unique constraints, with at most one unique
constraint defined as a primary key
27
© 2017, Syntel, Inc.
Data Integrity (Cont…)
DEPT table
20 Research Dallas
EMPLOYEE table
28
© 2017, Syntel, Inc.
Normalization
Normalization
30
© 2017, Syntel, Inc.
Contd…
Process of efficiently organizing data in a database
31
© 2017, Syntel, Inc.
Problems with Unnormalized Database
UPDATE ANOMALY
INSERTION ANOMALY
DELETION ANOMALY
32
© 2017, Syntel, Inc.
Example: UPDATE ANOMALY
33
© 2017, Syntel, Inc.
Example: INSERTION ANOMALY
34
© 2017, Syntel, Inc.
Example: DELETION ANOMALY
35
© 2017, Syntel, Inc.
Background to normalization:
Functional dependency
Transitive dependency
Multivalued dependency
Join dependency
Super key
Candidate key
Non-prime attribute
Primary key
36
© 2017, Syntel, Inc.
Purpose of the Normalization
1. no duplication of data
37
© 2017, Syntel, Inc.
Properties of Normalization:
Two important properties of Normalization:
38
© 2017, Syntel, Inc.
Normal forms (abbrev. NF)
39
© 2017, Syntel, Inc.
Normal Forms – Anomalies and Data Redundancies
40
© 2017, Syntel, Inc.
Relationship between Normal Forms
41
© 2017, Syntel, Inc.
Unnormalized Relation
A table that contains one or more repeating groups.
42
© 2017, Syntel, Inc.
Unnormalized relation contains non atomic values
43
© 2017, Syntel, Inc.
First Normal Form (1NF)
1NF requires that the values in each column of a table are atomic.
By atomic we mean that there are no sets of values within a column.
44
© 2017, Syntel, Inc.
Contd…
A table is in first normal form (1NF) if and only if it faithfully
represents a relation.
a table with a unique key and without any nullable columns is in 1NF
45
© 2017, Syntel, Inc.
Example of First Normal form
unnormalized data is normalized to 1NF
46
© 2017, Syntel, Inc.
Second Normal Form (2NF)
47
© 2017, Syntel, Inc.
Rules for 2NF
A table in 1NF is also in 2NF form if the values in every column are
functionally or transitively dependent on the complete primary key
For every relation with a single data item making up the primary key,
this rule should always be true. For those with the composite key
examine every column and ask whether its value depends on the
whole of the composite key or just some part of it
Remove those that depend only on part of the key to a new relation
with that part as the primary key
48
© 2017, Syntel, Inc.
Example of 2NF form
The below two tables demonstrate 2NF.
Note the multiple Class# values for each Student# value in the above
table. Class# is not functionally dependent on Student# (primary
key), so this relationship is not in 2NF.
49
© 2017, Syntel, Inc.
Third Normal form
Eliminate Columns Not Dependent On Key - If attributes do not
contribute to a description of the key, remove them to a separate
table
53
© 2017, Syntel, Inc.
The criteria for third normal form (3NF)
Rules :
A relation in the second normal form is also in the third normal form,
if the values in every non - key column are not transitively
dependent on the primary key
Examine every non - key column and question its relationship with
every other non - key column
If there is a transitive dependency remove both the columns to a
new relation
54
© 2017, Syntel, Inc.
Example of Third Normal form
In the last example, Adv-Room (the advisor's office number) is
functionally dependent on the Advisor attribute.
move that attribute from the Students table to the Faculty table, as
shown below:
55
© 2017, Syntel, Inc.
Contd…
this relation has redundancies wherein If the name of the employee
is changed, the change will have to be made in every tuple of the
relation, otherwise inconsistencies will creep up.
The table will further have to be decomposed to eliminate
dependencies between the candidate key columns as shown,
59
© 2017, Syntel, Inc.
BENEFITS OF NORMALIZATION
60
© 2017, Syntel, Inc.
DRAWBACKS OF NORMALIZATION
o requires much more CPU, memory, and I/O to process transactions and
database queries
61
© 2017, Syntel, Inc.
Summary
RDBMS are primary used for storing transactional data.
E-R Model is prepared to map the business system to
database.
Normalization is the process of refining the table schema.
62
© 2017, Syntel, Inc.
Thank You!