Q.1 What Is Normalisation? ANSWER:-Normalisation Is The Process of Structuring A Relational Database in Accordance
Q.1 What Is Normalisation? ANSWER:-Normalisation Is The Process of Structuring A Relational Database in Accordance
OBJECTIVES
To free the collection of relations from undesirable insertion, update and deletion
dependencies.
To reduce the need for restructuring the collection of relations, as new types of data are
introduced, and thus increase the life span of application programs.
To make the relational model more informative to users.
To make the collection of relations neutral to the query statistics, where these statistics
are liable to change as time goes by.
EXAMPLE
Below is a table that stores the names and telephone numbers of customers. One requirement
though is to retain multiple telephone numbers for some customers. The simplest way of
satisfying this requirement is to allow the "Telephone Number" column in any given row to
contain more than one value:
Customer
The telephone number column contains multiple phone numbers in a single value. For example,
the first row has two telephone numbers separated by a comma. The column values are not
atomic: it can be subdivided into two numbers. This violates first normal form.
Customer
Customer Telephone
First Name Surname Telephone Number2
ID Number1
Technically, this table does not violate the requirement for values to be atomic. However,
informally, the two telephone number columns still form a "repeating group": they repeat what
is conceptually the same attribute, namely a telephone number. An arbitrary and hence
meaningless ordering has been introduced.
ALTERNATIVE 1:
To bring the model into the first normal form, we split the strings we used to hold our telephone
number information into "atomic" (i.e. indivisible) entities: single phone numbers. And we
ensure no row contains more than one phone number.
Customer
Customer Surnam
First Name Telephone Number
ID e
1 123 9373636474
123 Pooja Singh
2 123 8976737363
456 San Zhang
3 456 7672677272
789 John Doe
4 456 9292929345
5 789 9834784748
Columns do not contain more than one telephone number in this design. Instead, each Customer-
to-Telephone Number link appears on its own row. Using Customer ID as key, a one-to-
many relationship exists between the name and the number tables. A row in the "parent"
table, Customer Name, can be associated with many telephone number rows in the "child"
table, Customer Telephone Number, but each telephone number belongs to one, and only one
customer.
ANSWER :- A key is an attribute or set of an attribute which helps you to identify a row in a
relation(table). They allow you to find the relation between two tables. Keys help you uniquely
identify a row in a table by a combination of one or more columns in that table.
PRIMARY KEY is a column or group of columns in a table that uniquely identify every row in
that table. The Primary Key can't be a duplicate meaning the same value can't appear more than
once in the table. A table cannot have more than one primary key.
11 Andrew Johnson
22 Tom Wood
33 Alex Hale
ALTERNATE KEY is a column or group of columns in a table that uniquely identify every row
in that table. A table can have multiple choices for a primary key but only one can be set as the
primary key. All the keys which are not primary key are called an Alternate Key.
Example:
In this table, StudID, Roll No, Email are qualified to become a primary key. But since StudID is
the primary key, Roll No, Email becomes the alternative key.
StudID Roll No First Name LastName Email
CANDIDATE KEY is a set of attributes that uniquely identify tuples in a table. Candidate Key is
a super key with no repeated attributes. The Primary key should be selected from the candidate
keys. Every table must have at least a single candidate key. A table can have multiple candidate
keys but only a single primary key.
Example: In the given table Stud ID, Roll No, and email are candidate keys which help us to
uniquely identify the student record in the table.
"Persons" table:
1 Hansen Ola
2 Svendson Tove
3 Pettersen Kari
"Orders" table:
1 77895 3
2 44678 3
3 22456 2
4 24562 1
Notice that the "PersonID" column in the "Orders" table points to the "PersonID" column in the
"Persons" table.
The "PersonID" column in the "Persons" table is the PRIMARY KEY in the "Persons" table.
The "PersonID" column in the "Orders" table is a FOREIGN KEY in the "Orders" table.
The FOREIGN KEY constraint is used to prevent actions that would destroy links between tables.
It also prevents invalid data from being inserted into the foreign key column, because it must be
one of the values contained in the table it points to.