Download as pdf or txt
Download as pdf or txt
You are on page 1of 16

DATABASE MANAGEMENT SYSTEM

Q.1) Primary Key and Foreign Key:-


Ans:-
Primary Key
A **Primary Key** is a column (or a set of columns) in a table that uniquely
identifies each row in that table. It must contain unique values, and it cannot
contain null values. The primary key ensures that each record in the table is
unique, which is essential for accurately identifying and accessing data. It's like
having a unique ID for every student in a school; no two students can have the
same ID, ensuring each student's record is distinct.

**Example:**
Consider a table named `Students`, with columns `StudentID`, `Name`, `Age`,
and `Major`. The `StudentID` could serve as the primary key because it uniquely
identifies each student.
Students Table:
+-----------+---------+-----+---------+
| StudentID | Name | Age | Major |
+-----------+---------+-----+---------+
|1 | Alice | 20 | Biology |
|2 | Bob | 22 | Chemistry |
|3 | Charlie | 21 | Physics |
+-----------+---------+-----+---------+
```
Foreign Key

A **Foreign Key** is a column (or a set of columns) in one table that refers to
the primary key of another table. The purpose of the foreign key is to enforce
referential integrity between the data in the two tables. This means it creates a
link between the tables, ensuring that the relationship between them remains
consistent. A foreign key in one table points to a primary key in another table,
establishing a relationship between the two tables.

**Example:**
Imagine we have another table called `Enrollments`, which records the courses
students have enrolled in. It includes columns like `EnrollmentID`, `StudentID`
(which refers back to the `StudentID` in the `Students` table), and `Course`.
Enrollments Table:
+--------------+-----------+----------+
| EnrollmentID | StudentID | Course |
+--------------+-----------+----------+
|1 |1 | Biology 101 |
|2 |2 | Chemistry 101 |
|3 |1 | Physics 101 |
+--------------+-----------+----------+
```
In the `Enrollments` table, `StudentID` serves as a foreign key because it
references the `StudentID` primary key in the `Students` table. This establishes a
relationship between each enrollment record and the corresponding student,
ensuring that enrollments can only be recorded for students that actually exist in
the `Students` table.

### Summary

- A **Primary Key** uniquely identifies each record within a table and cannot
be null.
- A **Foreign Key** creates a relationship between two tables by referencing the
primary key of another table, ensuring referential integrity.
Q.2) Centralised Database and Distributed Database.
Ans:
Centralized Database
Imagine your school's library where all books, journals, and resources are stored
in one main location. If anyone from anywhere in the school wants to borrow a
book or access a resource, they have to go to this single library. A **centralized
database** works much like this library. All the data is stored in one central
location (like a single server or data center), and users from different locations
access this data over a network.

**Advantages:**
- **Simplicity**: Easier to maintain and manage because everything is in one
place.
- **Consistency**: Since there's only one version of the data, it's easier to ensure
data accuracy and consistency.
- **Security**: Centralizing data can simplify the enforcement of security
policies and procedures.

Distributed Database
Now, think about a franchise restaurant chain, like McDonald's. Each restaurant
has its own storage of ingredients, but they all follow the same standards and
recipes. A **distributed database** is similar; it spreads the data across different
locations (servers situated in different geographical locations), yet operates as a
single database system. Even though the data is distributed, users can access and
manage it as if it were all in one place.
**Advantages:**
- **Reliability**: If one server fails, the system can continue to operate using the
data stored in other locations.
- **Local Control**: Different branches or departments can control their own
data, which can improve efficiency and response times.
- **Scalability**: It's easier to add more servers or locations to handle increased
load, improving performance and capacity.
Q.3) Roll-Back transaction.
Ans:-
In database management, a **rollback** operation is used to revert the database
to its previous state before a set of transactions were executed. This is particularly
useful in maintaining data integrity in cases where a transaction or a group of
transactions encounters an error or does not complete as expected. The rollback
operation undoes all changes made during the transaction.
Scenario
Imagine you are managing an online bookstore database. You have a table named
`Books` with columns `BookID`, `Title`, and `Stock`.

Let’s say you want to update the stock for a book and then perform another
operation, like updating the price. If the second operation fails for some reason,
you might want to undo the stock update as well to keep your data consistent.

Example Without Specific SQL Flavor


BEGIN TRANSACTION;

-- Attempt to update the stock of a specific book


UPDATE Books
SET Stock = Stock - 1
WHERE BookID = 123;
-- Assume here's an operation that fails, prompting a need to revert the stock
update
-- For illustration, let's say this operation is to update the price, but it encounters
an error
-- Since the second operation failed, we decide to roll back the transaction
ROLLBACK TRANSACTION;
-- At this point, the stock update made to the Books table is undone, and the
database
-- state is as it was before the BEGIN TRANSACTION command.
Q.4) DBA Roles and Responsibilities.
Ans:-
A Database Administrator (DBA) is like the caretaker or guardian of databases.
They are responsible for ensuring that databases, which are critical to the digital
operations of a business, run efficiently, securely, and without interruption. Think
of a DBA as a librarian who not only keeps the library's books organized but also
ensures that the library's catalog system is always operational, the books are in
good condition, and the library's rules are followed to maintain a peaceful
environment for its patrons.

### 1. **Installation and Maintenance**


- **Setting Up**: Like setting up a new exhibit in a museum, DBAs install and
configure database software and make sure it's properly set up for the
organization's needs.
- **Upkeep**: They perform routine maintenance tasks such as upgrades and
patches to ensure the database software is up-to-date and running smoothly, akin
to a mechanic regularly servicing vehicles to keep them running.

### 2. **Performance Monitoring and Tuning**


- **Keeping Things Fast and Efficient**: DBAs monitor the database's
performance, similar to how a traffic controller monitors and manages traffic
flow. They make adjustments to prevent bottlenecks and ensure data can be
accessed and updated swiftly and efficiently.

### 3. **Security**
- **Protector of Data**: DBAs are responsible for securing the database against
unauthorized access, much like a bank vault manager ensures that the vault is
secure. This involves setting up user accounts, defining what data users can
access, and protecting against external threats like hackers.

### 4. **Backup and Disaster Recovery**


- **Emergency Preparedness**: Just as a community might prepare for natural
disasters, DBAs ensure that there are backup and recovery systems in place. They
regularly backup data to prevent loss in case of hardware failure, software issues,
or other disasters, and they know how to restore this data when needed.
### 5. **Data Integrity and Availability**
- **Ensuring Accurate and Accessible Data**: They enforce data integrity rules
to make sure the data is accurate, consistent, and reliable. It's similar to ensuring
that all the information in a library's cataloging system is correct and that books
are available when patrons seek them.

### 6. **Capacity Planning**


- **Future-Proofing**: Like city planners ensuring there's enough infrastructure
to support a growing population, DBAs plan for future database growth. They
assess the need for additional storage, computing resources, and software
upgrades to handle increasing amounts of data.

### 7. **Consultation and Support**


- **Advisory Role**: DBAs often work with other IT staff and management,
offering expertise on database-related matters. They help select the right database
technologies and configurations for new projects and assist with data-related
problem-solving.

Q.5) Explain File System and Database System.


Ans:-

Imagine you have a giant room full of filing cabinets where you keep all your
documents and files. This room is like your computer's **File System**. It's a
way of organizing and storing your files on storage devices like hard drives or
SSDs. In this room, each drawer represents a folder, and within these drawers,
you have files. You can easily go to a specific drawer to find a document, but if
you have thousands of documents, finding the one you need might take a while,
especially if they're not well organized.

Now, imagine instead of this room, you have a librarian in a library. This librarian
has a detailed catalog that tells exactly where each book is, who borrowed it last,
and when it's due back. This library is like a **Database System**. It's not just
about storing data (or books, in this analogy); it's also about managing the data—
keeping track of where it is, ensuring it's consistent, and controlling who can
access it. In a database system, data is stored in tables, which are like the catalog
entries in our library. These tables make it very efficient to search for, update, or
analyze data.
### File System
- **Simple Organization**: Like a room full of filing cabinets, it organizes data
into files and folders.
- **Direct Access**: You can directly access and open files without needing a
special method or query language.
- **No Complex Relationships**: It's great for storing individual files but doesn't
handle complex relationships between data (like linking a customer to their
orders) very well.
- **Manual Search**: Finding specific data might require manually searching
through files or folders, which can be time-consuming.

### Database System


- **Structured Data Management**: Like a library with a catalog, it uses tables
to store data, making it easier to manage large volumes of information.
- **Efficient Querying**: You can use a query language (like SQL) to quickly
find, update, or analyze data without having to manually search through it.
- **Data Integrity and Security**: Offers tools and mechanisms to ensure data is
consistent, not duplicated, and secure from unauthorized access.
- **Handles Relationships**: Excellently manages relationships between
different types of data, making it powerful for applications that require complex
data analysis or reporting.

Q.6) Explain Decision Support system and Data Redundancy.


Ans:-

Decision Support System (DSS)

Imagine you're the captain of a ship navigating through a vast ocean. You have
charts, a compass, weather data, and your own experience to help you make
decisions about the best route, when to sail, and when to avoid bad weather. A
**Decision Support System (DSS)** is like having an expert navigator and a
weather forecasting system on board. It gathers all sorts of information—maps,
weather reports, data on currents and tides—and then, using technology, helps
you analyze this data to make informed decisions about your voyage. In a
business context, a DSS helps managers make decisions by providing
information, data analysis, and possible outcomes for different decisions. It's like
a toolkit that helps you see the bigger picture and weigh your options more clearly
before making a decision.
Data Redundancy

Now, imagine you have several notebooks where you jot down notes about your
journey, the crew's schedule, inventory, etc. If you write the same information in
multiple notebooks, you're doing extra work, and there's a chance the information
might not match up exactly if you update one notebook and forget to update the
others. This situation is similar to **data redundancy** in the world of data
management. It means the same piece of data is stored in more than one place.
While sometimes it's done on purpose for backup or quick access, it often leads
to extra storage being used, inconsistencies in data if not all instances are updated
together, and more effort required to manage the data.

Q.7) Explain Database and Data Warehouse.


Ans:-
Database

Imagine your kitchen, where you have different ingredients stored in various
containers, each labeled and organized on shelves. Whenever you want to cook a
meal, you go to these containers, take what you need in the exact amount, and use
them to prepare your dish. A **database** is like this kitchen for digital
information. It stores data in a structured format, using tables (like shelves) and
records (like containers) that are easily accessible, searchable, and updatable. Just
as you can quickly find and use kitchen ingredients to make a meal, you can
quickly access and use data in a database to perform tasks, answer questions, or
support applications in real-time operations.

### Data Warehouse

Now, think of a warehouse where a business stores large quantities of products in


bulk, organized for easy access but not necessarily intended for immediate use.
Instead, these products are kept for future use, analysis, and decision-making. A
**data warehouse** serves a similar purpose for data. It is a centralized
repository designed to store a vast amount of data from various sources within an
organization. This data is processed, transformed, and integrated so it can be used
for comprehensive analysis, reporting, and making strategic decisions. Unlike the
ingredients in your kitchen that you use daily, the data in a data warehouse is like
the bulk supplies stored for in-depth analysis to understand trends, patterns, and
long-term performance.
Q.8) How data mining use as an Backbone of artificial intelligence.
Ans:-
Data mining and Artificial Intelligence (AI) are closely interlinked fields that
complement and enhance each other, with data mining playing a crucial role as a
backbone in many AI applications. To understand this relationship, it's helpful to
break down the concepts into simpler terms.

Data Mining: The Treasure Hunt

Imagine you're on a treasure hunt, but instead of looking for gold in a vast ocean,
you're searching for valuable insights within a massive sea of data. Data mining
is the process of discovering patterns, correlations, and anomalies within large
datasets. It's like having a map and a set of tools that help you identify where the
treasure (valuable information) is buried.

Artificial Intelligence: Making Sense of the Treasure

Once you've found the treasure, you need to figure out what to do with it.
Artificial Intelligence is like having an expert on board who can analyze the
treasure (data insights) you've found and make intelligent decisions. AI uses
algorithms and models to mimic human intelligence, making decisions,
predicting outcomes, and learning from data.

How Data Mining Serves as a Backbone for AI

1. **Feeding the AI with Data**: AI systems need data to learn and make
decisions. Data mining extracts and prepares this data, serving as the food that
nourishes AI algorithms. Without data mining, AI systems wouldn't have the
quality data they need to operate effectively.

2. **Discovering Patterns for AI to Learn**: Data mining uncovers patterns and


relationships within the data. These patterns are essential for training AI models.
For instance, by identifying trends in customer purchase behavior, an AI system
can predict future buying habits.

3. **Enhancing AI Decision-Making**: The insights from data mining enable AI


systems to make more accurate decisions. For example, data mining might reveal
that customers who buy product A often also buy product B. An AI system can
use this insight to recommend product B to customers who purchase product A.
4. **Improving AI Over Time**: Data mining can be used to continually improve
AI algorithms. By analyzing the outcomes of AI decisions and actions, data
mining can identify areas for improvement and optimization, making AI systems
smarter over time.

5. **Enabling Complex Problem-Solving**: The combination of data mining and


AI allows for the solving of complex problems that neither could solve alone.
Data mining extracts and preprocesses the data, while AI applies sophisticated
algorithms to make sense of this data, predict outcomes, or automate tasks.

Q.9) Characteristics object oriented data model.


Ans:-

The Object-Oriented Data Model is akin to organizing a large warehouse using a


method where every item is part of a box, and each box can interact with other
boxes in various ways. This model is inspired by the principles of object-oriented
programming and applies them to the organization, storage, and manipulation of
data. Here are its main characteristics explained in a simple context:

### 1. **Objects**

Think of objects as individual containers or boxes in our warehouse. Each box


(object) contains data and also information on what can be done with this data.
For example, if you have a box labeled "DVD Player," it would contain not just
the DVD player but also instructions on how to play, stop, or eject DVDs.

### 2. **Classes**

Classes are like the blueprint or design for a box. They describe what each box
should contain and how it should behave. If "DVD Player" is a class, then each
DVD player you produce according to this blueprint is an object of that class. The
class ensures that all DVD player objects have the same characteristics and
behaviors.

### 3. **Encapsulation**

Encapsulation is about keeping the contents of each box and the instructions on
how to use them together, and not letting anyone mess with them directly unless
they use the provided instructions. This means that the data (attributes) and the
operations (methods) are bundled together, and the internal workings are hidden
from the outside, ensuring a controlled interaction with the object’s data.

### 4. **Inheritance**

Inheritance is a bit like creating a new box design based on an existing one but
with some additions or changes. For instance, if you have a box design for a
"Basic DVD Player" and you want to make a "Blu-ray DVD Player," you don't
start from scratch. Instead, you take the "Basic DVD Player" design and add
features to play Blu-ray discs. The "Blu-ray DVD Player" inherits all the
characteristics of the "Basic DVD Player" and adds some more.

### 5. **Polymorphism**

Polymorphism is the ability to treat different objects—each with their own set of
instructions—through a common interface. Imagine you have different boxes,
one for a DVD player and another for a Blu-ray player. Polymorphism allows you
to use them through a common set of commands like "Play," "Stop," and "Eject,"
even though the specific way these commands are executed might differ for each
player.

### 6. **Dynamic Binding**

This is like deciding exactly what to do with an object at the last possible moment.
For example, if you have a remote control with a "Play" button, dynamic binding
is what allows the system to decide whether to use the DVD player or the Blu-
ray player's "Play" function when you press the button, depending on which
player you're currently using.

### 7. **Message Passing**

Message passing is the process of sending instructions to the boxes. If you want
a DVD player to play, you send a "Play" message to it. This is how objects interact
with each other, with one object sending a request to another object to invoke a
method.
Q.10) How RDBMS Changes Life.
Ans:-
Before the advent of Relational Database Management Systems (RDBMS),
imagine organizing a vast collection of different types of information—like your
personal contacts, music collection, and book library—using physical ledgers or
index cards. Each type of information might be stored in a different format,
requiring you to remember where everything is and how it's organized. Finding a
specific piece of information, especially if it's related to other information, could
be like going on a treasure hunt without a map.

### Introduction of RDBMS

Enter RDBMS, which revolutionized how we store, retrieve, and manage data.
Think of RDBMS as a super-organized digital librarian who not only knows
where everything is but can also show you connections between different pieces
of information quickly and efficiently.

### How RDBMS Changes Life:

1. **Organization of Data**: RDBMS allows us to store data in tables (like


spreadsheets), where each row represents a record (like an entry in your contact
list) and each column represents a data type (like phone numbers, addresses, etc.).
This structured format makes data easy to organize and manage.

2. **Data Integrity and Accuracy**: RDBMS enforces rules to ensure that the
data entered is accurate and consistent, reducing errors. For example, it can
prevent you from accidentally entering a letter where a phone number should be
or adding the same contact twice.

3. **Efficient Data Retrieval**: Imagine asking the digital librarian for all your
friends who live in New York and like jazz. With RDBMS, retrieving this
information is as simple as running a quick search query, which can comb through
thousands of records in seconds to find exactly what you need.

4. **Data Security**: RDBMS provides robust security features, ensuring that


only authorized users can access or modify the data. It's like having a secure,
digital vault for your information that only you have the key to.

5. **Scalability and Flexibility**: As your collection of data grows, RDBMS can


easily scale to accommodate more data without sacrificing performance.
Q.11) Explain Security and Integrity.
Ans:-
Security and integrity are fundamental concepts in the context of data
management and information systems. They serve as the pillars that ensure data
is protected from unauthorized access or alterations and remains accurate and
consistent over time. Let's break these down into simpler terms to understand
their importance and application.

### Security

Imagine your home where you keep valuable belongings. Security, in this context,
refers to the measures you take to protect your home from intruders, such as locks
on the doors, alarm systems, or even surveillance cameras. In the digital world,
security serves a similar purpose for protecting data.

#### Key Aspects of Data Security:

1. **Confidentiality**: Ensuring that sensitive information is accessible only to


those who are authorized to see it. Just like how you wouldn’t want everyone to
have access to your personal diary.
2. **Integrity**: Protecting data from being altered by unauthorized parties. It's
like ensuring no one can tamper with your diary entries.
3. **Availability**: Making sure that the data is accessible to authorized users
when needed, akin to being able to access your house and your belongings
whenever you need to.
4. **Authentication**: Verifying the identity of users before giving them access
to data, similar to asking for a password or a key before someone can enter your
home.
5. **Authorization**: Determining what an authenticated user is allowed to do
with the data, like deciding who in your house can access the safe.

### Integrity

While security focuses on protecting data from external threats, integrity is about
maintaining the accuracy and consistency of data over its entire lifecycle. It
ensures that the data is reliable and correct, regardless of how many times it is
accessed or updated.
#### Key Aspects of Data Integrity:

1. **Data Accuracy**: Ensuring the data correctly reflects the real-world values
or events it is supposed to represent. It's like making sure the books in your library
have the right information.
2. **Consistency**: Data remains consistent across the database, even after
various operations like updates or deletions. For example, if you update your
address in one place, it should automatically update everywhere.
3. **Constraint Enforcement**: Applying rules to the data to ensure it adheres to
certain standards or formats, like making sure every phone number includes a
country code.
4. **Reliability**: Making sure the data can be relied upon for making decisions
or performing operations, akin to trusting the accuracy of a recipe in a cookbook.
5. **Non-repudiation**: Ensuring that actions performed on or with the data
cannot be denied later, similar to signing a contract that binds you to an
agreement.

Q.12) ER Diagram Payroll System.


Ans:-
Q.13) ER diagram Library Management System.
Ans:-

Q.14) (1) Consider the following relational database of "Zeal Technologies


Pvt. Ltd." and write the following SQL queries
(each question carries 5 marks Total 20 marks) (C04)

employee ( empno,empname, street, city, companyname, salary,


managername, dateofJoining) emploan(empno,amount,dateofloan)

a. List the names, street addresses and cities of residence of all employees
who work for "Zeal Technologies Pvt. Ltd." and earn more than Rs. 35000.
b. List the names of all employees in this database who have joined the
company "Zeal Technologies Pvt. Ltd." after 31st of March 2022
c. List the names of all the employees whose manager's name's 3rd character
is s
d. List the names of all the employees who have taken loan of more than
Rs.15000 after 31st March 2022.
Ans:- Q1. 1> List the names, street addresses and cities of residence of all
employees who work for “Zeal Technologies Pvt. Ltd.” and earn more than Rs.
35000.Ans:

SELECT empname, street, city


FROM employee
WHERE companyname = 'Zeal Technologies Pvt. Ltd.' AND salary > 35000;

Q1. 2> List the names of all employees in this database who have joined the
company “Zeal Technologies Pvt. Ltd.” after 31st of March 2022
Ans:

SELECT empname
FROM employee
WHERE companyname = 'Zeal Technologies Pvt. Ltd.' AND dateofJoining >
'2022-03-31';

Q1. 3> List the names of all the employees whose manager's name's 3rd character
is “s”
Ans:

SELECT empname
FROM employee
WHERE SUBSTRING(managername, 3, 1) = 's';

Q1. 4> List the names of all the employees who have taken loan of more than
Rs.15000 after 31st March 2022.
Ans:

SELECT e.empname
FROM employee e
JOIN emploan el ON e.empno = el.empno
WHERE el.amount > 15000 AND el.dateofloan > '2022-03-31';

You might also like