0% found this document useful (0 votes)
60 views77 pages

DBMS Manual (Complete)

Uploaded by

darshit240708
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)
60 views77 pages

DBMS Manual (Complete)

Uploaded by

darshit240708
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/ 77

Diploma Engineering

Laboratory Manual
Database Management
4331603

[Information Technology / Semester-3]


Enrolment No 236170316036
Name Gohel Vrujkumar Mansukhbhai
Branch Information Technology (IT)
Academic Term
Institute Government Polytechnic Ahmedabad

Directorate of Technical Education


Gandhinagar - Gujarat
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.

DTE’s Mission: To improve equity, Access & Quality in


Technical education.

Institute’s Vision: To be a leading technical institute that


provides transformative education to learners for achieving
competency as per the need of industry, society and
contributing in building nation.

Institute’s Mission: To provide a conducive learning


environment to nurture learners.
To act as a catalyst for achieving academic excellence by
bringing stake holders on same platform.

Department’s Vision: To acquire quality Education, Research


and Development in the field of Information technology
meeting the global standards and comply with the ever-
growing technology

Department’s Mission: Project development in association


with the Government, Industries and Professionals will be done
that can meet industrial needs.
Students will be competent by learning the principals of
Information technology that can match national and
international standards.
Database Management (4331603)

Certificate

This is to certify that Mr. Gohel Vrujkumar Enrollment No. 236170316036 of

3rd Semester of Diploma in Information Technology of Institute Government Polytechnic

Ahmedabad (GTU Code 617 )has satisfactorily completed the term work in course

“Database Management (4331603)” for the academic year:...................................... Term: Odd

prescribed in the GTU curriculum.

Place: ………………………….

Date: ………………………….

Signature of Course Faculty Head of the Department


Database Management (4331603)

Programme Outcomes (POs):

1. Basic and Discipline specific knowledge: Apply knowledge of basic mathematics,


science and engineering fundamentals and engineering specialization to solve the
engineering problems.
2. Problem analysis: Identify and analyse well-defined engineering problems using
codified standard methods.
3. Design/ development of solutions: Design solutions for engineering well-defined
technical problems and assist with the design of systems components or processes to
meet specified needs.
4. Engineering Tools, Experimentation and Testing: Apply modern engineering tools
and appropriate technique to conduct standard tests and measurements.
5. Engineering practices for society, sustainability and environment: Apply
appropriate technology in context of society, sustainability, environment and ethical
practices.
6. Project Management: Use engineering management principles individually, as a team
member or a leader to manage projects and effectively communicate about well- defined
engineering activities.
7. Life-long learning: Ability to analyse individual needs and engage in updating in the
context of technological changes in field of engineering.

4 | Page
Database Management (4331603)

Practical Outcome - Course Outcome matrix


Course Outcomes (COs):
a. Explain the basic concepts of databases.
b. Design database using Entity relationship approach.
c. Implement Relational algebra in a database.
d. Apply SQL Commands for creating, manipulating and controlling databases.
e. Apply concepts of normalization to design an optimal database.
f. Explain transaction management concepts for concurrent use of database.
Sr.
Practical Outcome/Title of experiment CO1 CO2 CO3 CO4 CO5 CO6
No.
1. Basics of Database, its applications and
Data Models
a. Prepare a report on Current Database
Trends.  - - - - -
b. Prepare a list of most famous websites
and Mobile Applications with Database
Tools used in it.
2. Entity Relationship Diagrams
a. Draw ER-Diagram for Banking
Management System -   - - -
b. Convert ER-Diagram to relational
schema.
3. SQL Commands
a. Design the below given schemas
using SQL Command – “Create”.
Decide the appropriate data type for
each column.
b. Insert data in above tables using SQL
Command “Insert”. - - -  - -
c. Retrieve data from tables inPractical
2 using Data SQLcommand- “Select”.
a. Write SQL queries to use Update, alter,
rename, delete, truncate and distinct

4. In-built Functions (Part – 1)


a. Write SQL queries to use various
date functions. - - -  - -
a. Write SQL queries to use various
numeric functions

5 | Page
Database Management (4331603)

5. In-built Function (Part 2)


a. Write SQL queries to use various
character functions.
(1) Find out length of string “hello world”.
(2) Change the case of ‘HELLO WORLD’
string to lower case.
(3) Change the case of
‘hello world’ toupper case.
(4) Display each word
initial letter ascapital letter :
government
polytechnic for girls. - - -  - -
(5) Find ‘put’ from string
‘computer’. (6)Add 10 star on
left side of India string.
(7) Add 10 star on right side of
Indiastring.
(8) Trim ‘ion’ from ‘information’.
(9) Trim ‘info’ from ‘information’.

b. Write SQL queries to use various


conversion functions
(a) Convert 100000 in format 99,99,99
a. (b)Convert today’s date to MM-DD-YY
format
6. Group Functions and Operators
a. Write SQL queries to use variousgroup
- - -  - -
function and operators using tables
created.
7. Set and Join Operators.
a. Write SQL query for set operators - - -  - -
and join operations.
8. SQL Constraint
a. Apply the concept of integrity/data
- - -  - -
constraints while creating/altering a
table.
9. Privilege Commands
a. Write SQL queries for CREATE USER,
- - -  - -
GRANT, REVOKE AND DROP USER
command.

6 | Page
Database Management (4331603)

10. PL/SQL Concepts


a. Write a program in PL/SQL to show the
user of Cursor
b. Write a program in PL/SQL to show the
user of Stored Procedures. - - -  - -
c. Write a program in PL/SQL to show the
user of Stored Function.
a. d. Write a program in PL/SQL to
show the user of Database Triggers.
11. Refining database design through
normalization
a. Normalization of database.

Consider the following relational schema:


a)Employee(eid, ename, salary, mngr id,
mngrname, mngrage,ecity)

b) Student(no,name, bdate, city, semester,


subname, submarks, percentage)
For above schemas, answer the following
- - - -  -
questions:-
a) Determine the primary key for given
relation.
b) Is there any pitfall in design of relation
schema? Explain it.
c) Find out various dependencies among
given attributes of given relation schema.
a. d) Normalize given relation schemaup
to possible normal form
Normalization of database for a given
relational schema.
12. Transaction Management
a. Prepare a report on transaction 
- - - - -
management concepts for concurrent
access of database by multiple users.

7 | Page
Database Management (4331603)

Industry Relevant Skills


The following industry relevant skills are expected to be developed in the students
by performance of experiments of this course.
• Data retrieval and analysis from relational databases.
• Query optimization and performance tuning for efficient data access.
• Basic database administration tasks, such as creating tables and managing user
permissions.
• Simple data manipulation and transformation using SQL statements.
• Familiarity with database systems commonly used in various industries.

Guidelines to Course Faculty


1. Course faculty should demonstrate experiment with all necessary implementation
strategies described in curriculum.
2. Course faculty should explain industrial relevance before starting of each
experiment.
3. Course faculty should involve & give opportunity to all students for hands on
experience.
4. Course faculty should ensure mentioned skills are developed in the students by
asking.
5. Utilise 2 hrs of lab hours effectively and ensure completion of write up with quiz
also.
6. Encourage peer to peer learning by doing same experiment through fast learners.

Instructions for Students


1. Organize the work in the group and make record of all observations.
2. Students shall develop maintenance skill as expected by industries.
3. Student shall attempt to develop related hand-on skills and build confidence.
4. Student shall develop the habits of evolving more ideas, innovations, skills etc.
5. Student shall refer technical magazines and data books.
6. Student should develop habit to submit the practical on date and time.
7. Student should well prepare while submitting write-up of exercise.

8 | Page
Database Management (4331603)

Continuous Assessment Sheet


Enrollment No: 236170316036
Name: Gohel Vrujkumar Mansukhbhai Term:
Sr. Marks
Practical Outcome/Title of experiment Page Date Sign
No. (10)
1. Basics of Database, its applications and Data
Models
a. Prepare a report on Current Database
Trends.
b. Prepare a list of most famous websites and
Mobile Applications with Database Tools
used in it.
2. Entity Relationship Diagrams
a. Draw ER-Diagram for Banking
Management System
b. Convert ER-Diagram to relational schema.
3. SQL Commands
d. Design the below given schemas using SQL
Command - ”Create”. Decide the
appropriate data type for each column.
e. Insert data in above tables using SQL
Command ”Insert”.
f. Retrieve data from tables in Practical 2
using Data SQL command- “Select”.
g. Write SQL queries to use Update, alter,
rename, delete, truncate and distinct
4. In-built Functions (Part – 1)
b. Write SQL queries to use various date
functions.
c. Write SQL queries to use various numeric
functions

9 | Page
Database Management (4331603)

5. In-built Function (Part 2)


a. Write SQL queries to use various character
functions.
(1) Find out length of string “hello world”.
(2) Change the case of ‘HELLO WORLD’ string to
lower case.
(3) Change the case of ‘hello world’ to upper
case.
(4) Display each word initial letter as capital
letter : government
polytechnic for girls.
(5) Find ‘put’ from string ‘computer’.
(6) Add 10 star on left side of India string.
(7) Add 10 star on right side of India string.
(8) Trim ‘ion’ from ‘information’.
(9) Trim ‘info’ from ‘information’.

b. Write SQL queries to use various conversion


functions
(a) Convert 100000 in format 99,99,99
a. (b)Convert today’s date to MM-DD-YY
format
6. Group Functions and Operators
a. Write SQL queries to use various group
function and operators using tables created.
7. Set and Join Operators.
a. Write SQL query for set operators and join
operations.
8. SQL Constraint
a. Apply the concept of integrity/data
constraints while creating/altering a table.
9. Privilege Commands
a. Write SQL queries for CREATE USER,
GRANT, REVOKE AND DROP USER
command.
10. PL/SQL Concepts
a. Write a program in PL/SQL to show the user
of Cursor
b. Write a program in PL/SQL to show the user
of Stored Procedures.
c. Write a program in PL/SQL to show the user
of Stored Function.
d. Write a program in PL/SQL to show the user
of Database Triggers.

10 | Page
Database Management (4331603)

11. Refining database design through normalization


a. Normalization of database.

Consider the following relational schema:


a)Employee(eid, ename, salary, mngr id,
mngrname, mngrage,ecity)

b) Student(no,name, bdate, city, semester,


subname, submarks, percentage)
For above schemas, answer the following
questions:-
a) Determine the primary key for given relation.
b) Is there any pitfall in design of relation
schema? Explain it.
c) Find out various dependencies among given
attributes of given relation schema.
d) Normalize given relation schema up to
possible normal form Normalization of database
for a given relational schema.
12. Transaction Management
a. Prepare a report on transaction
management concepts for concurrent
access of database by multiple users.

11 | Page
Database Management (4331603)

Date: _________________

Practical No.1: Basics of Database, its applications and Data Models


a. Prepare a report on Current Database Trends.
b. Prepare a list of most famous websites and Mobile Applications
with Database Tools used in it.

A. Report:

Prepare a report on Current Database Trends.


The landscape of database technology is undergoing significant
transformation, with cloud databases leading the charge.
Traditional on-premises systems such as Oracle, IBM, SAP,
Teradata, and Software AG are increasingly losing ground to
cloud-native databases. This shift is largely driven by the
flexibility, scalability, and cost-effectiveness that cloud solutions
offer. Major players like Microsoft, Amazon Web Services (AWS),
Google Cloud Platform (GCP), and Alibaba Cloud are at the
forefront, providing powerful database services that cater to a wide
range of enterprise needs. These cloud databases are not only
more adaptable to modern workloads but also align better with the
digital transformation goals of businesses, making them the
preferred choice for new
deployments and migrations
from legacy systems.
Another pivotal trend is the
integration of Artificial
Intelligence (AI) into
database management. AI is
revolutionizing the way
databases are maintained
and operated by reducing
the manual workload on
database administrators.
Through AI-driven tools,
administrators can now easily identify and resolve issues such as
storage and memory bottlenecks, which can otherwise hinder
database performance. This integration of AI enhances the overall
efficiency of database systems, allowing for proactive maintenance
and optimization without the need for constant human
12 | Page
Database Management (4331603)

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)

B. Prepare a list of most famous websites and Mobile


Applications with Database Tools used in it.

List of Most Famous Websites and Mobile Applications


with Database Tools Used

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:

A) Draw ER – Diagram for Banking Management System.

Entities: It is an object or concept in the real world from which


data is to be collected. For example, Customer, Account,
Branch.
Attributes: Characteristics or features of an entity. Examples
include Customer_ID, Account_Number, and Branch_Address.
Relationships: Links that exist between entities. In this case, A
customer can have many accounts. ER for Banking
Management System
This is the simplest form of ER for Banking Management System.
It includes all the core entities and relationships.

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)

B) Convert ER-Diagram of Banking Management System to relational


schema
A relational schema is the database's logical structure. It consists
of tables, columns and the relationships between these.
Tables:

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)

Practical No.3: SQL Commands


a. Design the below given schemas using SQL Command - ”Create”.
Decide the appropriate data type for each column.
b. Insert data in above tables using SQL Command ”Insert”.
c. Retrieve data from tables in Practical 2 using Data SQL command-
“Select”.
d. Write SQL queries to use Update, alter, rename, delete, truncate and
distinct.

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)

(c) Create table INSTALLMENT with column loan number, installment


number, installment date and amount.

(d) Create table TRANSACTION with column account number,


transaction date, amount, type of transaction, mode of payment.

22 | Page
Database Management (4331603)

(e) Show the structure of above tables using “Describe” command.

23 | Page
Database Management (4331603)

B) Insert data in above tables using SQL Command ”Insert”

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.

(b) Display all rows and selected columns of table Installment.

26 | Page
Database Management (4331603)

(c) Display selected rows and selected columns of table


Account.

(d) Display selected rows and all columns of table loan.

(e) Display the list of customers in descending order of their name from account
table.

27 | Page
Database Management (4331603)

(f) Display those records where mode of payment is “cheque”.

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.

(f) Rename the table ACCOUNT to ACCOUNT_MASTER.

30 | Page
Database Management (4331603)

(g) Update the column balance for all the account holders. (Multiply the
balance by2 foreach account holders)

(h) Delete the records whose account no is A004

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).

(e) Display the Loan amount*2 of table LOAN.

(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.

(h) Increase the size 5 to 7 of column acc_no.

33 | Page
Database Management (4331603)

Table: INSTALLMENT.
(a) Change the Inst_Date ‘2-Feb-04’ to ’3-Mar-04’.

(b) Reduce 5000 amount from all Installment holders.

(c) Add the amount 5000 where loan no is ‘L003’ and ‘L002’.

34 | Page
Database Management (4331603)

(d) Change the column size of 5 to 7 where column name is Loan_no.

(e) Delete row where inst_no is ‘I001’.

(f) Only create a structure of table installment1 from table installment.

35 | Page
Database Management (4331603)

Table: TRANSACTION.
(a) Insert any duplicate value and display all the records without any duplicate
rows.

(b) Select all the records in descending order(account number wise).

(c) Display amt, date, and type of transaction by date wise

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: _________________

Practical No.4: In-built Functions (Part – 1)

A. Source code:
A) Write SQL queries to use various date
functions.
(a) Add 3 months in current date.

(b) Display months between date: ’17-02-


04’ and ’17-02-05’.

(c) Display last date of month ‘2-feb-06’.

38 | Page
Database Management (4331603)

(d) If the date is 31-jul-13 then find out


the date of friendship day.

B.) Write SQL queries to use various numeric functions


(a) Display integer value of 125.25.

(b) Display absolute value of(-15)

(c) Display ceil value of 55.65

39 | Page
Database Management (4331603)

(d) Display floor value of 100.2

(e) Display the square root of 16.

(f) Display square root of 20.

(g) Display result of 12 raised to 6.

(h) Display result of 24 mod 2.

40 | Page
Database Management (4331603)

(i) Show value of e3.

(j) 2 is angle in radius find out cos, sin, tan value of 2.

(k) Show output of sign(-25), sign(25), sign(0).

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:_________________

Practical No.5: In-built Function (Part 2)

A.Source code:
A) Write SQL queries to use various character functions.
(1) Find out length of string “hello world”.

(2) Change the case of ‘HELLO WORLD’ string to lower case.

(3) Change the case of ‘hello world’ to upper case.

(4) Display each word initial letter as capital letter :


government polytechnic for girls.

43 | Page
Database Management (4331603)

(5) Find ‘put’ from string ‘computer’.

(6) Add 10 star on left side of India string.

(7) Add 10 star on right side of India string.

(8) Trim ‘ion’ from ‘information’.

(9) Trim ‘info’ from ‘information’.

44 | Page
Database Management (4331603)

B.) Write SQL queries to use various conversion functions


(a) Convert 100000 in format 99,99,99

(b) Convert today’s date to MM-DD-YY format

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: _________________

Practical No.6: Group Functions and Operators

A. Source code:

A) Write SQL queries to use various group function using tables


created in Practical3.
(a) Retrieve specified information for the account holder who
are not in‘Ahmedabad’.

(b) Retrievespecified information for the account holder who


are not in‘Ahmedabad ’or ‘Vadodara’.

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.

(e) Display only those records whose amount is 5000, 25000,


30000.

47 | Page
Database Management (4331603)

(f) Display only those records whose amount not in 5000,


25000, 30000.

(g) Find the total transaction amount of account holder from


transaction table.

48 | Page
Database Management (4331603)

(h) Find minimum amount of transaction.

(i) Find maximum amount of transaction.

(j) Count the total account holders.

(k) Count only that record that’s made of payment is ‘cash’.

(l) Count
only those records whose transaction made in the
month of ‘MAY’

49 | Page
Database Management (4331603)

(m) Find the average value of transaction.

(n) Display total balance for each branch from account table.

(o) Display total balance for account in Ahmadabad city.

(p) Find total amount of mode of pay ‘cash’ from transaction


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.

2. Find all customers who have not taken a loan.

52 | Page
Database Management (4331603)

3. Find the total amount of loans taken by each customer.

4. Find the total amount of installments paid for each loan.

5. Find the total amount of transactions made by each customer.

53 | Page
Database Management (4331603)

6. Find the average interest rate for all loans.

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: _________________

Practical No.8: SQL Constraint


A. Source code:
A) Apply the concept of integrity/data constraints while
creating/altering a table:
(a) Create table SalesPeople where Snum varchar2(4) PRIMARY
KEY (first letter should startwith S) , Sname varchar2(20) NOT
NULL,City Varchar2(15),Mobile_No Number(10).

(b) Create table Customer where cnum varchar2(4) P.K(first letter


should start with C), Cname varchar2(20) NOT NULL,city
varchar2(20),Rating number(3) DEFAULT 10,Snum number(4)
F.K (where snum refers salespeople table)

56 | Page
Database Management (4331603)

(c) Create table Order where Order_No number(4) P.K, Amount


number(5), odate varchar2(10), cnum varchar2(4) F.K,(where
cnum refers customer table), snum varchar2(4) F.K (where
snum refers Salespeople table)

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: _________________

Practical No.9: Privilege Commands


B. Source code:
A) Write SQL queries for CREATE USER, GRANT, REVOKE AND DROP
USER commands.
(a) Create a new user User1.

(b) Grant connect, resource and dba rights to user1.

(c) Grant all permissions of account table to user1.

(d) Remove select permission on account table for user1.

58 | Page
Database Management (4331603)

(e) Delete user1.

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)

Practical No.10: PL/SQL Concepts


1.) Write a program in PL/SQL to show the user of Cursor.
• Here's a information about PL/SQL program to demonstrate the
use of a Cursor.
• In this example, we will use employee table’s data ….

• Here is a cursor program in notepad :

• After right the program with specific condition we can go on


oracle and set serverout on and execute the program to get
output..

58 | Page
Database Management (4331603)

2.) Write a program in PL/SQL to show the user of Stored


Procedures.

I. Create a Stored Procedure

59 | Page
Database Management (4331603)
.

II. Execute the Stored Procedure

--Explanation:

60 | Page
Database Management (4331603)

3.) write a program in PL/SQL to show the user of stored function:

• 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 :

• Use the Stored Function in other block:

61 | Page
Database Management (4331603)

• Run the code in oracle to use stored functions of employees table:

4.) write a program in PL/SQL to show the user of database triggers.

• In this example, we'll create a trigger that changes made to an employees


table into a employees_audit table whenever an INSERT, UPDATE, or
DELETE operation is performed.

62 | Page
Database Management (4331603)

• Create employees_audit table:

• Create a trigger:

• The trigger employees_audit_trigger is set to fire AFTER INSERT OR


UPDATE OR DELETE on the employees table.

63 | Page
Database Management (4331603)

• INSERT: When a new record is inserted into the employees table, an


entry is made in the employees_audit table with the new employee's
details.
• UPDATE: When a record is updated, an entry is made with both the old
and new salary values.
• DELETE: When a record is deleted, an entry is made with the old salary
value.

• 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)

Practical No.11: Refining database design through normalization

a.) Normalization of database:


• Consider the following relational schema:

(a.)Employee(eid, ename, salary, mngr id, mngrname, mngrage,ecity)

• Relational Schema Given:

A.) 1st Normal Form (1NF):

• Rule: Each column should have atomic values, and each record should be
unique.

o The Employee table appears to satisfy 1NF, by each column holds


atomic values (e.g., no multiple values in a single column), and there's
a unique eid for each employee.

• Issue: Information about the employee's manager is stored redundantly.

B.) 2nd Normal Form (2NF):

• Rule: The table must be in 1NF and all non-key attributes should depend on
the primary key.

• PRIMARY KEY: in this table eid.

65 | Page
Database Management (4331603)

• Issue in 2NF : Manager details (like mngrname and mngrage) depend on


mngr_id, not directly on eid. This causes redundancy .

• Solution: Split the table to remove partial dependencies.

1.) Employee Table:

2.) Manager Table:

c.) 3rd Normal Form (3NF):

• Rule: The table must be in 2NF, and there should be no transitive


dependencies.

• Issue in 3NF: There are no transitive dependencies in the current tables.

1.) Employee Table (in 3NF):

• eid: Employee ID (Primary Key)


• ename: Employee Name
• salary: Employee Salary
• mngr_id: Manager ID (Foreign Key to the Manager table)
• ecity: Employee City

2.) Manager Table (in 3NF):

66 | Page
Database Management (4331603)

• mngr_id: Manager ID (Primary Key)


• mngrname: Manager Name
• mngrage: Manager Age

(b) Student(no,name, bdate, city, semester,subname, submarks,


percentage)

Normalization Process:
a.) 1st Normal Form (1NF):

• Issue in 1NF: Multiple subjects (subname) and marks


(submarks) are stored in the same row, which violates the
atomicity rule.

b.) 2nd Normal Form (2NF):

• Issue in 2NF:Some attributes (like name, bdate, city,


percentage) depend only on no (student number), not on
subname. This causes partial dependencies, which violate
2NF.

1.) Student Table (with attributes dependent only on no):

2.) Subject Table (with attributes dependent on both no and


subname):

67 | Page
Database Management (4331603)

• Now, the Student table holds student details, and the


Student_Subject table holds the subject and marks information
for each student.

• c.) 3rd Normal Form(3NF):

• Issue in 3NF:
The city, semester, and percentage might be considered non-
key attributes that should not depend on each other.

1.) Student Table (in 3NF):

• no: Student Number (Primary Key)


• name: Student Name
• bdate: Birthdate
• city: City
• semester: Semester
• percentage: Overall Percentage

2.) Student_Subject Table (in 3NF):

• no: Student Number (Foreign Key to the Student table)


• subname: Subject Name
• submarks: Marks obtained in the subject

68 | Page
Database Management (4331603)

• For above schemas, answer the following questions:-

1.) Determine the primary key for given relation.

(a) Employee Relation:

• Thus, the primary key for the Employee relation is:eid

• PRIMARY KEY: eid

(b) Student Relation:

• 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.

• PRIMARY KEY: (No,subname)

2.) Is there any pitfall in design of relation schema? Explain it.

• Yes, there are pitfalls in the design of the relation schema


provided. These pitfalls can lead to data anomalies,
redundancy, and inefficiencies.

→Let’s examine the possible pitfalls in the Employee schema.

(a) Employee Relation:

69 | Page
Database Management (4331603)

• Pitfalls in the Employee Schema:

1. Redundancy of Manager Data:


o In this schema, mngr_id, mngrname, and mngrage are
repeated for every employee who reports to the same
manager. This redundancy can lead to update
anomalies.

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 .

3.) Find out various dependencies among given attributes


of givenrelation schema.

• To find dependencies among the attributes of the given


relation schemas, we need to identify functional
dependencies (FDs).
• A functional dependency describes the relationship
between two attributes, where one attribute determines the
value of another attribute.

→Let’s examine dependencies in the Employee schema

(a) Employee Relation:

70 | Page
Database Management (4331603)

• Identifying Functional Dependencies:

1. eid → ename, salary, mngr_id, ecity:


o Explanation: The eid (employee ID) uniquely identifies
the employee’s name, salary, manager ID, and city.
This is the most fundamental dependency as eid is a
unique identifier for each employee.

2. mngr_id → mngrname, mngrage:


o Explanation: The mngr_id (manager ID) determines the
mngrname (manager's name) and mngrage
(manager's age). Multiple employees can have the
same mngr_id, but each mngr_id will have the same
mngrname and mngrage.

3. eid → mngr_id → mngrname, mngrage (T.D.):


o Explanation: The eid (employee ID) indirectly
determines the manager's name and age through the
mngr_id. This is a transitive dependency, where one
attribute (mngr_id) determines other non-key
attributes (mngrname, mngrage) through the
dependency chain from eid.

• Summary of Dependencies in the Employee Table:


→eid → ename, salary, mngr_id, ecity
→mngr_id → mngrname, mngrage
→Transitive dependency: eid → mngr_id → mngrname,
mngrage.

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)

Practical No.12: Transaction Management


A.)Prepare a report on transaction management concepts forconcurrent
access of database by multiple users.

→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)

→In a system where many users (like students, teachers,


and administrators) are accessing a database at the same
time, it's possible that they could all try to read or update
the same piece of data at the same time. Without
transaction management, this could lead to problems
like:
• Lost Updates: One user’s update could accidentally
overwrite another’s.
• Dirty Reads: A user could read incorrect data that hasn’t
been finalized yet.
• Non-Repeatable Reads: A user could read the same data
twice and get different results because another user
changed the data in between.
• Phantom Reads: A user could see different sets of data
between queries because another user inserted or
deleted data during the transaction.

• Transaction management is essential in multi-user


environments like school databases where students,
teachers, and administrators are working
simultaneously. By following the ACID properties and
using concurrency control techniques,
• the database ensures that multiple users can access the
data without causing errors it is managed helps in
designing safe and reliable database systems that work
efficiently even when many users are accessing them at
the same time.
74 | 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

You might also like