0% found this document useful (0 votes)
4 views4 pages

SQL Dbms Btech Notes

The document provides an overview of Entity-Relationship (ER) modeling and relational algebra, detailing components such as entities, attributes, and relationships, along with enhanced ER concepts like specialization and generalization. It discusses relational data models, constraints, and basic operations in relational algebra, including selection, projection, and joins. Additionally, it covers naming conventions, design issues, and the handling of constraint violations in database operations.

Uploaded by

vivekberma01780
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views4 pages

SQL Dbms Btech Notes

The document provides an overview of Entity-Relationship (ER) modeling and relational algebra, detailing components such as entities, attributes, and relationships, along with enhanced ER concepts like specialization and generalization. It discusses relational data models, constraints, and basic operations in relational algebra, including selection, projection, and joins. Additionally, it covers naming conventions, design issues, and the handling of constraint violations in database operations.

Uploaded by

vivekberma01780
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Detailed Notes on ER Modeling and

Relational Algebra - B.Tech Level


ER Diagram
An ER (Entity-Relationship) Diagram is a visual representation of the database structure. It
shows how entities (tables) relate to each other.

**Main Components:**
- **Entity:** Object or concept, represented as a rectangle (e.g., Student, Course).
- **Attribute:** Property of entity, shown as an oval (e.g., name, roll_no).
- **Relationship:** Association between entities, represented by diamonds (e.g., Enrolls).

**Example:**
- A Student "enrolls" in a Course.
- Attributes: Student(ID, Name), Course(ID, Title)

**Uses:** Helps in designing databases and understanding data requirements.

Naming Conventions and Design Issues


**Naming Conventions:**
- Use singular nouns for entity names (e.g., Student not Students).
- Attributes should be self-explanatory (e.g., student_id, email).
- Relationships should be verbs or verb phrases (e.g., enrolls_in).

**Design Issues:**
- **Use of derived attributes:** Prefer storing calculated values or deriving them on the fly?
- **Use of weak entities:** If entities cannot exist without another, use weak entities.
- **Multiple relationships:** Identify all possible associations.
- **Redundancy:** Minimize data repetition.

Enhanced Entity Relationship Modeling (EER)


Enhanced ER (EER) models add more semantics to the basic ER model by introducing:

- **Subclasses and Superclasses**


- **Specialization and Generalization**
- **Categories (Union types)**

**Example:** Employee can be specialized into Technician and Manager.


Subclasses, Superclasses, and Inheritance
- **Superclass:** A general entity (e.g., Employee).
- **Subclass:** A specific version with extra attributes (e.g., Engineer, Manager).
- **Inheritance:** Subclass inherits attributes and relationships of the superclass.

**Example:**
Superclass: Employee(emp_id, name)
Subclass: Engineer(emp_id, specialization)

Specialization and Generalization


**Specialization:** Top-down approach; divide a high-level entity into sub-entities.
**Generalization:** Bottom-up approach; combine lower-level entities into a superclass.

**Example:**
- Specialization: Employee → Engineer, Manager
- Generalization: Car, Truck → Vehicle

Constraints and Characteristics of Specialization and Generalization


- **Disjoint Constraint:** An entity instance can belong to only one subclass.
- **Overlap Constraint:** An instance can belong to multiple subclasses.
- **Total Participation:** Every instance of superclass must be in a subclass.
- **Partial Participation:** Not all instances must belong to subclass.

These define the structure and rules of class hierarchies.

Modeling of Union Types Using Categories


**Categories (Union Types):**
Used when a subclass has more than one possible superclass.

**Example:**
- A "Person" can be a "Customer" or an "Employee".
- Category: "Person" ← {Customer, Employee}

Useful for modeling shared entities.

Relational Data Model


A logical structure of data represented in rows and columns (tables).

**Key Concepts:**
- **Relation:** Table
- **Tuple:** Row
- **Attribute:** Column
- **Domain:** Set of allowed values

Represents data in a structured and normalized format.

Relational Constraints
1. **Domain Constraint:** Each attribute must contain only values from a predefined
domain.
2. **Key Constraint:** Each table must have a primary key.
3. **Entity Integrity Constraint:** Primary key cannot be NULL.
4. **Referential Integrity Constraint:** Foreign key must match a primary key in another
table or be NULL.

Relational Algebra
A procedural query language used to retrieve data.

Includes operations such as:


- Selection (σ)
- Projection (π)
- Union (∪)
- Set Difference (−)
- Cartesian Product (×)
- Rename (ρ)

Relational Model Concepts


Defines structure and semantics of relational databases.

**Core Concepts:**
- Relation, tuple, attribute, domain
- Primary key, foreign key
- Schema = Structure of the database
- Instance = Current state of the database

Relational Constraints and Relational Data Schema


**Relational Schema:** Describes structure (e.g., Student(ID, Name, Dept))

**Constraints:**
- Domain, Key, Referential Integrity
- Ensures logical consistency

Helps maintain integrity and accuracy.

Update Operations and Dealing with Constraint Violations


Operations: INSERT, DELETE, UPDATE

**Violations:**
- Insert with duplicate primary key → Key violation
- Insert child without parent → Referential violation
- Update changing type → Domain violation

**Solution:** Use checks, constraints, and triggers.

Basic Relational Algebraic Operations


1. **Selection (σ):** Filters rows.
2. **Projection (π):** Selects columns.
3. **Union (∪):** Combines results (no duplicates).
4. **Set Difference (−):** Rows in one but not the other.
5. **Cartesian Product (×):** Combines all rows from both tables.
6. **Rename (ρ):** Renames table or column.

Additional Relational Operations


- **Join:** Combines tables based on a condition (e.g., natural join, equi-join).
- **Division:** Useful when querying "all" relationships.
- **Intersection:** Rows common to both relations.
- **Assignment:** Store result of operations.

Example of Queries in Relational Algebra


Given two relations:

Student(SID, Name, Age)


Enrolls(SID, CID)

**Query 1:** Get names of students enrolled in any course:


π_Name(σ_Student.SID = Enrolls.SID (Student × Enrolls))

**Query 2:** Students older than 18:


σ_Age > 18(Student)

You might also like