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

DBMS_Assignment

Uploaded by

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

DBMS_Assignment

Uploaded by

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

Assignment No: 01

Sub: DBMS

Subcode: BCS304

1. List and explain advantages of using DBMS approach


Advantages of using DBMS approach:
- Data Redundancy and Inconsistency Control: DBMS reduces data redundancy by
integrating all the data into a single database, thereby eliminating duplicate records and
ensuring consistency.
- Data Integrity and Security: It enforces data integrity by applying constraints on the data.
Security is enhanced by restricting unauthorized access through authentication and
authorization mechanisms.
- Data Sharing: Multiple users can access the database concurrently without interfering with
each other’s work.
- Backup and Recovery: DBMS provides robust mechanisms for data backup and recovery,
ensuring data is not lost in case of failures.
- Data Abstraction: It hides the complexity of the data and presents users with a simple
interface for data access.
- Efficient Data Access: Indexing and query optimization techniques improve the efficiency
of data retrieval and manipulation.

2. Define the following terms

(a) Database
A database is an organized collection of data, generally stored and accessed electronically
from a computer system. It allows for efficient retrieval, insertion, and deletion of data, and
it is managed by a Database Management System (DBMS).

(b) DBMS Catalog


The DBMS catalog, also known as the system catalog or data dictionary, is a repository
within the DBMS that contains metadata—data about the data. This includes information on
database schema, table definitions, index structures, constraints, and user permissions.

(c) Entity
An entity is an object or thing in the real world that is distinguishable from other objects. In
the context of databases, an entity represents a single object or concept, and it is typically
modeled as a table where each row represents a unique instance of the entity.
(d) Degree of a relationship
The degree of a relationship in a database refers to the number of entities involved in a
relationship. For example:
- Unary relationship involves one entity.
- Binary relationship involves two entities.
- Ternary relationship involves three entities.

3. Explain the three-schema architecture with a neat diagram and describe the
different schemas involved in DBMS
Three-Schema Architecture:
The three-schema architecture is a framework for database systems that separates the
database into three levels:
- Internal Schema: This level defines the physical storage structure of the database. It
includes details on data storage, file organization, and access paths.
- Conceptual Schema: This level provides a unified view of the entire database without
considering the physical aspects. It describes what data is stored in the database and the
relationships among those data.
- External Schema: This level involves multiple user views. It defines how different users see
the data in the database. Each user view is tailored to meet the specific needs of a group of
users.

Diagram:
External Schema (User Views)
/ | \
View 1 View 2 View 3
\ | /
Conceptual Schema
|
Internal Schema

4. Summarize the steps involved in converting the ER constructs to relational


schema
Steps in converting ER constructs to Relational Schema:
1. Entity Conversion: Each entity in the ER diagram is converted to a table. Attributes of the
entity become columns of the table.
2. Relationship Conversion:
- One-to-One Relationship: Merge the two entities into a single table or use a foreign key to
link the tables.
- One-to-Many Relationship: Add a foreign key to the table on the "many" side pointing to
the primary key of the table on the "one" side.
- Many-to-Many Relationship: Create a new table to represent the relationship, including
foreign keys pointing to the primary keys of the related tables.
3. Weak Entity Conversion: Convert weak entities into tables and include foreign keys
pointing to the primary key of the owner entity.
4. Attribute Conversion: Handle multi-valued attributes by creating a separate table and
using foreign keys to link it back to the original table.
5. Handling Derived Attributes: Omit derived attributes from the relational schema, as they
can be calculated as needed.

5. Explain Joins in relational algebra with an example


Joins in Relational Algebra:
Joins are operations used to combine rows from two or more tables based on a related
column between them.
Types of Joins:
- Inner Join: Returns only the rows that have matching values in both tables.
- Left Join (Left Outer Join): Returns all the rows from the left table and the matched rows
from the right table. If no match is found, NULL values are returned for columns from the
right table.
- Right Join (Right Outer Join): Returns all the rows from the right table and the matched
rows from the left table. If no match is found, NULL values are returned for columns from
the left table.
- Full Join (Full Outer Join): Returns all rows when there is a match in either left or right
table. Rows without a match in one of the tables will contain NULL.
Example:
Consider two tables, Students and Courses.
Students:
| StudentID | Name |
|-----------|-------|
|1 | Alice |
|2 | Bob |
|3 | Carol |
Courses:
| CourseID | StudentID | CourseName |
|----------|-----------|------------|
| 101 | 1 | Math |
| 102 | 2 | Science |
| 103 | 1 | English |
Inner Join:
SELECT Students.Name, Courses.CourseName
FROM Students
INNER JOIN Courses ON Students.StudentID = Courses.StudentID;
Result:
| Name | CourseName |
|-------|------------|
| Alice | Math |
| Alice | English |
| Bob | Science |

6. Explain aggregate function with example


Aggregate Functions:
Aggregate functions perform a calculation on a set of values and return a single value.
Common aggregate functions include:
- COUNT: Counts the number of rows in a dataset.
- SUM: Calculates the sum of numeric values.
- AVG: Computes the average of numeric values.
- MAX: Finds the maximum value.
- MIN: Finds the minimum value.
Example:
Consider a table Sales:
| SaleID | Amount |
|--------|--------|
| 1 | 100 |
| 2 | 200 |
| 3 | 150 |
Using aggregate functions:
SELECT COUNT(SaleID) AS NumberOfSales, SUM(Amount) AS TotalSales, AVG(Amount) AS
AverageSale
FROM Sales;
Result:
| NumberOfSales | TotalSales | AverageSale |
|---------------|------------|-------------|
|3 | 450 | 150 |
These functions help summarize and analyze data in a meaningful way.

You might also like