Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
173 views

Unit 4 Rdbms

The document discusses relational database design and normalization. It covers relational data structures, data manipulation, integrity constraints including domain, referential, entity and key constraints. It also discusses functional dependencies and different normal forms including 1NF, 2NF, 3NF, BCNF, 4NF and 5NF. The goal of normalization is to reduce data redundancy and dependency by splitting relations into smaller, more manageable pieces. The document provides examples and definitions for each concept.

Uploaded by

Patel Dhruval
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
173 views

Unit 4 Rdbms

The document discusses relational database design and normalization. It covers relational data structures, data manipulation, integrity constraints including domain, referential, entity and key constraints. It also discusses functional dependencies and different normal forms including 1NF, 2NF, 3NF, BCNF, 4NF and 5NF. The goal of normalization is to reduce data redundancy and dependency by splitting relations into smaller, more manageable pieces. The document provides examples and definitions for each concept.

Uploaded by

Patel Dhruval
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 46

Relational Database Management

System
Prof. Manish Kumar Joshi, Assistant Professor
Prof. Nishant Khatri, Assistant Professor
Parul Institute Of Computer Application.
CHAPTER-4
Relational Database Design
Relational Data Structure
A type of DS (Data Structure) in which data are represented as tables in which no
entry contains more than one value.
Features of relational Data structure
All data stored in the tables are provided by an Relational Database Management
System.
Ensures that all data stored are in the form of rows and columns
Facilitates primary key, which helps in uniquely identification of the rows
Index creation for retrieving data at a higher speed.
Facilitates a similar or common column to be shared amid two or more tables.
Multi-users accessibility is facilitated to be controlled by individual users
A virtual table creation is enabled to store sensitive data and simplifies queries.
Relational data manipulation
One of the primary functions of a database management system (DBMS) is to be
able to manipulate data. This means adding new data, changing the values of
existing data and reorganizing the data. Other basic form of data manipulation is to
retrieve specific information from the database.
For example, for a database of employees within an organization, you may want to
find just the employees hired within the last year or those holding a certain
position. In database terminology, this is called a query. The term 'query' means 'to
search, to question or to find.' So, a database query is like asking a question of the
database.
Integrity constraint
Integrity constraints are a set of rules. It is used to maintain the quality of
information.
Integrity constraints ensure that the data insertion, updating, and other processes
have to be performed in such a way that data integrity is not affected.
Since, integrity constraint is used to guard against accidental damage to the
database.
Types of Integrity constraint

Image From Self


Domain Constraints
Domain Constraints : Domain constraints can be define as the definition of a valid
set of values for an attribute.
The data type of domain which includes string, character, integer, time, date,
currency, etc. The values of the attribute must be available in the corresponding
domain.

Image From Self


Referential Integrity Constraints
Referential Integrity Constraints: A referential integrity constraint is specialised
between two tables.
In this type of Referential Integrity constraints, if a foreign key in Table 1 refers to
the Primary Key of Table 2, then every value of the Foreign Key in Table1 must be
null() or be available in Table2.

Image From Self


Entity Integrity Constraints
Entity integrity constraints :The Entity integrity constraint define that primary
key value can't be null.
This is because the primary key value is used to identify or uniquely individual
rows in relation and if the primary key has a null value, then we can't identify
those rows.
A tables can contain a null value other than the primary key field.

Image From Self


Key Constraints
• Key constraints: Keys are the entity set that is used to identify an entity
within its entity set unique.
• An entity set can have many keys, but out of which one key will be the
primary key. A primary key contain a unique and null value in the relational
table.

Image From Self


Function Dependency
Functional Dependency is a relationship that occurs between multiple attributes
of a relation.
This concept is given by E.F.Codd (Edgar Freak Codd).
Functional dependency represents a formalism on the infrastructures of relation.
Its a type of constraint existing between various attributes of a relation.
It is used to describe various normal forms.
These dependencies are restrictions imposed on the data in database.
If P is a relation with A and B attributes, a functional dependency between these
two attributes is represented as {A → B}. It specifies that,
A It is a determinant set.
Function Dependency
B It is a dependent attribute. {A → B}A functionally determines B.
B is a functionally dependent on A.
Each value of A is associated precisely with other one B value. A function
dependency is trivial if B is a subset of A.
'A' Functionality determines 'B' {A → B} (Left hand side attributes determine the
values of Right hand side attributes).

Image From Self


Function Dependency
In the above <Employee> table, EmpName (employee name) is functionally
dependent on EmpId (employee id) because the EmpId is unique for individual
names.
The EmpId identifies the employee specifically, but EmpName cannot distinguish
the EmpId because more than one employee could have the same name.
The functional dependency between attribute eliminates the repetition of
informations.
It is related to a candidate key, which uniquely identifies a tuple and determines
the value of all other attributes in the relation.
Advantages of Functional Dependency
•Functional Dependency avoid data redundancy (Repetitions) where same data
should not be repeated at multiple locations in same database.
•It maintains the quality of data in database.
•It allows clearly defined meanings and constraints of databases.
•It helps in identifying bad designs.
•It expresses the facts about the database design.
Normalization
Database normalizations is a database schema design techniques, by which an existing
schema is modified to reduce the redundancy and dependency of data.
Normalization split a long table into smaller table and defines relationships between
them to increases the clarity in organizing data.
Some facts About database Normalization
•The word normalization and normal form refer to the structure of a database.
•Normalization was developed by IBM researcher E.F. Codd In the 1970s.
•Normalization increases clarity in organizing data in Databases.
•Normalization of a Database is achieved by following a set of rules
called 'forms' in creating the database
First Normal Form (1NF)
•First normal form enforces these criteria:
•Eliminate repeating groups in individual tables.
•Creates a different table for each set of related data.
•Identify every set of related data with a primary key.

Image From Self Image From Self


Second normal form[2nf]
The entity should be considered already in 1NF, and all attributes within the entity
should only depend solely on the unique identifier of the entity.
eg:-
Sample Products table:
Second normal form[2nf]
Second normal form[2nf]
Third normal form(3nf)
The entity should be considered within 2NF, and no columns entry should be
dependent on any other entry (value) other than the key for the table.
If such an entity exists, move it outside into a new tables.
3NF(Third Normal Form) is achieved, considered as the database is normalized.
 
A relations will be in 3NF if it is in 2NF and not contain any transitive partial
dependencys.
3NF is used to reduce or minimise the data duplication. It is also used to achieve
the data integrity.
If there is no transitive dependency for non-prime attribute, then the relation
must be in third normal form.
Third normal form(3nf)
A relation is in third normal form if it holds at least one of the following conditions
for every non-trivial function dependency X → Y.
X is a super key.
Y is a prime attribute, example:- each element of Y is part of some candidate key

Image from self


Third normal form(3nf)
Third normal form(3nf)
BCNF[Boyce codd normal form]
3NF(Third Normal Form) and all tables in the database should be only one primary
key.
BCNF is the advance or new version of 3NF. It is stricter than 3NF.
A table is in BCNF if every functional dependency X → Y, X is the super key of
the tables.
For BCNF, the table should be in 3NF, and for every FD, LHS is super keys.
BCNF[Boyce codd normal form]
BCNF[Boyce codd normal form]
BCNF[Boyce codd normal form]
BCNF[Boyce codd normal form]
Fourth normal form[4nf]
Table cannot have multi-valued dependency on a Primary Key(Null).
A relation will be in 4NF if it is in BoyceCodd normal form and has no multi-
valued dependency.
For dependency A → B, if for a single value of A, multiple values of B exists, then
the relation will be a multi-valued dependency.
Fourth normal form[4nf]
Fourth normal form[4nf]
Fourth normal form[4nf]
Fifth normal form [5nf]
A relations is in 5NF if it is in 4NF and not contains any join dependency and
joinings should be lossless.
5NF (Fifth Normal Form)is satisfied when all the tables are broken into as many
tables as possible in order to avoid redundancy.
5NF is also called as Project-join normal form (PJ/NF).
Fifth normal form [5nf]
Fifth normal form [5nf]
Fifth normal form [5nf]
Domain-Key Normal Form (DCNF)
There is no rule to define normal form up to 5NF. Historically the process of
normalization and the processes of discovering undesirable dependencies were
carried through 5NF, but it has been possible to define the stricter normal form that
takes into accounts additional type of dependency and constraint.
The basic idea behind the Domain Key Normal Form is to specify the normal form
that takes in the account all the possible dependencies and constraints.
In simple words, we can say that Domain Key Normal Form is a normal form used
in database normalization which requires that the database contains no constraints
other than domain constraints and key constraints.
Domain-Key Normal Form (DCNF)
In other word, a relation schema is said to be in Domain Key Normal Form only if
all the constraints and dependencies that should hold on the valid relation state can
be enforced simply by enforcing the domain constraints and the key constraints on
the relation. For a relation in Domain Key Normal Form , it becomes very straight
forward to enforce all the database constraints by simply checking that each
attribute value is a tuple (Mathematical Row) is of the appropriate domain and that
every key constraint is enforced.
Reason to use DKNF are follow:
To avoid general constraints in the database that are not clear key constraint.
Most database can easily test or check key constraints on attribute.
Domain-Key Normal Form (DCNF)
Since, because of the difficulty of including complex constraints in a Domain Key
Normal Form relation its practical utility is limited means that they are not in
practical use, since it may be quite difficult to specified general integrity constraints.
Let’s understand this by taking an example:
Consider relations CAR (MAKE, vin#) and MANUFACTURE (vin#, country),
Where vin# represents the vehicle identification number ‘country’ represents the
name of the country where it is manufactured.
Domain-Key Normal Form (DCNF)
A general constraints may be of the following forms:
The Make is either ‘HONDA’ or ‘MARUTI’ then the first character of the vin # is a
‘B’ If the country of manufacture is ‘INDIA’
If the MAKE is either ‘FORD’ or ‘ACCURA’, the 2nd character of the vin# is a
‘B” if the country of manufacture is ‘INDIA’.
There is no simplified way to represents such constraint short of writing a
procedure or general assertion to test them. Since such a procedure needs to
enforce an appropriate integrity constraint. Hence, transforming a higher normal
form into domain/key normal form is not always a dependency-preserving
transformation and these are not possible always.
Denormalization
Denormalization is a database optimizations method in which we add redundant
data to one or more table. This can help us avoid costly joins in a relational
database. Note that denormalization does not mean that we do not have to do
normalization. It is an optimizations technique that is applied after doing
normalization.
In a traditional normalized database, we store data in different logical tables and
attempt to minimize redundant data. We may strive to have only one copy of each
piece of data in database.
Denormalization
For eg:-, in a normalized database, we might have a Course table and a Teachers table
.Each entry in Courses would store the teacherID for a Course but not the
teacherName. When we need to retrieve a list of all Courses with the Teacher name,
we would do a joins among these two tables.
In many ways, this is great; if a teacher changes is or her name, we only have to
update the name in one place.
The disadvantage is that if tables are large, we may spend an unnecessarily long time
doing joins on tables.
Denormalization, then, strikes a different compromise. Under denormalization, we
decide that we’re okay with some redundancy and some extra effort to update the
database in order to get the efficiency advantages of fewer or less joins.
Pros Of Denormalization
•Retrieving or data fetching of data is faster hence we do fewer joins
•Queries to retrieve can be easier or simpler(and therefore less likely to have bugs),
hence we need to look at fewer tables.
Cons of Denormalization
•Updates and inserts are more expensive.
•Denormalization make supdates and insert code hard to write.
•Data may be inconsistent
•Data redundancy necessitates more storage.
•In a system that demand scalability, like that of any major tech companies, we
almost always use elements of both of the things normalized and denormalized
database.
www.paruluniversity.ac.in

You might also like