Database Systems - Lecture 6
Database Systems - Lecture 6
CONCEPTUAL SCHEMA
A conceptual schema defines an abstract view of the data and the relationships among data
entities.
This schema is independent of any specific DBMS.
• Database design: It helps in understanding the domain and modeling the data requirements
without worrying about implementation.
• Communication: Acts as a bridge between the database designers and business users to
ensure the correct interpretation of the data.
• Documentation: Provides a complete and structured view of the organization’s data.
RELATIONAL SCHEMA
A relational schema defines how data is organized in tables, specifying the relations, columns,
and keys.
• Describes tables, columns, data types, primary and foreign keys, and constraints.
• More focused on the logical data model as it will be implemented in a database.
• Normalization techniques are applied to avoid redundancy and maintain integrity.
1
CONCEPTUAL SCHEMA VS RELATIONAL SCHEMA
2
Example:
A one-to-many relationship between Student and Course (where a student can enroll in
multiple courses) is mapped by adding StudentID as a foreign key in the Enrollment table.
3. Attributes to Columns:
• The non-key attributes of the entities are directly mapped to columns in the corresponding
tables
• Data types are specified for each attribute based on the requirements (e.g., string, integer,
date).
4. Handling Composite and Multi-Valued Attributes:
• Composite attributes (attributes that can be subdivided) are flattened into multiple
columns.
• Multi-valued attributes (attributes that can have multiple values) are often transformed
into separate tables with a foreign key relationship.
5. Normalization:
• The relational schema is normalized to reduce redundancy and ensure data integrity.
• Tables are checked for various normal forms (1NF, 2NF, 3NF, etc.) and reorganized
accordingly.
EXAMPLE OF MAPPING:
Conceptual Schema
• Entity: Employee with attributes EmployeeID, Name, DOB
• Relationship: WorksIn between Employee and Department (one-to-many)
Relational Schema:
• Table: Employee(EmployeeID, Name, DOB, DepartmentID
• Table: Department(DepartmentID, DeptName)
• Foreign Key: DepartmentID in employee references Department(DepartmentID)
3
Uses of Entity Constraint
• Uniqueness of Records: Ensures that each record in a table is distinct, preventing
duplication of data.
• Efficient Data Retrieval: Primary keys facilitate fast and efficient searching, sorting, and
querying of data in a table.
• Data Integrity: Helps maintain data integrity by ensuring that no record is ambiguous or
can be confused with another.
Example:
In a table Employee, the EmployeeID column is the primary key. The entity integrity constraint
ensures that every employee has a unique EmployeeID and no employee can have a null value
for EmployeeID
4
Uses of Referential Integrity Constraint
• Enforcing Relationships Between Tables: Ensures that records in one table are validly
related to records in another. For instance, an order must always be associated with an
existing customer.
• Maintaining Consistency: Prevents orphaned records or invalid references in a database,
ensuring the relationships between tables are always valid.
• Cascading Changes: When a referenced record is deleted or updated, the referential
integrity constraint can automatically update or delete related records.
Example:
In a database with Orders and Customer tables, the CustomerID in the Orders table is a foreign
key referencing the CustomerID in the Customer table. Referential integrity ensures that every
order has a valid CustomerID.
In the above example, the CustomerID in the Orders table must correspond to an existing
CustomerID in the Customer table.
If an attempt is made to insert an order with a non-existent CustomerID, the database will reject
the action.
5
6