Relational Databases
Database in which data is modelled in the form of Entities + Relationships.
keys
Unique Key
Primary Key
Composite Key
Foreign Key
Dependencies
Functional Dependency
When one attribute can be used to uniquely determine (or fetch) another.
For example, Employee ID
can be used to determine Employee Name
.
- Determining attribute = Determinant
- Attribute being determined = Dependent
Represented as:
For example:
Trivial Dependency
When
And
For example,
The dependent attribute (B) should really be a subset of the determinant (A) for it to be a trivial dependency. Being able to calculate an attribute on basis of another doesn't make the calculable attribute a subset. For example, Age
can be determined from Date of birth
but Age
is NOT a subset of Date of birth
.
Partial
When an attribute is dependent on only a part of a composite primary key
Transitive
Multivalued
Normalization
Normalization is a process of organizing database in a table which is used to minimise redundancy in a table.
1NF
- First normal form
- If the table holds atomic value.
- One attribute → One attribute.
- Break rows if there are two values in any row.
2NF
- Second Normal Form
- Should be in First Normal Form.
- All non-key attributes are fully functional dependent on primary key.
- That basically means, seperate out tables to make a primary key.
3NF
- Third Normal Form
- Should be in Second Normal Form
- No Transitive Partial Dependency
- Break the table to remove this
References
Normalization