CLASS TEST 1
1. Explain Database Management System and various
functionalities provided by the system.
Ans:
A Database Management System (DBMS) is software designed to store,
manage, and facilitate access to databases. It serves as an
intermediary between users and databases, ensuring that data is
organized, consistent, and accessible efficiently. Here are some key
functionalities provided by a DBMS:
1. Data Storage, Retrieval, and Update: The DBMS stores data in a
structured way and allows users to efficiently retrieve and
update data.
2. Transaction Management: It ensures that all database
transactions are processed reliably and adhere to ACID
(Atomicity, Consistency, Isolation, Durability) properties.
3. Concurrency Control: DBMS handles simultaneous data access by
multiple users without interference, using techniques like
locking and timestamp ordering to maintain data integrity.
4. Security Management: It provides mechanisms to ensure data
security and privacy, including user authentication,
authorization, and encryption.
5. Backup and Recovery: DBMS offers tools to back up data and
restore it in case of hardware failures, system crashes, or
other disasters.
6. Data Integrity Management: It enforces data integrity
constraints to maintain the accuracy and consistency of data,
using constraints, triggers, and rules.
7. Data Abstraction and Independence: DBMS provides data
abstraction to hide the complexity of data storage and
representation from users, allowing for logical and physical
data independence.
8. Database Languages: DBMS supports various database languages
for data definition (DDL), data manipulation (DML), data
control (DCL), and transaction control (TCL), such as SQL.
9. Data Modeling and Design: DBMS assists in designing databases
with the help of data models like Entity-Relationship (ER)
models, facilitating effective database designs.
10. Performance Management: It includes optimization techniques to
ensure efficient query processing and database performance,
such as indexing, query optimization, and caching.
11. Data Sharing: DBMS allows multiple users and applications to
share data concurrently while maintaining data consistency and
integrity.
2. Classify the Data Base Management system over traditional
File system
Ans:
3. Explain various Data models in Data base management systems
with examples
Ans:
Data models in Database Management Systems (DBMS) define the
structure of a database and how data is stored, organized, and
manipulated. Here are some common data models used in DBMS, along
with examples:
1. Hierarchical Data Model
● Description: Organizes data in a tree-like structure where
each record has a single parent and can have multiple
children.
Example: An organizational chart where each employee reports to one
manager, but a manager can have multiple subordinates.
CEO
├── VP of Sales
│ ├── Sales Manager 1
│ └── Sales Manager 2
└── VP of Engineering
├── Engineering Manager 1
└── Engineering Manager 2
2. Network Data Model
● Description: Similar to the hierarchical model but allows each
record to have multiple parent and child records, forming a
graph structure.
Example: A university database where courses can have multiple
prerequisites, and each prerequisite can be required for multiple
courses.
Course A
├── Course B
└── Course C
└── Course D
3. Relational Data Model
● Description: Organizes data into tables (relations) consisting
of rows (tuples) and columns (attributes). Tables can be
linked using foreign keys.
Example: A customer-order database with tables for Customers,
Orders, and Products.
Customers Table:
+----+--------+---------+
| ID | Name | City |
+----+--------+---------+
| 1 | Alice | New York|
| 2 | Bob | LA |
+----+--------+---------+
Orders Table:
+----+-----------+-----------+
| ID | CustomerID| ProductID |
+----+-----------+-----------+
| 1 | 1 | 101 |
| 2 | 2 | 102 |
+----+-----------+-----------+
4. Object-Oriented Data Model
● Description: Integrates object-oriented programming principles
into databases, allowing the storage of objects, classes, and
inheritance.
Example: A multimedia database where objects like images, videos,
and text documents are stored and managed.
Class: Image
Attributes: resolution, size, format
Class: Video (inherits from Image)
Attributes: duration, frame_rate
5. Entity-Relationship (ER) Data Model
● Description: Uses entities, attributes, and relationships to
represent data. Entities are objects, and relationships show
how entities are related.
Example: A library database where books, authors, and borrowers are
entities with relationships like "written by" and "borrowed by."
Entities:
- Book (Attributes: ISBN, Title, Publisher)
- Author (Attributes: AuthorID, Name, Nationality)
- Borrower (Attributes: BorrowerID, Name, MembershipDate)
Relationships:
- "Written by" between Book and Author
- "Borrowed by" between Book and Borrower
6. Document Data Model
● Description: Stores data in document formats like JSON or XML,
where each document can have a different structure.
Example: A content management system where documents store articles
with varying fields such as title, author, and body.
{
"title": "Introduction to Databases",
"author": "John Doe",
"body": "This article explains the basics of databases."
}
7. Key-Value Data Model
● Description: Stores data as key-value pairs where each key is
unique, and the value can be a simple data type or a complex
object.
Example: A cache system where session data is stored with session
IDs as keys.
Key: session123
Value: { "userID": "1", "cart": ["item1", "item2"] }
8. Column-Family Data Model
● Description: Stores data in columns rather than rows, with
columns grouped into families.
Example: A time-series database where data points are stored with
timestamps as keys.
Row Key: sensor123
Column Family: temperature
Columns: [2023-01-01: 22.5, 2023-01-02: 23.0]
9. Graph Data Model
● Description: Represents data as nodes (entities) and edges
(relationships), useful for data with complex
interconnections.
Example: A social network database where users are nodes and
friendships are edges.
Nodes: User1, User2, User3
Edges: User1 -> User2 (friend), User2 -> User3 (friend)
Each data model has its strengths and is chosen based on the
specific requirements of the application, such as the nature of the
data, the complexity of relationships, and performance
considerations.
[Link] Database schema, Database instance with
examples.
Ans:
Database Schema
A database schema is the blueprint or architecture of a database
that defines its structure, including tables, columns,
relationships, and constraints. It is the logical design of the
database and dictates how data is organised and how relationships
among data are managed.
Types of Schemas:
1. Physical Schema: Defines how data is physically stored in the
hardware.
2. Logical Schema: Defines the logical constraints and structure
of the data, such as tables, columns, data types, and
relationships.
3. View Schema: Defines how data is presented to users and
applications, often as a subset of the logical schema tailored
to specific needs.
Example:
Tables: Books, Authors Attributes:
● Books: BookID, Title, AuthorID
● Authors: AuthorID, Name
SQL Schema Definition
CREATE TABLE Authors (
AuthorID INT PRIMARY KEY,
Name VARCHAR(100)
);
CREATE TABLE Books (
BookID INT PRIMARY KEY,
Title VARCHAR(100),
AuthorID INT,
FOREIGN KEY (AuthorID) REFERENCES Authors(AuthorID)
);
Database Instance
A database instance is the actual data stored in the database at a
particular moment in time. It represents the state of the database,
including all the records and their current values. While the schema
is static and defines the structure, the instance is dynamic and
changes as data is inserted, updated, or deleted.
Example:
This instance shows some records that might be in the Books and
Authors tables at a given time.
Explanation
● Authors Table: Contains records of authors with their AuthorID
and Name.
● Books Table: Contains records of books with their BookID,
Title, and AuthorID which references the AuthorID in the
Authors table to establish a relationship between books and
their authors.
5. Outline languages associated with Data Base management
system with examples.
Ans:
1. Data Definition Language (DDL)
DDL is used to set up the structure of the database, like creating
tables.
● CREATE: To create a new table.
● ALTER: To change existing tables, like adding a new column.
● DROP: To delete tables or databases.
2. Data Manipulation Language (DML)
DML is used to manage the data inside the database, such as
retrieving or updating it.
Examples:
● SELECT: To get data from the database
● INSERT: To add new data to the database.
● UPDATE: To change existing data
● DELETE: To remove data from the database.
3. Data Control Language (DCL)
DCL is used to control who can access the data in the database.
Examples:
● GRANT: To give a user permission to access or change data.
● REVOKE: To take back permissions from a user.
4. Transaction Control Language (TCL)
TCL is used to manage changes made by DML commands and to ensure
data integrity.
Examples:
● COMMIT: To save all changes made in the current transaction
● ROLLBACK: To undo changes made in the current transaction.
● SAVEPOINT: To set a point within a transaction to which you
can later roll back.
5. Query Language
SQL (Structured Query Language) is the standard language used to
perform tasks such as updating or retrieving data from a database.
Examples:
● Basic Query: To get specific data from a table
● Join Query: To get data from multiple tables based on
relationships.