DBMS Manual (Complete)
DBMS Manual (Complete)
Laboratory Manual
Database Management
4331603
DTE’s Vision:
● To provide globally competitive technical education;
● Remove geographical imbalances and inconsistencies;
● Develop student friendly resources with a special focus on girls’ education and
support to weaker sections;
● Develop programs relevant to industry and create a vibrant pool of technical
professionals.
Certificate
Ahmedabad (GTU Code 617 )has satisfactorily completed the term work in course
Place: ………………………….
Date: ………………………….
4 | Page
Database Management (4331603)
5 | Page
Database Management (4331603)
6 | Page
Database Management (4331603)
7 | Page
Database Management (4331603)
8 | Page
Database Management (4331603)
9 | Page
Database Management (4331603)
10 | Page
Database Management (4331603)
11 | Page
Database Management (4331603)
Date: _________________
A. Report:
intervention.
In-memory databases are also gaining traction due to their ability
to store entire datasets in read-only memory (RAM). This approach
significantly boosts performance by providing faster data access
and improved reliability, making in-memory databases a strong
alternative for mission-critical software solutions. These databases
are particularly valuable in scenarios where speed and real-time
data processing are crucial, offering a competitive edge in
industries that require quick decision-making based on large
volumes of data.
The rise of all-flash databases represents another noteworthy
trend. These memory-based databases offer exceptional speed and
performance, which is critical for applications that demand high
throughput and low latency. However, the high cost associated
with all-flash storage means that these databases are often
reserved for specific use cases where performance outweighs
budget considerations.
Despite the emergence of these advanced technologies, SQL
remains a cornerstone in the database world. It continues to be
the second most popular language among professional developers,
underscoring its enduring importance in managing and querying
databases. SQL’s robust and reliable nature ensures its continued
relevance, even as new database technologies emerge.
Within this landscape, PostgreSQL has seen a remarkable surge in
popularity. With 49% of developers now using PostgreSQL, it has
become the most popular database for the second consecutive
year. Its open-source nature, coupled with powerful features and
active community support, has made PostgreSQL a go-to choice
for developers and enterprises alike.
In conclusion, the current trends in database technology reflect a
broader movement towards cloud adoption, AI-driven automation,
and enhanced performance through in-memory and all-flash
databases. Meanwhile, traditional technologies like SQL and
newer favorites like PostgreSQL continue to play a vital role in the
evolving database ecosystem. These trends indicate a future where
databases will be more powerful, scalable, and intelligent, aligning
closely with the needs of modern enterprises.
13 | Page
Database Management (4331603)
1. Facebook
• Database Tool: MySQL, Cassandra, HBase
• Application: Social Media Platform
• Details: Facebook uses MySQL for structured data,
Cassandra for scalable, distributed storage, and HBase
for real-time data processing.
2. Google
• Database Tool: Bigtable, Spanner, MySQL
• Application: Search Engine, Cloud Services
• Details: Google uses Bigtable for large-scale structured
data, Spanner for global transactional consistency, and
MySQL for internal applications.
3. Amazon
• Database Tool: DynamoDB, Aurora, Redshift
• Application: E-commerce Platform, Cloud Services
• Details: DynamoDB for NoSQL data storage, Aurora for
relational databases, and Redshift for data warehousing
4. Netflix
• Database Tool: Cassandra, MySQL, DynamoDB
• Application: Streaming Service
• Details: Netflix uses Cassandra for high availability and
scalability, MySQL for relational data, and DynamoDB for
fast, scalable NoSQL data storage.
14 | Page
Database Management (4331603)
5. Twitter
• Database Tool: MySQL, Cassandra
• Application: Social Media Platform
• Details: Twitter uses MySQL for structured data and
Cassandra for handling large-scale, distributed storage of
unstructured data.
6. Instagram
• Database Tool: PostgreSQL, Cassandra
• Application: Social Media Platform
• Details: Instagram relies on PostgreSQL for relational
data and Cassandra for handling large amounts of
unstructured data.
7. LinkedIn
• Database Tool: Voldemort, MySQL, Espresso
• Application: Professional Networking Platform
• Details: LinkedIn uses Voldemort for distributed storage,
MySQL for structured data, and Espresso for serving
social graph data.
8. WhatsApp
• Database Tool: Erlang Mnesia, MySQL
• Application: Messaging Service
• Details: WhatsApp uses Mnesia for its lightweight and
distributed nature, and MySQL for structured data
storage.
9. Uber
• Database Tool: MySQL, Cassandra
• Application: Ride-Sharing Service
• Details: Uber uses MySQL for its relational needs and
Cassandra for handling massive amounts of data across
15 | Page
Database Management (4331603)
distributed systems.
10. Spotify
• Database Tool: Cassandra, PostgreSQL
• Application: Music Streaming Service
• Details: Spotify uses Cassandra for scalable, distributed
storage and PostgreSQL for structured relational data.
C. Assessment-Rubrics
Faculty
Marks Obtained Date
Signature
Program Implementation Student’s engagement
Correctness and Presentation in practical activities Total
(4) Methodology (3) (3) (10)
R1 R2 R3
16 | Page
Database Management (4331603)
Date: _________________
Practical No.2: Entity Relationship Diagrams
a. Draw ER-Diagram for Banking Management System
b. Convert ER-Diagram to relational schema.
A. Source code:
17 | Page
Database Management (4331603)
Entities:
Customer: Customer_ID (PK), Name, Address, Contact_Number
Account: Account_Number (PK), Account_Type, Balance,
Open_Date, Customer_ID (FK)
Branch: Branch_ID (PK), Branch_Name, Branch_Address
Employee: Employee_ID (PK), Name, Position, Branch_ID (FK)
Transaction: Transaction_ID (PK), Account_Number (FK),
Transaction_Date, Amount, Transaction_Type
Relationships:
Customer and Account: One-to-Many (A customer can have many
accounts, but an account belongs to only one customer)
Account and Branch: Many-to-One (An account can be at one
branch, a branch can have many accounts)
Employee and Branch: Many-to-One (An employee works at one
branch, but a branch can have many employees)
Account and Transaction: One-to-Many (An account can have
many transactions, but a transaction belongs to only one
account)
Explanation:
The primary key uniquely identifies a record within an entity.
The foreign key defines the relationships between these two
entities.
18 | Page
Database Management (4331603)
Customer
Customer_ID Name Address Contact_Number
Account
Account_Number Account_Type Balance Open_Date Customer_ID
Branch
Branch_ID Branch_Name Branch_Address
Employee
Employee_ID Name Position Branch_ID
Transaction
Transaction_ Account_ Transaction_ Amount Transaction_
ID Number Date Type
19 | Page
Database Management (4331603)
Relationships:
The foreign key Customer_ID in the Account table enforces a one-
to-many relationship between Customer and Account.
The foreign keys Branch_ID in both the Account and Employee
tables enforce the many-to one relationships.
The foreign key Account_Number in the Transaction table enforces
a one-to-many relationship between Account and Transaction.
Additional Considerations:
Data Types: Define appropriate data types for attributes.
Constraints: Enforce constraints NOT NULL, UNIQUE, and
CHECK to maintain data integrity.
Indexes: Build indexes for those columns under frequent search
conditions to improve the performance of inquiries.
Normalization: The schema normalization can also be considered
in order to avoid redundancy and enhance data coherence.
B. Assessment-R
Faculty
Marks Obtained Date
Signature
Program Implementation Student’s engagement
Correctness and Presentation in practical activities Total
(4) Methodology (3) (3) (10)
R1 R2 R3
Date: ________________
20 | Page
Database Management (4331603)
A. Source code:
A) Design the below given schemas using SQL Command - ”Create”. Decide the
appropriate data type for each column.
(a) Create a table ACCOUNT with column account number, name, city,
balance, loan taken.
(b) Create a LOAN table with column loan number, account number,
loan amount, interest rate, loan date, remaining loan.
21 | Page
Database Management (4331603)
22 | Page
Database Management (4331603)
23 | Page
Database Management (4331603)
24 | Page
Database Management (4331603)
25 | Page
Database Management (4331603)
C.) Retrieve data from tables in Practical 2 using Data SQL command- “Select”.
(a) Display all rows and all columns of table Transaction.
26 | Page
Database Management (4331603)
(e) Display the list of customers in descending order of their name from account
table.
27 | Page
Database Management (4331603)
28 | Page
Database Management (4331603)
C) Write SQL queries to use Update, alter, rename, delete, truncate and distinct.
Table: ACCOUNT.
(a) Change the name ‘pateljigar’ to ‘patelhiren’.
(b) Change the name and city where account number is A005. (new name =
‘kothari nehal’and new city = ‘patan’).
(c) Display only those records where loan taken status is ‘YES’.
29 | Page
Database Management (4331603)
(d) Add the new column (address varchar2 (20)) into table
ACCOUNT.
(e) Create
another table ACCOUNT_TEMP (acc_no, name, balance) from
tableACCOUNT.
30 | Page
Database Management (4331603)
(g) Update the column balance for all the account holders. (Multiply the
balance by2 foreach account holders)
Table: LOAN.
(a) For each loan holders Add 100000 Rs. Amount into the column loan_amt.
(b) For each loan holders Increase the interest rate 2%.
31 | Page
Database Management (4331603)
(c) Display only those records where loan holder taken a loan in month of January.
(d) Modify the structure of table LOAN by adding one column credit_no varchar2
(4).
(f) Display the records of table LOAN by date wise in ascending order.
32 | Page
Database Management (4331603)
(g) Display the records of table LOAN by account number wise in descending
Order.
33 | Page
Database Management (4331603)
Table: INSTALLMENT.
(a) Change the Inst_Date ‘2-Feb-04’ to ’3-Mar-04’.
(c) Add the amount 5000 where loan no is ‘L003’ and ‘L002’.
34 | Page
Database Management (4331603)
35 | Page
Database Management (4331603)
Table: TRANSACTION.
(a) Insert any duplicate value and display all the records without any duplicate
rows.
36 | Page
Database Management (4331603)
B. Assessment-Rubrics
Faculty
Marks Obtained Date
Signature
Program Implementation Student’s engagement
Correctness and Presentation in practical activities Total
(4) Methodology (3) (3) (10)
R1 R2 R3
37 | Page
Database Management (4331603)
Date: _________________
A. Source code:
A) Write SQL queries to use various date
functions.
(a) Add 3 months in current date.
38 | Page
Database Management (4331603)
39 | Page
Database Management (4331603)
40 | Page
Database Management (4331603)
41 | Page
Database Management (4331603)
B.Assessment-Rubrics
Faculty
Marks Obtained Date
Signature
Program Implementation Student’s engagement
Correctness and Presentation in practical activities Total
(4) Methodology (3) (3) (10)
R1 R2 R3
42 | Page
Database Management (4331603)
Date:_________________
A.Source code:
A) Write SQL queries to use various character functions.
(1) Find out length of string “hello world”.
43 | Page
Database Management (4331603)
44 | Page
Database Management (4331603)
B.Assessment-Rubrics
Faculty
Marks Obtained Date
Signature
Program Implementation Student’s engagement
Correctness and Presentation in practical activities Total
(4) Methodology (3) (3) (10)
R1 R2 R3
45 | Page
Database Management (4331603)
Date: _________________
A. Source code:
46 | Page
Database Management (4331603)
(c) Retrieve
those records of Account holder whose balance
between is 50000and 100000.
(d) Retrieve
those records of Account holder whose balance
not between is 50000and 100000.
47 | Page
Database Management (4331603)
48 | Page
Database Management (4331603)
(l) Count
only those records whose transaction made in the
month of ‘MAY’
49 | Page
Database Management (4331603)
(n) Display total balance for each branch from account table.
50 | Page
Database Management (4331603)
Assessment-Rubrics
Faculty
Marks Obtained Date
Signature
Program Implementation Student’s engagement
Correctness and Presentation in practical activities Total
(4) Methodology (3) (3) (10)
R1 R2 R3
51 | Page
Database Management (4331603)
Date: _________________
Practical No.7: Set and Join Operators.
A.Source code:
A) Write SQL query for set operators and join operations. (Use
tables of Practical 3).
1. Find all customers who have taken a loan and their
corresponding loan details.
52 | Page
Database Management (4331603)
53 | Page
Database Management (4331603)
7. Find the total amount of loans that have been fully paid off.
54 | Page
Database Management (4331603)
B.Assessment-Rubrics
Faculty
Marks Obtained Date
Signature
Program Implementation Student’s engagement
Correctness and Presentation in practical activities Total
(4) Methodology (3) (3) (10)
R1 R2 R3
55 | Page
Database Management (4331603)
Date: _________________
56 | Page
Database Management (4331603)
A. Assessment-Rubrics
Faculty
Marks Obtained Date
Signature
Program Implementation Student’s engagement
Correctness and Presentation in practical activities Total
(4) Methodology (3) (3) (10)
R1 R2 R3
57 | Page
Database Management (4331603)
Date: _________________
58 | Page
Database Management (4331603)
A. Assessment-Rubrics
Faculty
Marks Obtained Date
Signature
Program Implementation Student’s engagement
Correctness and Presentation in practical activities Total
(4) Methodology (3) (3) (10)
R1 R2 R3
59 | Page
Database Management (4331603)
58 | Page
Database Management (4331603)
59 | Page
Database Management (4331603)
.
--Explanation:
60 | Page
Database Management (4331603)
• In this example, the stored function will take an employee's ID as input and
return the employee's full name (first name and last name concatenated).
• NOTEPAD PROGRAM :
61 | Page
Database Management (4331603)
62 | Page
Database Management (4331603)
• Create a trigger:
63 | Page
Database Management (4331603)
• example of trigger:
• Assessment-Rubrics
Faculty
Marks Obtained Date
Signature
Program Implementation Student’s engagement
Correctness and Presentation in practical activities Total
(4) Methodology (3) (3) (10)
R1 R2 R3
64 | Page
Database Management (4331603)
• Rule: Each column should have atomic values, and each record should be
unique.
• Rule: The table must be in 1NF and all non-key attributes should depend on
the primary key.
65 | Page
Database Management (4331603)
66 | Page
Database Management (4331603)
Normalization Process:
a.) 1st Normal Form (1NF):
67 | Page
Database Management (4331603)
• Issue in 3NF:
The city, semester, and percentage might be considered non-
key attributes that should not depend on each other.
68 | Page
Database Management (4331603)
• Candidate Keys:
1. no (Student Number) is a unique identifier for each student.
2. no + subname: A combination of no (student number) and
subname (subject name) will uniquely identify each row.
69 | Page
Database Management (4331603)
2. Update Anomalies:
• If a manager's details (like mngrname or mngrage)
change, this needs to be updated across all rows where that
manager is referenced. This can cause data inconsistency .
3. Insertion Anomaly:
• If you want to insert a new manager into the system
without any employees yet reporting to them, it would be
impossible since the manager data is embedded within the
Employee table.
4. Deletion Anomaly:
• If you delete the only employee under a manager, you would
lose all information about the manager .
70 | Page
Database Management (4331603)
71 | Page
Database Management (4331603)
• Assessment-Rubrics
Faculty
Marks Obtained Date
Signature
Program Implementation Student’s engagement
Correctness and Presentation in practical activities Total
(4) Methodology (3) (3) (10)
R1 R2 R3
72 | Page
Database Management (4331603)
→A transaction in a database is a series of operations that are treated as a single unit. For
example, if a student updates their course registration, it involves reading data (like
available courses) and writing data (saving their course selection). A transaction can either
succeed or fail, but it must follow some rules to keep the database safe.
→ACID Properties:
1. Atomicity:
o A transaction must be all or nothing. If any part of the transaction fails,
the whole transaction fails.
.
2. Consistency:
o The database should always be in a valid state. After a transaction is
completed, the data should still follow all rules set by the database, like
checking that student IDs are unique.
o
3. Isolation:
o Transactions should not interfere with each other. If two students are
updating their records at the same time, one transaction should not
affect the other’s view of the data.
4. Durability:
o Once a transaction is successfully completed, it must be permanently
saved to the database, even if there is a system crash right afterward.
73 | Page
Database Management (4331603)
B.)Assessment-Rubrics
Faculty
Marks Obtained Date
Signature
Program Implementation Student’s engagement
Correctness and Presentation in practical activities Total
(4) Methodology (3) (3) (10)
R1 R2 R3
75 | Page