DBMS
DBMS
o The three schema architecture is also called ANSI/SPARC and the internal level. Its role is to define the correspondence
architecture or three-level architecture. between the records and fields of the conceptual level and files and
o This framework is used to describe the structure of a data structures of the internal level.
specific database system. External/ Conceptual Mapping
o The three schema architecture is also used to separate the The external/Conceptual Mapping lies between the external level
user applications and physical database. and the Conceptual level. Its role is to define the correspondence
o The three schema architecture contains three-levels. It between a particular external and the conceptual view.
breaks the database down into three different categories.
In the above diagram @ Database Users & Administrations:
o It shows the DBMS architecture. People who work with a database can be -> Database users ->
o Mapping is used to transform the request and response database administrators
between various database levels of architecture. Database users: are the persons who interact with the database and
o Mapping is not good for small DBMS because it takes take the benefits of database. Users are differentiating by the way
more time. they expect to interact with the system. Types:-
o In External / Conceptual mapping, it is necessary to 1. Naïve users/ Native users/ End users: they are the
transform the request from external level to conceptual unsophisticated users who use the existing application to
schema. interact with the database. Ex- people accessing database
o In Conceptual / Internal mapping, DBMS transform the over the web, bank tellers, clerical staffs.
request from the conceptual to internal level. 2. Application programmers: They are the computer
Objectives of Three schema Architecture professionals who write the application programs. They
The main objective of three level architecture is to enable multiple interact with system through DML queries. Ex-Writing a C
users to access the same data with a personalized view while program to generate report of employees who are working
storing the underlying data only once. Thus it separates the user's in particular dept., will involve a query to fetch the data
view from the physical structure of the database. from database. It will include an embedded SQl query in
1. Internal Level the C program.
o The internal level has an internal schema which describes 3. Sophisticated users: They interact with the system by
the physical storage structure of the database. writing SQL queries directly through the query processor
o The internal schema is also known as a physical schema. (like SQL) without writing application programs. Ex-
o It uses the physical data model. It is used to define that Analysts, who submits SQL queries to explore data in
how the data will be stored in a block. DBMS.
o The physical level is used to describe complex low-level 4. Specialized users: They are also sophisticated users who
data structures in detail. write specialized database applications that do not fit into
2. Conceptual Level
the traditional data processing framework. They are the
o The conceptual schema describes the design of a database developers who develop the complex programs to the
at the conceptual level. Conceptual level is also known as
requirement. Ex- Computer-Aided Design (CAD) Systems,
logical level.
Experts Systems, Knowledge Based System, etc. that store
o The conceptual schema describes the structure of the complex data types (graphics and audio data) &
whole database.
environment modelling systems.
o The conceptual level describes what data are to be stored Database Administrators:
in the database and also describes what relationship exists
DBA is a person or group that is responsible for
among those data.
supervising both the database and the use of the DBMS.
o In the conceptual level, internal details such as an DBAs coordinate all the activities of the database system.
implementation of the data structure are hidden.
They use specialised software to store and organize data.
o Programmers and database administrators work at this They have all the permissions.
level.
DBA tasks:
3. External Level
Schema definition
o At the external level, a database contains several schemas
Storage structure and access method definition
that sometimes called as subschema. The subschema is
Schema and physical organization modification
used to describe the different view of the database.
Specifying integrity constrains
o An external schema is also known as view schema.
Granting user authority to access database
o Each view schema describes the database part that a
Monitoring performance & responding to changes in
particular user group is interested and hides the remaining
requirements
database from that user group.
Routine maintenance
o The view schema describes the end user interaction with
Acting as liaison with users
database systems.
Mapping between Views Backing up and restoring databases
@ Normalization
The three levels of DBMS architecture don't exist independently of
A large database defined as a single relation may result in data
each other. There must be correspondence between the three levels
duplication. This repetition of data may result in:
i.e. how they actually correspond with each other. DBMS is
Making relations very large.
responsible for correspondence between the three types of schema.
It isn't easy to maintain and update data as it would
This correspondence is called Mapping.
involve searching many records in relation.
There are basically two types of mapping in the database
Wastage and poor utilization of disk space and resources.
architecture:
The likelihood of errors and inconsistencies increases.
o Conceptual/ Internal Mapping
So to handle these problems, we should analyse and decompose
o External / Conceptual Mapping
the relations with redundant data into smaller, simpler, and well-
Conceptual/ Internal Mapping
structured relations that are satisfying desirable properties.
Normalization is a process of decomposing the relations into A table is in BCNF if every functional dependency X → Y, X
relations with fewer attributes. is the super key of the table.
What is Normalization? For BCNF, the table should be in 3NF, and for every FD,
Normalization is the process of organizing the data in the LHS is super key.
database. Rules for BCNF
Normalization is used to minimize the redundancy from a Rule 1: The table should be in the 3rd Normal Form.
relation or set of relations. It is also used to eliminate Rule 2: X should be a super key for every functional dependency
undesirable characteristics like Insertion, Update, and (FD) X−>Y in a given relation.
Deletion Anomalies. Fourth normal form (4NF)
Normalization divides the larger table into smaller and A relation will be in 4NF if it is in Boyce Codd normal form
links them using relationships. and has no multi-valued dependency.
The normal form is used to reduce redundancy from the For a dependency A → B, if for a single value of A, multiple
database table. values of B exists, then the relation will be a multi-valued
Types of Normal Forms: dependency.
Normalization works through a series of stages called Normal Fifth normal form (5NF)
forms. The normal forms apply to individual relations. The relation is o A relation is in 5NF if it is in 4NF and not contains any join
said to be in particular normal form if it satisfies constraints. dependency and joining should be lossless.
Following are the various types of Normal forms: o 5NF is satisfied when all the tables are broken into as many
1NF: A relation is in 1NF if it contains an atomic value. tables as possible in order to avoid redundancy.
2NF: A relation will be in 2NF if it is in 1NF and all non-key o 5NF is also known as Project-join normal form (PJ/NF).
attributes are fully functional dependent on the primary key.
3NF: A relation will be in 3NF if it is in 2NF and no transition A relation R is in Fifth Normal Form if and only if everyone joins
dependency exists. dependency in R is implied by the candidate keys of R. A relation
BCNF: A stronger definition of 3NF is known as Boyce Codd's decomposed into two relations must have lossless join Property,
which ensures that no spurious or extra tuples are generated
normal form. when relations are reunited through a natural join.
4NF: A relation will be in 4NF if it is in Boyce Codd's normal form Properties
and has no multi-valued dependency. A relation R is in 5NF if and only if it satisfies the following
5NF: A relation is in 5NF. If it is in 4NF and does not contain any join conditions:
dependency, joining should be lossless. 1. R should be already in 4NF.
First Normal Form (1NF) 2. It cannot be further non loss decomposed (join
A relation will be 1NF if it contains an atomic value. dependency).
@ Join Dependency
It states that an attribute of a table cannot hold multiple
Join decomposition is a further generalization of multivalued
values. It must hold only single-valued attribute. dependencies. If the join of R1 and R2 over C is equal to relation
First normal form disallows the multi-valued attribute, R then we can say that a join dependency (JD) exists, where R1
composite attribute, and their combinations. and R2 are the decomposition R1(A, B, C) and R2(C, D) of a
Second Normal Form (2NF) given relations R (A, B, C, D). Alternatively, R1 and R2 are a
In the 2NF, relational must be in 1NF. lossless decomposition of R. A JD ⋈ {R1, R2, …, Rn} is said to
In the second normal form, all non-key attributes are fully hold over a relation R if R1, R2, ….., Rn is a lossless-join
functional dependent on the primary key decomposition. The *(A, B, C, D), (C, D) will be a JD of R if the
join of joins attribute is equal to the relation R. Here, *(R1, R2, R3)
Third Normal Form (3NF)
is used to indicate that relation R1, R2, R3 and so on are a JD of
A relation will be in 3NF if it is in 2NF and not contain any
R. Let R is a relation schema R1, R2, R3……..Rn be the
transitive partial dependency. decomposition of R. r( R ) is said to satisfy join dependency if and
3NF is used to reduce the data duplication. It is also used only if
to achieve the data integrity.
If there is no transitive dependency for non-prime
attributes, then the relation must be in third normal form. Joint Dependency
A relation is in third normal form if it holds at least one of the o Join decomposition is a further generalization of
following conditions for every non-trivial function dependency X → Multivalued dependencies.
Y. o If the join of R1 and R2 over C is equal to relation R, then
1. X is a super key. we can say that a join dependency (JD) exists.
2. Y is a prime attribute, i.e., each element of Y is o Where R1 and R2 are the decompositions R1(A, B, C) and
R2(C, D) of a given relations R (A, B, C, D).
part of some candidate key.
Boyce Codd normal form (BCNF) o Alternatively, R1 and R2 are a lossless decomposition of R.
Application of the general definitions of 2NF and 3NF may o A JD ⋈ {R1, R2,..., Rn} is said to hold over a relation R if R1,
identify additional redundancy caused by dependencies that R2,....., Rn is a lossless-join decomposition.
violate one or more candidate keys. However, despite these o The *(A, B, C, D), (C, D) will be a JD of R if the join of join's
additional constraints, dependencies can still exist that will cause attribute is equal to the relation R.
redundancy to be present in 3NF relations. This weakness in 3NF o Here, *(R1, R2, R3) is used to indicate that relation R1, R2,
R3 and so on are a JD of R
resulted in the presentation of a stronger normal form
called the Boyce-Codd Normal Form (Codd, 1974). Although, 3NF
What is Join?
is an adequate normal form for relational databases, still, this Join is an operation in DBMS(Database Management System)
(3NF) normal form may not remove 100% redundancy because of that combines the row of two or more tables based on related
X−>Y functional dependency if X is not a candidate key of the columns between them. The main purpose of Join is to retrieve
given relation. This can be solved by Boyce-Codd Normal Form the data from multiple tables in other words Join is used to
(BCNF). perform multi-table query. It is denoted by ⨝.
Syntax-
BCNF is the advance version of 3NF. It is stricter than 3NF. R3 <- ⨝(R1) <join_condition> (R2)
where R1 and R2 are two relations to be join and R3 is a relation
that will holds the result of join operation.
Types of Join Table A Table B
1. Inner Join Number Square Number Cube
2. Outer join
Inner join
Inner Join is a join operation in DBMS that combines two or more 2 4 2 8
table based on related columns and return only rows that have
matching values among tables.Inner join of two types.
3 9
Equi Join 3 27
Natural Join
Equi Join 4 16 5 75
Equi Join is a type of Inner join in which we use equivalence(‘=’)
condition in join condition. A⟕B
Example: Result:
Table A Table B
Number Square Cube
Column Column Column Column
A B A B 2 4 8
a a a a
3 9 27
a b a c 4 16 –
Natural Join 2 4 8
Natural join is a type of inner join in which we not need of any
comparison operators. In natural join columns should have the
same name and domain. There should be at least one common 3 9 27
attribute between two tables.
Eample:
Table A Table B 5 – 75
2 4 8
3 9 27
3 9 27
4 16 –
Outer Join
@ ER Model
The Entity Relational Model is a model for identifying entities to be
represented in the database and representation of how those
entities are related. The ER data model specifies enterprise schema
that represents the overall logical structure of a database
graphically.
The Entity Relationship Diagram explains the relationship among
the entities present in the database. ER models are used to model
real-world objects like a person, a car, or a company and the
relation between these real-world objects. In short, the ER Diagram
is the structural format of the database.
Symbols Used in ER Model
Rectangles: Rectangles represent Entities in the ER Model.
Ellipses: Ellipses represent Attributes in the ER Model.
Diamond: Diamonds represent Relationships among Entities.
Lines: Lines represent attributes to entities and entity sets with other
relationship types.
Double Ellipse: Double Ellipses represent Multi-Valued Attributes
Double Rectangle: Double Rectangle represents a Weak Entity.