CS Term 1 Practical File
CS Term 1 Practical File
(TERM 1)
ANIKET AGARWAL
CLASS-XII-C
ROLL NO-5
(b) Show all information where capacity > noofstudents in order of rtno:
(c) Show area_covered where Distance > 20 and Charges < 80000:
(d) Show transporter-wise total number of students traveling:
(e) Show Rtno, Area_covered, and average cost per student (Charges /
Noofstudents):
(f) Add a new record with data (11, "Moti Bagh", 35, 32, 10, "Kisan Tours", 35000):
ANS:-
INSERT INTO SchoolBus (Rtno, Area_covered, Capacity, Noofstudents, Distance,
Transporter, Charges) VALUES (11, 'Moti Bagh', 35, 32, 10, 'Kisan Tours', 35000);
(b) Display NAME, STIPEND, SUBJECT, and annual stipend (12 × STIPEND)
c) Count the number of students who are either PHYSICS or COMPUTER Sc.
Graduates
(c) List all patient names with their date of admission in ascending order
(d) Display patient’s name, charges, and age for male patients only
(e) Count the number of patients with age > 20
(k) Display details of all patients whose names start with ‘Z’
(c) Display the coach’s name and Acodes in ascending order of Acode
(d) Display the content of the Activity table whose ScheduleDate is earlier than
01/01/2004 in ascending order of ParticipantsNum
(e) Display the names of coaches who are not associated with any activity at all
Output of Queries
● The ROUND(number, -1) function rounds the number to the nearest 10s
place (negative precision).
● Output: 340
b) List business done by the movies showing only MovieID, MovieName and
Total_Earning.
e) List MovieID, MovieName and Cost for all movies with ProductionCost greater than
10,000 and less than 1,00,000.
f) List details of all movies which fall in the category of comedy or action.
g) List details of all movies which have not been released yet
Assumed Table Creation Schema
Table: UNIFORM
Table: COST
Rectifying the Anomalies
Before inserting into the COST table, the handkerchief's details must first be inserted
into the UNIFORM table to avoid a foreign key violation.
The FOREIGN KEY constraint ensures that any data entered into the COST table will
require a corresponding record in the UNIFORM table.
If not already present, add the following constraint to the COST table:
This enforces referential integrity, preventing invalid UCode values in the COST table.
To ensure a UCode can only be assigned if the UName is provided, add a NOT NULL
constraint to the UName column in the UNIFORM table:
This ensures that UName must be specified whenever a new UCode is added.
To enforce the condition that the price of an item is greater than zero in the COST table,
add a CHECK constraint:
Final Schema
Table: UNIFORM
Table: COST
a) Create the table Product with appropriate data types and constraints
c) List the Product Code, Product Name, and price in descending order of
their Product Name. If PName is the same, display in ascending order of
price.