CBSE Class 12 – Computer Science Question Paper 2023

 

SECTION-A

1. State True or False.
“Identifiers are names used to identify a variable, function in a program.”

Answer:
True


2. Which of the following is a valid keyword in Python?
(a) false
(b) return
(c) non_local
(d) none

Answer:
(c) non_local


3. Given the following Tuple:
Tup = (10, 20, 30, 50)
Which of the following statements will result in an error?
(a) print(Tup[0:1])
(b) Tup.insert(2, 3)
(c) print(Tup[1:2])
(d) print(len(Tup))

Answer:
(b) Tup.insert(2, 3)
Tuples are immutable in Python, so the insert method cannot be used on them.


4. Consider the given expression:
5<10 and 12>7 or not 7>4
Which of the following will be the correct output, if the given expression is evaluated?
(a) True
(b) False
(c) NONE
(d) NULL

Answer:
(a) True
Explanation:
The expression evaluates as follows:
5 < 10 (True), 12 > 7 (True), 7 > 4 (True).
So, the expression becomes True and True or not True, which evaluates to True.


5. Select the correct output of the code:
S = “Amrit Mahotsav @ 75”
A = S.partition(“@”)
print(A)

Answer:
(a) (‘Amrit Mahotsav’, ‘@’, ’75’)
Explanation:
The partition method splits the string into a tuple with three parts: the part before the separator (@), the separator itself, and the part after the separator.

6. Which of the following mode keeps the file offset position at the end of the file?
(a) r+
(b) x
(c) w
(d) a

Answer:
(d) a


7. Fill in the blank.
… function is used to arrange the elements of a list in ascending order.
(a) arrange()
(b) sort()
(c) ascending()
(d) asort()

Answer:
(b) sort()


8. Which of the following operators will return either True or False?
(a) +=
(b) !=
(c) –
(d) =

Answer:
(b) !=


9. Which of the following statement(s) would give an error after executing the following code?

python
Stud = {"Murugan": 100, "Mithu": 95} # Statement 1
print(Stud[95]) # Statement 2
Stud["Murugan"] = 99 # Statement 3
print(Stud.pop()) # Statement 4
print(Stud) # Statement 5

Answer:
(d) Statements 2 and 4
Explanation:

  • Statement 2: You cannot access a dictionary by value (Stud[95] is incorrect).
  • Statement 4: The pop() method requires a key as an argument, not called without one.

10. Fill in the blank.
… is a number of tuples in a relation.
(a) Attribute
(b) Degree
(c) Domain
(d) Cardinality

Answer:
(d) Cardinality


11. The syntax of seek() is:
file_object.seek(offset[, reference_point])
What is the default value of reference point?
(a) 0
(b) 1
(c) 2
(d) 3

Answer:
(a) 0


12. Fill in the blank:
… clause is used with SELECT statement to display data in a sorted form with respect to a specified column.
(a) WHERE
(b) ORDER BY
(c) HAVING
(d) DISTINCT

Answer:
(b) ORDER BY

13. Fill in the blank:
… is used for point-to-point communication or unicast communication such as radar and satellite.
(a) INFRARED WAVES
(b) BLUETOOTH
(c) MICROWAVES
(d) RADIOWAVES

Answer:
(c) MICROWAVES


14. What will the following expression be evaluated to in Python?
print(4+3*5/3-5%2)

Answer:
(b) 8.0
Explanation:
Order of operations (PEMDAS):

  • First, multiplication and division: 3 * 5 = 15, 15 / 3 = 5
  • Then, modulus: 5 % 2 = 1
  • Then, addition and subtraction: 4 + 5 – 1 = 8.0

15. Which function returns the sum of all elements of a list?
(a) count()
(b) sum()
(c) total()
(d) add()

Answer:
(b) sum()


16. fetchall() method fetches all rows in a result set and returns a:
(a) Tuple of lists
(b) List of tuples
(c) List of strings
(d) Tuple of strings

Answer:
(b) List of tuples


17. Assertion (A): To use a function from a particular module, we need to import the module.
Reason (R): import statement can be written anywhere in the program, before using a function from that module.

Answer:
(a) Both (A) and (R) are true and (R) is the correct explanation for (A).


18. Assertion (A): A stack is a LIFO structure.
Reason (R): Any new element pushed into the stack always gets positioned at the index after the last existing element in the stack.

Answer:
(a) Both (A) and (R) are true and (R) is the correct explanation for (A).

SECTION B

19. Atharva is a Python programmer working on a program to find and return the maximum value from the list. The code written below has syntactical errors. Rewrite the correct code and underline the corrections made.

Incorrect Code:

python
def max_num(L):
max = L[0]
for a in L:
if a > max :
max = a
return max

Corrected Code:

python
def max_num(L):
max_value = L[0] # Changed 'max' to 'max_value' to avoid using a reserved keyword
for a in L:
if a > max_value: # Used 'max_value' instead of 'max'
max_value = a
return max_value

20. (a) Differentiate between wired and wireless transmission.

Answer:

Wired Transmission Wireless Transmission
Uses physical cables (e.g., copper, fiber optic) to transmit data. Uses electromagnetic waves (e.g., radio waves, microwaves) for data transmission.
Examples include Ethernet, DSL, and fiber-optic connections. Examples include Wi-Fi, Bluetooth, and cellular networks.
Generally more secure, less interference, and stable. Susceptible to interference, but offers mobility and flexibility.
Can have higher bandwidth and speed. Limited by range and bandwidth.

(b) Differentiate between URL and domain name with the help of an appropriate example.

Answer:

URL Domain Name
URL (Uniform Resource Locator) is the complete web address used to access a specific resource on the internet. A domain name is the human-readable address that points to an IP address of a website.
Example: https://www.example.com/path/to/resource Example: www.example.com
It includes the protocol (HTTP/HTTPS), domain name, and resource path. It is a part of the URL and represents the server’s name where the website is hosted.

21. (a) Given is a Python list declaration:

python
Listofnames = ["Aman", "Ankit", "Ashish", "Rajan", "Rajat"]

Write the output of:

python
print(Listofnames[-1:-4:-1])

Answer:
Output:

python
['Rajat', 'Rajan', 'Ashish']

Explanation:
The slicing starts from index -1 (last element) and moves backward with a step of -1, stopping just before index -4.


(b) Consider the following tuple declaration:

python
tupl = (10, 20, 30, (10, 20, 30), 40)

Write the output of:

python
print(tupl.index(20))

Answer:
Output:

python
1

Explanation:
The value 20 is found at index 1 in the tuple.


22. Explain the concept of “Alternate Key” in a Relational Database Management System with an appropriate example.

Answer:
An alternate key is a candidate key that was not selected as the primary key. It can uniquely identify records in a table but is not the primary key.

Example:
In a Students table, both Student_ID and Email_ID can be candidate keys. If Student_ID is chosen as the primary key, then Email_ID will be the alternate key.


23. (a) Write the full forms of the following:

(i) HTML: HyperText Markup Language
(ii) TCP: Transmission Control Protocol

(b) What is the need of Protocols?

Answer:
Protocols are necessary to define the rules and conventions for communication between devices over a network. They ensure that data is transmitted correctly and efficiently across different systems.


24. (a) Write the output of the code given below:

python
def short_sub(lst, n):
if len(lst) > n:
for i in range(0, n):
lst[i] = lst[i] + lst[i]
else:
for i in range(0, n):
lst[i] = lst[i] + lst[i]
return lst

subjects = ['CS', 'HINDI', 'PHYSICS', 'CHEMISTRY', 'MATHS']
short_sub(subjects, 5)
print(subjects)

Answer:
Output:

python
['CSCS', 'HINDIHINDI', 'PHYSICSPHYSICS', 'CHEMISTRYCHEMISTRY', 'MATHSMATHS']

Explanation:
The function short_sub doubles the strings in the list subjects. Since the length of subjects is greater than n=5, the loop iterates for all elements in the list, concatenating each string with itself.

OR

(b) Write the output of the code given below:

python

a = 30

def call(x):
global a
if a % 2 == 0:
x += a
else:
x = a
return x

x = 20
print(call(35), end="+")
print(call(40), end="=")

Answer:
Output:

python
65+70=

Explanation:

  • The value of a is 30, which is even, so x += a will be executed.
  • call(35) will return 35 + 30 = 65.
  • call(40) will return 40 + 30 = 70 (since a is still 30, which is even).
  • The end="+" and end="=" just control how the print statement’s output appears, so the result is 65+70=.

25. (a) Differentiate between CHAR and VARCHAR data types in SQL with appropriate example.

Answer:

CHAR VARCHAR
Fixed length data type. Variable length data type.
Space is padded if the stored value is shorter than the defined length. Only the actual length of the data is stored.
Example: CHAR(10) will store 10 characters, even if fewer are provided. Example: VARCHAR(10) will store up to 10 characters, but no extra space is used for shorter values.
More efficient for storing data of consistent length. More efficient for storing data of variable length.
Example:
sql
CREATE TABLE example (
code CHAR(5)
);
``` | Example:
```sql
CREATE TABLE example (
name VARCHAR(50)
);
``` |

Let me know if you need further clarification!

OR

(b) Name any two DDL and any two DML commands.

Answer:

DDL (Data Definition Language) Commands:

  1. CREATE – Used to create a new table, view, or other database objects.
  2. ALTER – Used to modify an existing database object, such as a table.

DML (Data Manipulation Language) Commands:

  1. SELECT – Used to query and retrieve data from a database.
  2. INSERT – Used to add new rows of data into a table.

SECTION C

26. (a) Consider the following tables – LOAN and BORROWER:

Table: LOAN

LOAN_NO B_NAME AMOUNT
L-170 DELHI 3000
L-230 KANPUR 4000

Table: BORROWER

CUST_NAME LOAN_NO
JOHN L-171
KRISH L-230
RAVYA L-170

Natural Join: A natural join combines rows from two tables where they have the same column names (in this case, the LOAN_NO column). It eliminates duplicate columns and combines the information from the matching rows.

Steps for Natural Join:

  • The LOAN_NO column is common in both tables, so the rows with matching LOAN_NO values will be joined.
  • L-170 exists in both tables, and L-230 also exists in both tables.
  • L-171 is in the BORROWER table but not in the LOAN table, so it will be excluded from the result.

Result of the Natural Join:

LOAN_NO B_NAME AMOUNT CUST_NAME
L-170 DELHI 3000 RAVYA
L-230 KANPUR 4000 KRISH

Number of Rows and Columns in the Result:

  • Rows: There are 2 rows (for L-170 and L-230).
  • Columns: There are 4 columns: LOAN_NO, B_NAME, AMOUNT, and CUST_NAME.

Final Answer:

  • Rows: 2
  • Columns: 4

(b) Write the output of the queries (i) to (iv) based on the table, WORKER given below:

TABLE: WORKER

WID F_NAME L_NAME CITY STATE
102 SAHIL KHAN KANPUR UTTAR PRADESH
104 SAMEER PARIKH ROOP NAGAR PUNJAB
105 MARY JONES DELHI DELHI
106 MAHIR SHARMA SONIPAT HARYANA
107 ATHARVA BHARDWAJ DELHI DELHI
108 VEDA SHARMA KANPUR UTTAR PRADESH

(i) SELECT F_NAME, CITY FROM WORKER ORDER BY STATE DESC;

Answer:

F_NAME CITY
VEDA KANPUR
SAHIL KANPUR
SAMEER ROOP NAGAR
MAHIR SONIPAT
MARY DELHI
ATHARVA DELHI

(ii) SELECT DISTINCT (CITY) FROM WORKER;

Answer:

CITY
KANPUR
ROOP NAGAR
DELHI
SONIPAT

(iii) SELECT F_NAME, STATE FROM WORKER WHERE L_NAME LIKE '_HA%';

Answer:

F_NAME STATE
MAHIR HARYANA
ATHARVA DELHI

(iv) SELECT CITY, COUNT(*) FROM WORKER GROUP BY CITY;

Answer:

CITY COUNT(*)
KANPUR 2
ROOP NAGAR 1
DELHI 2
SONIPAT 1

27. (a) Write the definition of a Python function named LongLines() which reads the contents of a text file named ‘LINES.TXT’ and displays those lines from the file which have at least 10 words in it.

Answer:

python
def LongLines():
with open('LINES.TXT', 'r') as file:
lines = file.readlines()

for line in lines:
words = line.split()
if len(words) >= 10:
print(line.strip())

Example:

Content of ‘LINES.TXT’:

css
Once upon a time, there was a woodcutter.
He lived in a little house in a beautiful, green wood.
One day, he was merrily chopping some wood.
He saw a little girl skipping through the woods, whistling happily.
The girl was followed by a big gray wolf.

Output:

css
He lived in a little house in a beautiful, green wood.
He saw a little girl skipping through the woods, whistling happily.

27. (b) Write a function count_Dwords() in Python to count the words ending with a digit in a text file “Details.txt”.

Answer:

python

import re

def count_Dwords():
with open('Details.txt', 'r') as file:
content = file.read()

words = content.split()
count = 0

for word in words:
if re.search(r'\d$', word):
count += 1

print(f"Number of words ending with a digit are {count}")

Example:

Content of ‘Details.txt’:

graphql
On seat2 VIP1 will sit and
On seat1 VVIP2 will be sitting

Output:

javascript
Number of words ending with a digit are 4

28. (a) Write the outputs of the SQL queries (i) to (iv) based on the relations COMPUTER and SALES given below:

Table: COMPUTER

PROD_ID PROD_NAME PRICE COMPANY TYPE
P001 MOUSE 200 LOGITECH INPUT
P002 LASER PRINTER 4000 CANON OUTPUT
P003 KEYBOARD 500 LOGITECH INPUT
P004 JOYSTICK 1000 IBALL INPUT
P005 SPEAKER 1200 CREATIVE OUTPUT
P006 DESKJET PRINTER 4300 CANON OUTPUT

Table: SALES

PROD_ID QTY_SOLD QUARTER
P002 4 1
P003 2 2
P001 3 2
P004 2 1

(i) SQL Query:
SELECT MIN(PRICE), MAX(PRICE) FROM COMPUTER;

Output:

MIN(PRICE) MAX(PRICE)
200 4300

(ii) SQL Query:
SELECT COMPANY, COUNT(*) FROM COMPUTER GROUP BY COMPANY HAVING COUNT(COMPANY) > 1;

Output:

COMPANY COUNT(*)
LOGITECH 2
CANON 2

(iii) SQL Query:
SELECT PROD_NAME, QTY_SOLD FROM COMPUTER C, SALES S WHERE C.PROD_ID=S.PROD_ID AND TYPE = 'INPUT';

Output:

PROD_NAME QTY_SOLD
MOUSE 3
KEYBOARD 2
JOYSTICK 2

(iv) SQL Query:
SELECT PROD_NAME, COMPANY, QUARTER FROM COMPUTER C, SALES S WHERE C.PROD_ID=S.PROD_ID;

Output:

PROD_NAME COMPANY QUARTER
LASER PRINTER CANON 1
KEYBOARD LOGITECH 2
MOUSE LOGITECH 2
JOYSTICK IBALL 1

(b) Write the command to view all databases.

Answer:
SHOW DATABASES;

29. Write a function EOReplace() in Python, which accepts a list L of numbers. Thereafter, it increments all even numbers by 1 and decrements all odd numbers by 1.

Function Definition:

python
def EOReplace(L):
for i in range(len(L)):
if L[i] % 2 == 0:
L[i] += 1 # Increment even numbers by 1
else:
L[i] -= 1 # Decrement odd numbers by 1
return L

Example:

Input:
L = [10, 20, 30, 40, 35, 55]

Output:
L = [11, 21, 31, 41, 34, 54]


30. (a) A list contains the following record of customers:

[Customer_name, Room Type]

Write the following user-defined functions to perform given operations on the stack named ‘Hotel’:

(i) Push_Cust() – To Push customers’ names of those customers who are staying in ‘Delux’ Room Type.

(ii) Pop_Cust() – To Pop the names of customers from the stack and display them. Also, display “Underflow” when there are no customers in the stack.

Function Definitions:

python
# Push_Cust function to push customers in 'Delux' room type into the stack
def Push_Cust(Hotel, customers):
for customer in customers:
if customer[1] == 'Delux': # Checking Room Type
Hotel.append(customer[0]) # Push customer name to stack

# Pop_Cust function to pop customers from the stack and display "Underflow" when stack is empty
def Pop_Cust(Hotel):
if len(Hotel) == 0:
print("Underflow") # If stack is empty, print "Underflow"
else:
print(Hotel.pop()) # Pop and display customer name

Example:

Input data:
customers = [[“Siddharth”, “Delux”], [“Rahul”, “Standard”], [“Jerry”, “Delux”]]
Hotel = []

  1. Call Push_Cust(Hotel, customers)
    Stack after push operation: ["Siddharth", "Jerry"]

  2. Call Pop_Cust(Hotel)
    Output:
    Jerry
    Stack after pop operation: ["Siddharth"]

  3. Call Pop_Cust(Hotel)
    Output:
    Siddharth
    Stack after pop operation: []

  4. Call Pop_Cust(Hotel)
    Output:
    Underflow


30. (b) Write a function in Python, Push(Vehicle) where, Vehicle is a dictionary containing details of vehicles – [Car_Name: Maker].

The function should push the name of the car manufactured by TATA (including all possible cases like Tata, TaTa, etc.) to the stack.

Function Definition:

python
def Push(Vehicle, stack):
for car, maker in Vehicle.items():
if 'TATA' in maker.upper(): # Check for 'TATA' in the maker's name (case insensitive)
stack.append(car) # Push the car name to stack

Example:

Input:
Vehicle = {“Santro”: “Hyundai”, “Nexon”: “TATA”, “Safari”: “Tata”}
stack = []

  1. Call Push(Vehicle, stack)
    Stack after push operation: ["Nexon", "Safari"]
SECTION D

31. Quickdev, an IT-based firm, located in Delhi is planning to set up a network for its four branches within a city with its Marketing department in Kanpur. As a network professional, give solutions to the questions (i) to (v), after going through the branches locations and other details which are given below:

Distance between various branches:

Branch A to Branch B 40 m
Branch A to Branch C 80 m
Branch A to Branch D 65 m
Branch B to Branch C 30 m
Branch B to Branch D 35 m
Branch C to Branch D 15 m
Delhi Branch to Kanpur 300 km

Number of computers in each of the branches:

Branch Number of Computers
Branch A 15
Branch B 25
Branch C 40
Branch D 115

(i) Suggest the most suitable place to install the server for the Delhi branch with a suitable reason.

Answer: The most suitable place to install the server for the Delhi branch would be Branch D, as it has the highest number of computers (115).

Reason:

  • The server should ideally be located in the branch that has the most computers to efficiently manage the data traffic and provide faster access to resources.
  • Installing the server in Branch D will minimize network traffic latency and improve performance since it will handle a large number of clients and data requests.
  • Moreover, it is strategically located closer to other branches, which will help optimize data transfer speeds for the other branches.

31. Quickdev, an IT-based firm, located in Delhi is planning to set up a network for its four branches within a city with its Marketing department in Kanpur. Answer the following questions based on the given setup:

(ii) Suggest an ideal layout for connecting all these branches within Delhi.

Answer: The most suitable network layout for connecting all the branches within Delhi would be a star topology.

Reason:

  • In a star topology, each branch would be connected to a central hub or switch, which is the server in Branch D (as suggested earlier).
  • The star topology is simple to install, easy to manage, and troubleshooting is easier because if one branch faces an issue, it doesn’t affect others.
  • This topology is scalable and efficient for handling the communication between the branches.

(iii) Which device will you suggest, that should be placed in each of these branches to efficiently connect all the computers within these branches?

Answer: The ideal device to be used in each branch is a Switch.

Reason:

  • A switch is used to connect multiple computers within a branch, allowing them to communicate with each other effectively.
  • Switches provide more efficient traffic handling compared to hubs as they intelligently direct data only to the specific device it is intended for, reducing congestion and collisions.

(iv) Delhi firm is planning to connect to its Marketing department in Kanpur which is approximately 300 km away. Which type of network out of LAN, WAN or MAN will be formed? Justify your answer.

Answer: The network formed between the Delhi branch and the Marketing department in Kanpur would be a WAN (Wide Area Network).

Reason:

  • A WAN covers large geographical areas, typically connecting multiple locations, including cities and countries.
  • Since the distance between Delhi and Kanpur is 300 km, which is beyond the range of LAN or MAN, a WAN is required for this connection.
  • WANs typically use routers, leased lines, and sometimes public networks to establish communication between remote locations.

(v) Suggest a protocol that shall be needed to provide help for transferring of files between Delhi and Kanpur branch.

Answer: The most suitable protocol for transferring files between the Delhi and Kanpur branch is FTP (File Transfer Protocol).

Reason:

  • FTP is specifically designed to transfer files over a network.
  • It allows easy, secure, and reliable transfer of files between systems.
  • FTP can operate over a WAN like the one connecting Delhi and Kanpur, ensuring that large files can be transferred efficiently.

32. (a) What possible output(s) are expected to be displayed on screen at the time of execution of the following Python program:

python

import random

M=[15,10,20,25,30]

for i in range(1,3):
first=random.randint(2,5)-1
sec=random.randint(3,6)-2
third=random.randint(2,4)
print(M[first],M[sec],M[third], sep="#")

Answer:

The output of the program will be one of the following options, as the program uses random numbers:

  1. (i) 10#25#15 2. 20#25#25
  • The random.randint function will generate random indices for each of first, sec, and third, so the values printed will change each time the program is run.

32. (b) The code given below deletes the record from the table “employee” which contains the following record structure:

python

import mysql.connector

# Establish connection
conn = mysql.connector.connect(
host='localhost',
user='root',
password='root',
database='emp'
)
cursor = conn.cursor()

# SQL command to delete the record
sql = "DELETE FROM employee WHERE E_code = %s"
val = ("E001",) # Sample E_code to delete
cursor.execute(sql, val)
conn.commit()

print(cursor.rowcount, "record(s) deleted")
cursor.close()
conn.close()

Answer:

The Python code connects to the MySQL database emp, executes a DELETE query to remove the record from the employee table where the E_code is "E001", and then commits the transaction to save changes in the database. The program will display the number of records deleted, e.g.,:

scss
1 record(s) deleted

This confirms that one record with E_code = 'E001' has been successfully deleted from the table.

33. (a) Difference between CSV and text files:

CSV (Comma Separated Values) File:

  • A CSV file contains data in tabular form where each record is separated by commas, and each row of data represents a new line.
  • It’s commonly used for storing and exchanging data between applications or databases.

Text File:

  • A text file can store plain data, and the contents are displayed as plain text without any specific structure.
  • It doesn’t follow a specific format like CSV, so it can contain any kind of data (e.g., numbers, strings, or even a combination of both).

Program for (a):

python

import csv

# Function to add details to the courier.csv file
def COURIER_ADD():
cid = input("Enter Courier ID: ")
s_name = input("Enter Sender Name: ")
source = input("Enter Source Address: ")
destination = input("Enter Destination Address: ")

# Writing the data to the CSV file
with open('courier.csv', mode='a', newline='') as file:
writer = csv.writer(file)
writer.writerow([cid, s_name, source, destination])
print("Courier added successfully!")

# Function to search and display records based on the destination
def COURIER_SEARCH():
destination = input("Enter destination to search for: ")
with open('courier.csv', mode='r') as file:
reader = csv.reader(file)
found = False
for row in reader:
if row[3] == destination:
print(row)
found = True
if not found:
print("No courier found for this destination.")

# Call the functions
COURIER_ADD()
COURIER_SEARCH()


33. (b) Why is it important to close a file before exiting?

It is important to close a file before exiting for the following reasons:

  • To Save Changes: Closing the file ensures that any data written to the file is saved and flushed from the memory to the disk.
  • Resource Management: It releases the system resources associated with the file, preventing resource leakage.
  • Data Integrity: It ensures that any data in memory is correctly written to the file, avoiding data corruption.

Program for (b):

python

import csv

# Function to add book details to the Book.csv file
def Add_Book():
book_ID = input("Enter Book ID: ")
B_name = input("Enter Book Name: ")
pub = input("Enter Publisher: ")

# Writing the data to the CSV file
with open('Book.csv', mode='a', newline='') as file:
writer = csv.writer(file)
writer.writerow([book_ID, B_name, pub])
print("Book added successfully!")

# Function to search and count books by a specific publisher
def Search_Book():
pub = input("Enter Publisher Name: ")
count = 0
with open('Book.csv', mode='r') as file:
reader = csv.reader(file)
for row in reader:
if row[2] == pub:
count += 1
print(f"Number of books published by {pub}: {count}")

# Call the functions
Add_Book()
Search_Book()


34. The School Lab Table and Queries:

(i) Identify the columns which can be considered as Candidate keys.

  • Candidate keys: LABNO (since it is unique for each lab and can be used to uniquely identify each record in the table).

(ii) Write the degree and cardinality of the table.

  • Degree of the table: 5 (as there are 5 columns in the table: LABNO, LAB_NAME, INCHARGE, CAPACITY, FLOOR)
  • Cardinality of the table: 5 (as there are 5 rows in the table)

(iii) SQL Queries:

(a) Insert a new row with appropriate data:

sql
INSERT INTO LAB (LABNO, LAB_NAME, INCHARGE, CAPACITY, FLOOR)
VALUES ('L006', 'PHYSICS', 'Dr. Sharma', 30, 'II');

(b) Increase the capacity of all labs by 10 students which are on Floor 1:

sql
UPDATE LAB
SET CAPACITY = CAPACITY + 10
WHERE FLOOR = 'I';

OR (iii) SQL Queries:

(a) Add a constraint PRIMARY KEY to the column LABNO in the table:

sql
ALTER TABLE LAB
ADD CONSTRAINT PRIMARY KEY (LABNO);

(b) Delete the table LAB:

sql
DROP TABLE LAB;