You are on page 1of 25

Features of good

relational design
and schema
refinement

By Shivam Chauhan -
11814901719, BBA(G) IV-C.
Features of good relational
design
I. Relation for every entity
II. Lesser number of Null values
III. No spurious tuples
IV. No Redundancy
V. No modification anomaly
1. Relation For Every Entity
Attributes describe
the characteristics or – Informally, each tuple in a relation should represent one entity or
properties of an entity
in a database table. ... relationship instance. (Applies to individual relations and their
The attribute values,
of each student entity,
attributes).
will define its – Attributes of different entities (EMPLOYEEs, DEPARTMENTSs,
characteristics in the
table. In a relational PROJECTs) should not be mixed in the same relation.
database, we store
data in the form of – Only foreign keys should be used to refer to other entities.
tables. The column
header of the table
– Entity and relationship attributes should be kept apart as much as
represents possible.
the attributes.
2. Lesser Number of Null Values:
– Relations should be designed such that their tuples will have as
few NULL values as possible.
– Attributes that are NULL frequently added in separate relations
(with the CPL primary key).
– Reasons for nulls:
• Attributes not applicable or invalid
• Attribute value unknown (may exist)
• Value known to exist, but unavailable
3. Decomposition (Spurious Tuples):
Spurious Tuples are
those rows in a table,
which occur as a result – Bad designs for a relational database may result in erroneous
of joining two tables in
wrong manner. They are
results for a certain JOIN operations.
extra tuples (rows) – The “lossless join” property is used to guarantee meaningful
which might not be
required. results for join operations.
In database- – The relations should be designed to satisfy the lossless join
ese, spurious condition.
tuples are created
when two tables are – No spurious tuples should be generated by doing a natural-join of
joined on attributes that
are neither primary keys any relations.
nor foreign keys.
– There are two important properties of decompositions:
1. Non-addictive or of the corresponding join losslessness.
2. Preservation of the functional dependencies.

– Lossless Decomposition.
– It is a process of splitting a relation into multiple relations and joins
back the relations to get the original relation.
Here is an example
of spurious tuples.
Where we have a
schema for ID,
Name and Year of Example of Spurious Tuples
birth of two
different people.
ID NAME YOB
If we separate it
into two relation 1 100 Vinesh 2015
has ID and Name 200 Vinesh 1980
and relation 2 has
Name and Year of
birth. If we separate it into two

ID NAME NAME YOB


100 Vinesh Vinesh 2015
200 Vinesh Vinesh 1985

Relation 1 Relation 2
Here spurious
tuples are ID NAME YOB
created after the 100 Vinesh 2015
two tables were
100 Vinesh 1980
joined in the
wrong manner. 200 Vinesh 2015 Spurious Tuples
200 Vinesh 1980

Normal forms are the best to handle these issues.


the inclusion of 4. Data Redundancy
extra
components
which are not – Redundancy is storing the same data item in more than one place.
strictly necessary
to functioning, in – A redundancy creates several problems like the following:
case of failure in
other 1. Extra storage space: storing the same data in many places takes large
components. amount of disk space.
Redundancy 2. Entering same data more than once during data insertion.
-Unnecessary
3. Deleting data from more than one place during deletion.
4. Modifying data in more than one place.
5. Anomalies may occur in the database if insertion, deletion, modification
etc are not done properly. It creates inconsistency and unreliability in
the database.
5. Modification Anomaly:
– Every schema must ensure the guarantee of the data when
modification happens to the data.

– Types of anomaly:
1. Update Anomalies
2. Deletion Anomalies
3. Insert Anomalies
1. Update Anomalies
– If data items are scattered and are not linked to each other
properly, then it could lead to strange situations.
– For example, when we try to update one data item having its
copies scattered over several places, a few instances get updated
properly while few others are left with old values.

– Such instances leave the database in an inconsistent state.


2. Deletion Anomalies
– We tried to delete a record, but parts of it was left undeleted because of
unawareness, the data is also saved somewhere else.
3. Insert Anomalies
– We tried to insert data in a record that does not exist at all.

Now I will be explaining these anomalies with the help of an example.


Example of Update, Deletion and
Insert Anomalies.
Here we can see a
schema for students
name, email, course
and instructor.
Schema for student’s name, email, course and instructor.
Suppose vinesh
changes his email Student Name Student Email Course Instructor
address we will have
update anomaly as… Vinesh vinesh@gmail.com Multimedia Lokesh
Vinesh vinesh@gamil.com Web designing Pandiyan
Arun a1@gmail.com Multimedia Lokesh
MK mk@gamil.com C++ Sunny

1. Vinesh changes his email address. (Update Anomaly)


2. Vinesh drops web designing. (Deletion Anomaly)
3. Creates a new course, networking. (Insertion Anomaly)
– Update Anomaly: because in this case if a user changes his email address , it
will affect all the tuples which matches the email.
– Insertion Anomaly:When a new course is introduced and there is no
corresponding student available, so student name , email etc will be empty.
– Deletion Anomaly: When a student drops a course , the corresponding details
of the student may also be deleted.
Definition of schema: Design of a database is called the schema. Schema is of
three types: Physical schema, logical schema and view schema. ... The design
of a database at physical level is called physical schema, how the data stored in
blocks of storage is described at this level.

Schema Refinement
The term "schema"
refers to the The Schema Refinement refers to refine the schema by using some
organization of data as technique. The best technique of schema refinement is decomposition.
a blueprint of how the
database is constructed Schema Refinement is a technique of organizing the data in the
(divided into database
tables in the case of
database. It is a systematic approach of decomposing tables to eliminate
relational databases). data redundancy and undesirable characteristics like Insertion, Update
The formal definition of
a database schema is
and Deletion Anomalies. Redundancy refers to repetition of same data
a set of formulas or duplicate copies of same data stored in different locations. Anomalies:
(sentences) called
integrity constraints Anomalies refers to the problems occurred after poorly planned and
imposed on a database normalized databases where all the data is stored in one table which is
sometimes called a flat file database.
Two levels of designing relation
schemas

– The logical "conceptual" level: It explains how users interpret the


relation schemas and the meaning of their attributes. It also enables the
user to clearly understand the meaning of data in the relations.

– The storage "base relation" level: Design and storage processes are
concerned mainly with base relations. It explains how the tuples in a
base relation are stored.
INFORMAL DESIGN GUIDELINES FOR
RELATION SCHEMA

– Semantics of the attributes: Semantic specifies how to interpret the


attribute values stored in a tuple of relation. Whenever we group
attributes to form a relation schema, certain meaning is associated with
the attributes. The attribute defined must be self explanatory. Informally,
each tuple in a relation should represent one entity or relationship
instance. (Applies to individual relations and their attributes).
– Attributes of different entities: (EMPLOYEES, DEPARTMENTS and PROJECT's)
should not be mixed in the same relation. Only foreign keys should be used to
refer to other entities.

– Reducing the redundant values in tuples: Goal of schema design is to


minimize the storage space that the databases occupy. Grouping attributes
into relation schema has a significant effect on storage space. For example,
the space consumed by two relations or database employee and department
is less than the space consumed by Emp dept relation or database.
– Reducing the null values in tuples: If many attributes do not
have values for the some tuples in the relation or in database,
we end up with a number of NULL values in those tuples. For
example a database defines with five telephone numbers but
most of the tuples have only one or two telephone entries then
there exist a number null values. Null values have multiple
interpretations.
– Disallowing spurious or false tuple: Sometimes when we combine
the tuple from two relations, we get spurious or wrong tuples/
information that is not valid; to solve this problem we join those with
the equality operator. In other words, bad designs for a relational
database may result in erroneous results for certain JOIN operations.
MCQ 1
Q1. Reducing the redundant values in tuples Goal of schema design is
to ___Answer: A)____________________________.
A) to minimize the storage space that the databases occupy.
B) to maximize the storage space that the databases occupy.
C) neither A nor B.
MCQ 2
Q2. Bad designs for a relational database may result in erroneous
results for certain JOIN operations. Answer: A) True

A) True
B) False
MCQ 3
Q3.  Which of the following is not a feature of a good relational
design? Answer: B
A) No redundancy
B) More number of Null values
C) No modification anomaly
D) Relation for every entity
Thank You

You might also like