Uni Iii
Uni Iii
3.2 DECOMPOSITION
Decompose a relation schema that has many attributes into several schemas with
fewer attributes. Careless decomposition, however, may lead to another form of bad
design.
Consider an alternative design in which we decompose Lending-schema into the
following two schemas:
Branch-customer-schema = (branch-name, branch-city, assets, customer-name)
Customer-loan-schema = (customer-name, loan-number, amount)
We construct our new relations branch-customer
(Branch-customer) and customer-loan (Customer-loan-schema):
branch-customer = Πbranch-name, branch-city, assets, customer-name(lending)
customer -loan = Πcustomer-name, loan-number, amount(lending)
Example: A B C D
a1 B1 c1 d1
a1 B1 c1 d2
a1 B2 c2 d1
a2 B1 c3 d1
First normal form is a relation in which the intersection of each row and
column contains one and only one value. To transform the unnormalized table to fist
normal form, we identify and remove the repeating groups within the table. A
repeating group is a set of columns that store similar information that repeats in the
same table.
Example:
Create table Contacts (
Contact_ID integer
L_name varchar(10)
F_name varchar(10)
Contact_date1 date
Contact_desc 1 varchar(50));
The above data structure contains a repeating group of the date and description
of two conversations.
To eliminate the repeating group is moved to another table (i.e using the
decomposition concept), which is then related to the parent table. The primary key of
the parent table (contact_id) is stored in the second table. Moving the repeating group
in to another table allows any number of conversations to be recorded and searched
easily.
Example:
1. Create table Contacts(
Contact_id integer (6) notnull
L_name Varchar(20) Notnull // relation (First part)
F_name varchar(20));
The above table is in 3NF. Here the department and HOD are duplicated.
Further, if professor P2 resigns, 3rd and 4th row will be deleted.
The normalization of the relation is done by creating a new relation for department and
HOD of deleting HOD from professor relation, as shown below:
Pcode Dept. %time
P1 Phy 50
P1 Maths 50
P2 Che 25
P2 Phy 75
P3 Maths 100
Dept. HOD
Phy SN
Maths MR
Che NM
Multivalued Dependencies
Let R be a relation schema and let X and Y be the subset of attributes of R.
Intuitively, the multivalued dependency X Y is said to hold over R if, in every
legal instance r of R, each X values and this set is independent of the values in the other
attribute.
i.e, if t1 ε r, t2 ε r, and t1.X = t2.X, then there must be some t3 ε r such that t1.XY = t3.XY
and t2.Z = t3.Z
X Y Z
A B1 C1
A B2 C2
A B1 C2
A B2 C1
The rules on MVDs are,
MVD Complementation: if X Y, then X R – XY
MVD Augmentation: if X Y and W Z, then WX YZ.
MVD Transitivity: if X Y and Y Z, then X (Z-Y)
Replication: if X Y, then X Y
Coalescence: if X Y and there is a W such that W ∩ Y is empty, W Z, and
Y Z, then XZ.
Join Dependencies
A join dependency |X| {R1, R2, …, Rn} is said to hold over a relation R if
R1,R2,..,Rn is a lossless-join decomposition of R. An MVD X Y over a relation R can
be expressed as the join dependency |X| {XY, X(R-Y)}
The relation given in the above table is in 3NF and also in BCNF. This relation is
reduced by expressing this relation as 2 relations in fourth normal form (4NF), which
has no more than one independent multivalued dependency or one dependent
multivalued dependency with a functional dependency.
Because, this can be expressed as the 4NF as below; ie., the fact that vendors are
capable of supplying certain items and that they are assigned to supply for some
projects in independently specified in the 4NF relation.
Vendor Supply Vendor Project
Vcode Item Code Vendor Code Project code
V1 I1 V1 P1
V1 I2 V1 P3
V2 I2 V2 P1
V2 I3 V3 P1
V3 I1 V3 P2
Project No Item code
P1 I1
P1 I2
P2 I1
P3 I1
P3 I3
3.11 DENORMALIZATION:
De-normalization is the opposite of normalization. It is a process of increasing
redundancy in the database either for convenience or to improve performance.
DATABASE SECURITY:
The data stored in the database need protection from unauthorized action and
malicious destruction or alteration, in addition to the protection against accidental
introduction of inconsistency that integrity constraint provides.
Confidentiality
Privacy of Communications
Secure Storage of Sensitive Data
Authenticated user
Granular Access Control
Integrity
Availability
(a)Security violations:
Among the form of malicious access are
o Unauthorized reading of data
o Unauthorized modification of data
o Unauthorized destruction of data
Database security refers to protection from malicious access.
To protect the database, we must take security measure at several levels. They are
o Database system
o Network
o Physical
o Human
(b) Authorization:
We may assign user several forms authorization on parts of the database
For example,
Read authorization
Insert authorization
Update authorization
Delete authorization
In addition to the forms of authorization for access to data, we may grant a user
authorization to modify the database schema:
Index authorization
Resource authorization
Alteration authorization
Drop authorization
(c)Authorization and views:
Creation of view does not require resource authorization a user who creates a
view does not necessarily receive all privilege on that view. He/she receive only those
privileges that provide no additional authorization society and those that she already
had.
(d)Granting of privileges:
A user who has been granted some form of authorization may be allowed to
pass on this authorization to other users.
The passing of authorization from one user to another can be represented by an
authorization graph. The nodes of this graph are the users. The graph includes
an edge Ui -> Uj: if user Ui grants update authorization on to Uj.
A user has an authorization if and only if there is a path from the root of the
authorization graph down to the node representing the user.
(e) Notion of roles:
A set of rules is created in the database, authorization can be granted to rules, in
exactly the same fashion as they we granted to individual users. Each database user is
granted to a set of rules that he or she is authorization to perform.
(f) Audit trails:
A audit trail is a lot of all changes to the database, along with information such as
which was performed the change and when the change was performed. By this, it aids
security.
If we wish to grant a privilege and to allow the recipient to pan the privilege on
to other users we append the with grant option, clause to the appropriate grant
command.
For ex, if we wish to allow the select privilege on branch and allow U1 to grant
this privilege to others, grant select on branch to U1 with grant option.
To revoke an authorization, we use the revoke statement
Revoke<privilege list> on <relation name or view name> from <user/role
list>[restrict/cascade]