0% found this document useful (0 votes)
13 views2 pages

Sample Question - Database Final Exam

Uploaded by

md.abrarfuad
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)
13 views2 pages

Sample Question - Database Final Exam

Uploaded by

md.abrarfuad
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/ 2

EDGE: BU-CSE Digital Skills Training

Database
Sample Question

You are provided with a database schema for a travel system. Your task is to create the database,
insert sample data, and then write SQL queries to answer the questions about the data.

Figure: Schema diagram of travel database

1. Create a database name travel with above tables. [10]


2. Insert data in each table. Sample data are given in below. [5]

Company:
id name city contact
1 SR Group Dhaka 80988789
2 Karim Group Faridpur 576577867
3 Hanif Travel Dhaka 57678677

Bus
bus_id bus_name model company_id
1 Hanif volvo 3
2 Nabil scania 1
3 Alam volvo 1
4 SR sarkar 1
5 Hanif Scania Scania 3

Driver

Page 1 of 2
EDGE: BU-CSE Digital Skills Training

d_id name phone license_no city bus_id

1 Habib 198398409 A125679 Dhaka 1

2 Kamal 1374577567 A125622 Barishal 2

3 Nabab 1983984409 A12534 Rajshahi 5

4 Jamal 1374877567 BA125679 Dhaka 4

Passenger
p_id first_name last_name gender email phone
1 nasir Hossain male nasir@gmail.com 1900987654
2 azim Uddin male azim@gmail.com 9876262636
3 bina Kabir female bina@gmail.com 1933987654
4 aslam Khan male aslam@gmail.com 9876262636

Book_ticket:
t_id passenger_id bus_id route_id journey_date seat_no
1 1 3 1 11/15/2019 A3
2 2 3 2 11/15/2019 A4
3 3 3 1 11/15/2019 A8
4 4 3 1 11/15/2019 B4

Payment
payment_id passenger_id bus_id amount
1 4 3 500
2 2 1 500

3. Now write SQL for the following questions: [10]

1. List all buses along with their respective company names.

2. Find all drivers who work for ‘SR Group’.


3. Count the number of passengers who have booked tickets for the bus named ‘Alam’.
4. Find the average payment for each employee.

5. Find the total number of buses for each company.


6. Find all passengers who use Banglalink phone number.
Hints: phone number starts with 019 or 014
7. List the details of passengers who have made more than one payment.
8. List the details of the top 3 most frequently traveled passengers.
9. Create a view for the following problem:
Find the name (first_name and last_name), email, phone of all passengers.
10. Find the total revenue generated by each company.

Good Luck!!!

Page 2 of 2

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy