There are 2 approaches to create a database
Top Down(Design by analysis)
Bottom up(Design by synthesis)
The impact goals of database design is to reduce redundancy and preserve information consistency.
Informational guildelines to design relational schema
Semantics of the attributes must be clear in the schema.
Reducing redundant information in the tuples.
Reducing null values in the tuples.
Disallowing the possibility of generating spurious tuples.
Functional Dependency
A functional dependency is a relationship between 2 sets of attributes in a database where one attribute uniquely determines another attribute. There are 2 types of functional dependency Trivial and Non Trivial.
Armstrong's Axioms
Reflexive x→x
Transitivity x→y and y→z then x→z
Augumentation x→y then xA→yA
Union x→y and x→z then x→yz
Splitting x→yz then x→y and x→z
Pseudo Transitivity x→y and yA→z then xA→z
Composition x→y and A→A then xA→yA
Closure of Functional dependency
Closure is the set of all functional dependencies F^+ which can be inferred from a given set of functional dependencies F.
R{A,B,C,D,E}
FD(A>B,B>C,C>D,D>E}
ABCDE+={ABCDE} (using the above properties we can remove B,C,D,E as A can determine all of them making this a super key)= SK=CK
As ‘A’ is a single element it automatically becomes the candidate key. But if there are more than 1 element as the SK like AB or BD we need to find the FD(functional dependency) of the individual elements.
Rules for 1st Normalization
Each attribute should contain atomic values.
A column should contain value of same domain.
Each column should have unique name,
No duplicate rows.
No ordering to rows and columns.
Rules for 2nd Normal form
The relation should be in the 1st normal form.
No partial dependency in the relation. (Partial dependency is a subset of candidate key and should not determine prime attribute)
Rules for 3’d Normal form
Relation should be in 1st and 2nd normal form.
Non prime attribute should not determine Non prime attribute.
Note- If a table is in the 3’d normal form if and only if, for each of its non trivial functional dependencies atleast one of the following conditions holds true.
Rules for BCNF(Boyce Codd Normal Form)
It should be in 3’d normal form.
If x→y then x should be super key.
Lossless Join Decomposition
A decomposition of a relation RRR into smaller relations R1R_1R1 and R2R_2R2 is lossless if we can join R1R_1R1 and R2R_2R2 back together to reconstruct the original relation RRR without losing any data.
No Repeating Values in Attributes:
- There should be no unnecessary duplication of values in the attributes of the decomposed relations.
All Attributes Should Be Present:
- Every attribute in the original relation must appear in at least one of the decomposed relations.
Uniqueness of Common Attributes:
At least one of the common attributes between R1R_1R1 and R2R_2R2 (shared attributes) must form a candidate key in one of the decomposed relations.
If the shared attributes are not unique, and other values in the remaining attributes are identical, the join may lose some data, making it a lossy decomposition.
ACID properties
Atomicity-Either all of the operation is done or none.
Consistency-Before transaction and after transaction is completed the total sum of the value should be the same.
Isolation-Transaction should be completed without any interference.
Durability-All changes must me permanent.
Transaction States
Happy Coding…