0% found this document useful (0 votes)
2 views

DBMS Mid1 Assignment Detailed

The document outlines key concepts in Database Management Systems (DBMS), including three levels of abstraction: physical, logical, and view levels. It discusses SQL commands categorized into DDL for defining schema and DML for data manipulation, as well as the importance of Entity Relationship (ER) diagrams and relational models. Additionally, it covers set operations and join operations in relational algebra, illustrating how to combine and manipulate data effectively.

Uploaded by

vishnu.reddy2260
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

DBMS Mid1 Assignment Detailed

The document outlines key concepts in Database Management Systems (DBMS), including three levels of abstraction: physical, logical, and view levels. It discusses SQL commands categorized into DDL for defining schema and DML for data manipulation, as well as the importance of Entity Relationship (ER) diagrams and relational models. Additionally, it covers set operations and join operations in relational algebra, illustrating how to combine and manipulate data effectively.

Uploaded by

vishnu.reddy2260
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Database Management System (DBMS) - Mid-1 Assignment

1. (a) Three Levels of Abstraction in DBMS


A DBMS provides three levels of abstraction:

1. **Physical Level**: Describes how data is actually stored (e.g., file structures, indexing).
2. **Logical Level**: Defines what data is stored and the relationships between them.
3. **View Level**: Defines how different users see the data, ensuring security and simplicity.

Example: A student database has different views for students, professors, and administrators.

1. (b) DDL and DML Commands in SQL


SQL commands are categorized into:

- **DDL (Data Definition Language)**: Used for defining database schema.


- CREATE TABLE students (id INT, name VARCHAR(50));
- ALTER TABLE students ADD COLUMN age INT;
- DROP TABLE students;

- **DML (Data Manipulation Language)**: Used for modifying data.


- INSERT INTO students VALUES (1, 'John Doe', 20);
- UPDATE students SET age = 21 WHERE id = 1;
- DELETE FROM students WHERE id = 1;

2. Entity Relationship (ER) Diagrams


ER diagrams represent entities, their attributes, and relationships. Examples:

- **Library Management System**: Entities: Books, Students, Librarians.


- **University System**: Entities: Students, Courses, Professors.
- **Railway Booking System**: Entities: Passengers, Trains, Reservations.

Each entity has attributes (e.g., Book_ID, Train_Number) and relationships (e.g., Student borrows
Book).
3. Major Components of ER Diagrams
The key components of an ER diagram are:

1. **Entities**: Represent objects (e.g., Student, Book, Train).


2. **Attributes**: Properties of entities (e.g., Name, ID, Title).
3. **Relationships**: Define associations (e.g., Student borrows Book).
4. **Keys**: Unique identifiers (e.g., Primary Key, Foreign Key).

4. Relational Model and Integrity Constraints


The **Relational Model** organizes data into tables with:

- **Domain Constraint**: Ensures attribute values fall within a valid range.


- **Key Constraint**: Ensures uniqueness (e.g., Student_ID must be unique).
- **Referential Integrity**: Ensures Foreign Keys reference existing records in the parent table.

Example: In a student database, Student_ID must be unique and Course_ID in enrollment must
reference an existing Course.

5. Set Operations in Relational Algebra


Relational Algebra provides operations for combining relations:

1. **Union (R UNION S)**: Combines two relations, removing duplicates.


2. **Intersection (R INTERSECT S)**: Retrieves common tuples from both relations.
3. **Difference (R MINUS S)**: Finds tuples in R that are not in S.
4. **Cartesian Product (R CROSS JOIN S)**: Combines all tuples of R with all tuples of S.

Example:
- R = { (1, 'Alice'), (2, 'Bob') }
- S = { (2, 'Bob'), (3, 'Charlie') }
- R UNION S = { (1, 'Alice'), (2, 'Bob'), (3, 'Charlie') }
- R INTERSECT S = { (2, 'Bob') }

6. Join Operations in Relational Algebra


Joins are used to combine relations based on a common attribute:
1. **Theta Join (R JOIN condition S)**: Joins based on a specified condition.
2. **Equi Join (R JOIN A=B S)**: Joins using equality.
3. **Natural Join (R NATURAL JOIN S)**: Automatically joins on common attributes.
4. **Outer Joins**:
- **Left Outer Join**: Includes unmatched rows from the left relation.
- **Right Outer Join**: Includes unmatched rows from the right relation.
- **Full Outer Join**: Includes unmatched rows from both relations.

Example:
- Table: Students (ID, Name)
- Table: Enrollments (ID, Course)
- Natural Join returns students with course enrollments, while Left Outer Join also includes students
without courses.

You might also like