Cs403 Assignment Solution 1 Fall 2023
Cs403 Assignment Solution 1 Fall 2023
VU ID: BC 200205775
NAME: MUHAMMAD ASIM
CS403- Database Management System
ASSIGNMENT NO. 2 SOLUTION SPRING 2023
Task 1:
Write SQL statement to create a new database in SQL Server by your VU ID (sample screenshot
is provided on the last page of this file).
SOLUTION:
SQL statement to create a new database in SQL Server:
--CREATE DATABASE bc200205775;
Task 2:
Write SQL statements for the following:
Create tables: Stadium, MatchSchedule and Block in database created in Task 1.
For each table, you have to define all attributes/columns given in ERD with appropriate
data types.
You are also required to define Primary key of each table.
Transform multi-valued attribute.
Map all relationships and add foreign keys in appropriate tables according to
relationships types.
SOLUTION:
SQL statements to create tables:
1. Stadium Table:
USE bc200205775;
CREATE TABLE Stadium (
StadiumID INT PRIMARY KEY,
StadiumName VARCHAR(100),
Location VARCHAR(100),
Dimension VARCHAR(50)
);
2. MatchSchedule Table:
USE bc200205775
CREATE TABLE MatchSchedule (
ScheduleID INT PRIMARY KEY,
MatchDate DATE,
MatchTime TIME,
MatchDay VARCHAR(20),
Teams VARCHAR(100)
);
Task 3:
Write SQL Statements to insert 2 records in each table.
SOLUTION:
SQL Statements to insert 2 records in each table:
1. Inserting records in the Stadium Table:
USE bs200205775;
INSERT INTO Stadium (StadiumID, StadiumName, Location, Dimension)
VALUES (1, 'Stadium A', 'Location A', 'Dimension A'),
(2, 'Stadium B', 'Location B', 'Dimension B');
2. Inserting records in the MatchSchedule table:
USE bs200205775;
INSERT INTO MatchSchedule (ScheduleID, MatchDate, MatchTime,
MatchDay,Teams)
VALUES (1, '2023-07-10', '14:30:00', 'Sunday', 'Team A vs Team B'),
(2, '2023-07-12', '18:00:00', 'Tuesday', 'Team C vs Team D');
USE bs200205775;
INSERT INTO Block (BlockID, BName, Capacity, Charges, BColor, StadiumID)
VALUES (1, 'Block 1', 100, 10.50, 'Red', 1),
(2, 'Block 2', 150, 8.75, 'Blue', 1);
Task 4:
Write SQL Statements to:
1. Display name and capacity of all blocks.
USE bc200205775
SELECT BName, Capacity
FROM Block;