unit ii to v dbms b.com
unit ii to v dbms b.com
1. FUNCTIONAL DEPENDENCY
Functional dependency (FD) is a set of constraints between two attributes in a relation.
Functional dependency says that if two tuples have same values for attributes A1, A2,...,
An, then those two tuples must have to have same values for attributes B1, B2, ..., Bn.
Functional dependency is represented by an arrow sign (→) that is, X→Y, where X
functionally determines Y. The left-hand side attributes determine the values of attributes
on the right-hand side.
Fully Functional Dependency :
If X and Y are an attribute set of a relation, Y is fully functional dependent on X, if Y is
functionally dependent on X but not on any proper subset of X.
Partial Functional Dependency :
A functional dependency X->Y is a partial dependency if Y is functionally dependent on
X and Y can be determined by any proper subset of X.
2. NORMALIZATION
Normalization is a technique for dividing relation into relations and identifying anomalies
in the existing relations.
Advantages of Normalization:
Less storage space
Reduces data redundancy in a database
It eliminates serious manipulation anomalies.
First Normal Form (1NF):
A relation in which the intersection of each row and column contains one and only one
value.Example:
EmpNum EmpPhone EmpDegrees
111 040-23840112
222 040-23987654 { BA, BSc, PhD }
333 040-23456789 { BSc, MSc }
Transformation into 1NF:
Employee( EmpNum, EmpPhone) EmployeeDegree(EmpNum, EmpDegrees)
EmpNum EmpPhone
EmpNum EmpDegrees
111 040-23840112 222 BA
222 040-23987654 222 BSc
333 040-23456789 222 PhD
333 BSc
333 MSc
InvNum InvDate
Note: any relation that is in BCNF, is in 3NF The First Normal Form -The Second Normal Form
- The Third Normal Form - Boyce Codd Normal Form –
3. DIFFERENT TYPES OF FILE ORGANIZATIONS
File – A file is named collection of related information that is recorded on secondary storage
such as magnetic disks, magnetic tables and optical disks.
What is File Organization?
File Organization refers to the logical relationships among various records that constitute
the file, particularly with respect to the means of identification and access to any specific record.
In simple terms, Storing the files in certain order is called file Organization. File
Structure refers to the format of the label and data blocks and of any logical control record.
Types of File Organizations
Sequential File Organization
Heap File Organization
Hash File Organization
B+ Tree File Organization
Clustered File Organization
Sequential File Organization
The easiest method for file Organization is Sequential method. In this method the file are
stored one after another in a sequential manner.
Advantages
Fast and efficient method for huge amount of data.
Simple design.
Files can be easily stored in magnetic tapes i.e cheaper storage mechanism.
Disadvantages.
Time wastage as we cannot jump on a particular record that is required, but we have to move
in a sequential manner which takes our time.
Sorted file method is inefficient as it takes time and space for sorting records.
Heap File Organization
Heap File Organization works with data blocks. In this method records are inserted at the
end of the file, into the data blocks. No Sorting or Ordering is required in this method. If a data
block is full, the new record is stored in some other block, Here the other data block need not be
the very next data block, but it can be any block in the memory. It is the responsibility of DBMS
to store and manage the new records.
Advantages
Fetching and retrieving records is faster than sequential record but only in case of small
databases.
When there is a huge number of data needs to be loaded into the database at a time, then this
method of file Organization is best suited.
Disadvantages
Problem of unused memory blocks.
Inefficient for larger databases.
Hash File Organization :
Hashing is an efficient technique to directly search the location of desired data on the disk
without using index structure. Data is stored at the data blocks whose address is generated by
using hash function. The memory location where these records are stored is called as data block
or data bucket.
Data bucket – Data buckets are the memory locations where the records are stored. These
buckets are also considered as Unit Of Storage.
Hash Function – Hash function is a mapping function that maps all the set of search keys to
actual record address. Generally, hash function uses primary key to generate the hash index –
address of the data block. Hash function can be simple mathematical function to any complex
mathematical function.
Hash Index-The prefix of an entire hash value is taken as a hash index. Every hash index has
a depth value to signify how many bits are used for computing a hash function. These bits
can address 2n buckets. When all these bits are consumed ? then the depth value is increased
linearly and twice the buckets are allocated.
Below given diagram clearly depicts how hash function work: