33. Fun Media Services Ltd is an event planning organization. It is planning to set up its India campus in Mumbai with its head office in Delhi. The Mumbai campus will have four blocks/buildings - ADMIN, DECORATORS, FOOD, and MEDIA.
You as a network expert need to suggest the best network-related solutions for them to resolve the issues/problems mentioned in points (i) to (v), keeping in mind the distances between various blocks/buildings and other given parameters.
Shortest distance between various buildings:
| FROM – TO |
DISTANCE |
| ADMIN TO DECORATORS |
90 meters |
| ADMIN TO MEDIA |
75 meters |
| ADMIN TO FOOD |
50 meters |
| DECORATORS TO FOOD |
65 meters |
| DECORATORS TO MEDIA |
50 meters |
| FOOD TO MEDIA |
45 meters |
| DELHI Head Office to MUMBAI Campus |
1475 KM |
The number of computers at various buildings is as follows:
| BUILDING |
NUMBER OF COMPUTERS |
| ADMIN |
110 |
| DECORATORS |
75 |
| MEDIA |
12 |
| FOOD |
20 |
(i) Suggest the most appropriate location of the server inside the MUMBAI campus (out of the 4 buildings). Justify your answer.
Ans: The most appropriate location of the server inside the MUMBAI campus is ADMIN building due to the maximum number of computers in it.
(ii) Draw the cable layout to efficiently connect various buildings within the MUMBAI campus.
Ans: Cable Layout
(iii) Which hardware device will you suggest to connect all the computers within each building?
Ans: Switch or Hub
(iv) Which of the following will you suggest to establish online face-to-face communication between the people in the Admin Office of the MUMBAI campus and the DELHI Head Office?
a) Cable TV
b) Email
c) Video Conferencing
d) Text Chat
(v) What type of network (out of PAN, LAN, MAN, WAN) will be set up in each of the following cases?
(a) The Mumbai campus gets connected with the Head Quarter in Delhi
Ans: WAN
(b) The computers connected in the MUMBAI campus
Ans: LAN
34. (i) Mention any two differences between seek() and tell().
Ans:
|
seek() |
tell() |
| Purpose |
Repositions the file pointer to a specific location within a file |
Returns the current position of the file pointer |
| Syntax |
seek(offset [,reference point]) |
tell() |
| Parameters |
Requires specifying the offset and an optional reference point |
Requires no parameters |
(ii) Consider a file FLIGHT.DAT containing multiple records. The structure of each record is as shown below:
[Fno, FName, Fare, Source, Destination]
Write a function COPY_REC() in Python that copies all those records from FLIGHT.DAT where the source is DELHI and the destination is MUMBAI, into a new file RECORD.DAT
Ans:
import pickle
def COPY_REC():
In_file = open('FLIGHT.DAT', 'rb')
out_file = open('RECORD.DAT', 'wb')
try:
while True:
data = pickle.load(In_file)
if data[3] == 'DELHI' and data[4] == 'MUMBAI':
pickle.dump(data, out_file)
except:
In_file.close()
out_file.close()
COPY_REC()
OR
(i) Mention any two differences between binary files and csv files?
Ans:
| Binary |
CSV |
| 1. pickle module to be used |
1. csv module is used |
| 2. Data is stored in binary format(0s and 1s) and is not in human readable form using any plain text editor. |
2. Data is stored in tabular fashion and comma separated by default. The file can be read by any spreadsheet software or text editor. |
| 3. File extension .dat/.pdf/.exe etc. |
3. File extension .csv |
(ii) Consider a Binary file BOOK.DAT containing a dictionary having multiple elements. Each element is in the form BNO:[BNAME,BTYPE,PRICE] as key:value pair
where
BNO - Book Number
BNAME - Book Name
BTYPE - Book Type
PRICE - Book price
Write a user-defined function, findBook(price), that accepts price as parameter and displays all those records from the binary file BOOK.DAT which has a book price more than or equal to the price value passed as a parameter.
Ans:
import pickle
def findBook(price):
with open('BOOK.DAT', 'rb') as file:
while True:
try:
book_record = pickle.load(file)
for item in book_record:
book_price = book_record[item][2]
if book_price >= price:
print(item, book_record[item])
except EOFError:
break
findBook(50)
35. (i) Define the term constraint with respect to RDBMS. Give a suitable example.
Ans: A constraint in RDBMS is a rule applied on a table column to ensure the accuracy, validity, and integrity of data stored in the database.
Constraints restrict the type of data that can be inserted, updated, or deleted in a table.
Common Types of Constraints:
NOT NULL - Ensures that a column cannot store NULL values
UNIQUE - Ensures all values in a column are different
PRIMARY KEY - Uniquely identifies each record (combination of NOT NULL + UNIQUE)
FOREIGN KEY - Maintains relationship between two tables
CHECK - Ensures that values satisfy a specific condition
DEFAULT - Assigns a default value if no value is provided
Example:
CREATE TABLE Student (
RollNo INT PRIMARY KEY,
Name VARCHAR(50) NOT NULL,
Age INT CHECK (Age >= 18),
City VARCHAR(20) DEFAULT 'Ajmer'
);
(ii) Sameera maintains a database named STORE which contains a table named ITEM with the structure given below:
• Ino (Item number) - integer
• Iname (Item Name) - string
• Price (Item Price) - float
• Discount (Discount) - float
Note the following to establish connectivity between Python and MySQL:
• Username - root
• Password - tiger
• Host - localhost
Help her to remove the record from the table ITEM for a particular value of item name input by the user.
import mysql.connector as mysql
con1 = mysql.connect(host='localhost', user='root', password='__', database='STORE') # Statement-1
mycursor = ________ # Statement-2
item_name = input("Enter the Item name to remove the record : ")
query = ______________ # Statement-3
mycursor.execute(query)
con1.____ # Statement-4
print('Data Deleted successfully')
con1.close()
With reference to the above code, answer the following questions
(a) Complete statement 1 to establish the connection with the database.
Ans: password='tiger'
(b) Write statement 2 to create the cursor object.
Ans: mycursor = con1.cursor()
(c) Complete statement 3 to remove the record from the table ITEM based on the item name entered by the user
Ans: query = 'delete from ITEM where Iname = "{}" '.format.(item_name)
(d) Complete statement 4 to save the changes in the table.
Ans: con1.commit()
OR
i. Write one difference between the alternate key and the candidate key.
Ans: A candidate key is a column or a group of columns that can uniquely identify each record in a table. There can be more than one candidate key in a table.
An alternate key is a candidate key that is not chosen as the primary key.
ii. A table named ITEM is created in a database STORE. The table contains multiple columns whose details are as shown below:
Ino (Item number) - integer
Iname (Item Name) - string
Price (Item Price) - float
Discount (Discount) - float
Note the following to establish connectivity between Python and MySQL:
Username - root
Password - tiger
Host - localhost
However, the table is to be interfaced with Python to perform certain tasks. The incomplete code is given below:
______ # Line 1
con1 = mysql.connect(host='localhost', user='root', password='tiger', database='STORE')
mycursor = con1.______ # Line 2
query = 'SELECT * FROM ITEM where Price > {}'.format(______) # Line 3
mycursor.execute(query)
data = mycursor.______ # Line 4
for rec in data:
print(rec)
con1.close()
(a) Complete line 1 to import the appropriate module.
Ans: import mysql.connector as mysql
(b) Complete Line 2 to create the cursor object.
Ans: mycursor = con1.cursor()
(c) Complete the query given in Line 3 to display details of all such items from the table ITEMS whose price is more than 5000.
Ans: query = 'SELECT * FROM ITEM where Price > {}'.format(5000)
(d) Complete Line 4 to extract all the records.
Ans: data = mycursor.fetchall()