sql basics
sql basics
Key Features: Primary and foreign keys, normalization, and SQL support.
2. Hierarchical Databases
3. Network Databases
4. Object-Oriented Databases
Use Case: Complex applications with multimedia, CAD, and real-time systems.
5. NoSQL Databases
6. Distributed Databases
7. Cloud Databases
Entity
Types:
o Entity Instance: A single entity from the entity type (e.g., a specific
student, John).
Attributes
Types:
o Derived Attribute: Derived from other attributes (e.g., Age derived from
DOB).
Relationships
Types:
1. Primary Key
Properties:
2. Foreign Key
An attribute in one table that references the primary key of another table.
3. Candidate Key
Properties:
4. Super Key
Integrity Constraints
Ensures the column(s) identified as the primary key is unique and non-null.
3. Unique Constraint
Ensures all values in a column or group of columns are unique across rows.
5. Check Constraint
6. Default Constraint
Normalization
1. Minimize redundancy.
Requirement:
Example:
A table with multiple phone numbers in a single column violates 1NF. Separate
them into rows or columns.
Requirement:
Example:
In a table with StudentID + CourseID as a composite key, attributes like
StudentName depend only on StudentID and should be moved to another table.
Requirement:
Example:
A table where StudentID → DepartmentID → DepartmentName should separate
DepartmentID and DepartmentName into another table.
Requirement:
Example:
If Professor → Subject but Professor is not a super key, split the table to satisfy
BCNF.
1. Generalization
Definition: The process of combining two or more entities into a single higher-
level entity by extracting common features.
Example:
Key Points:
o Bottom-up approach.
2. Specialization
Example:
o Entity: Employee.
Key Points:
o Top-down approach.