Advertisements
Advertisements
Using the sports database containing two relations (TEAM, MATCH_DETAILS) and write the Query for the following:
Display the MatchID of matches played by Team 2 and not won by it.
Concept: undefined >> undefined
What are the risks associated with HTTP? How can we resolve these risks by using HTTPS?
Concept: undefined >> undefined
Advertisements
Which of the following mode in the file opening statement results or generates an error if the file does not exist?
Concept: undefined >> undefined
The SELECT statement when combined with the ______ clause returns records without repetition.
Concept: undefined >> undefined
Write two points of difference between Circuit Switching and Packet Switching.
Concept: undefined >> undefined
Explain the use of ‘Foreign Key’ in a Relational Database Management System. Give example to support your answer.
Concept: undefined >> undefined
Consider the following tables – Bank_Account and Branch:
Table: Bank_Account
| ACode | Name | Type |
| A01 | Amrita | Savings |
| A02 | Parthodas | Current |
| A03 | Miraben | Current |
Table: Branch
| ACode | City |
| A01 | Delhi |
| A02 | Mumbai |
| A01 | Nagpur |
What will be the output of the following statement?
SELECT * FROM Bank_Account NATURAL JOIN Branch;
Concept: undefined >> undefined
Write a method COUNTLINES() in Python to read lines from the text file ‘TESTFILE.TXT’ and display the lines which do not start with any vowel.
Example:
If the file content is as follows:
An apple a day keeps the doctor away.
We all pray for everyone’s safety.
A marked difference will come in our country.
The COUNTLINES() function should display the output as:
The number of lines not starting with any vowel - 1
Concept: undefined >> undefined
Write a function ETCount() in Python, which should read each character of a text file “TESTFILE.TXT” and then count and display the count of occurrence of alphabets E and T individually (including small cases e and t too).
Example:
If the file content is as follows:
Today is a pleasant day.
It might rain today.
It is mentioned on weather sites
The ETCount() function should display the output as:
E or e : 6
T or t : 9
Concept: undefined >> undefined
______ clause is used with a SELECT statement to display data in a sorted form with respect to a specified column.
Concept: undefined >> undefined
Explain the concept of “Alternate Key” in a Relational Database Management System with an appropriate example.
Concept: undefined >> undefined
Write the output of the queries (i) to (iv) based on the table, WORKER given below:
TABLE: WORKER
| W_ID | 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 |
SELECT F_NAME, CITY FROM WORKER ORDER BY STATE DESC;SELECT DISTINCT (CITY) FROM WORKER;SELECT F_NAME, STATE FROM WORKER WHERE L_NAME LIKE '_HA%';SELECT CITY, COUNT(*) FROM WORKER GROUP BY CITY;
Concept: undefined >> undefined
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. For example, if the content of 'LINES.TXT' is as follows:
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.
Then the function should display output as:
He lived in a little house in a beautiful, green wood.
He saw a little girl skipping through the woods, whistling happily.
Concept: undefined >> undefined
Write a function count_Dwords() in Python to count the words ending with a digit in a text file "Details.txt".
Example:
If the file content is as follows:
On seat2 V1P1 will sit and
On seat1 VVIP2 will be sitting
The output will be:
The number of words ending with a digit is 4
Concept: undefined >> undefined
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 | DESKET PRINTER | 4300 | CANON | OUTPUT |
| Table: SALES | ||
| PROD_ID | QTY_SOLD | QUARTER |
| P002 | 4 | 1 |
| P003 | 2 | 2 |
| P001 | 3 | 2 |
| P004 | 2 | 1 |
SELECT MIN(PRICE), MAX(PRICE) FROM COMPUTER;SELECT COMPANY, COUNT(*) FROM COMPUTER GROUP BY COMPANY HAVING COUNT(COMPANY) > 1;SELECT PROD_NAME, QTY_SOLD FROM COMPUTER C, SALES S WHERE C.PROD_ID=S.PROD_ID AND TYPE = 'INPUT';SELECT PROD_NAME, COMPANY, QUARTER FROM COMPUTER C, SALES S WHERE C.PROD_ID=S.PROD_ID;
Concept: undefined >> undefined
The code given below reads the following records from the table employee and displays only those records that have employees coming from the city 'Delhi':
E_code - StringE_name - StringSal - IntegerCity - String
Note the following to establish connectivity between Python and MySQL:
- Username is
root - Password is
root - The table exists in a MySQL database named
emp. - The details
(E_code,E_name,Sal,City)are the attributes of the table.
Write the following statements to complete the code:
Statement 1 - to import the desired library.
Statement 2 - to execute the query that fetches records of the employees/coming from the city ‘Delhi’.
Statement 3 - to read the complete data of the query (rows whose city is Delhi) into the object named details, from the table employee in the database.
import ____________ as mysql #Statement 1
def display():
mydb=mysql.connect(host="localhost",user="root"
passwd="root", database=" emp")
mycursor=mydb.cursor()
____________ #Statement 2
details = ____________ # Statement 3
for i in details:
print (i)Concept: undefined >> undefined
The school has asked their estate manager Mr Rahul to maintain the data of all the labs in a table LAB. Rahul has created a table and entered data from 5 labs.
| LAB NO | LAB_NAME | INCNCHARGE | CAPACITY | FLOOR |
| L001 | CHEMISTRY | Daisy | 20 | I |
| L002 | BIOLOGY | Venky | 20 | II |
| L003 | MATH | Preeti | 15 | I |
| L004 | LANGUAGE | Daisy | 36 | III |
| L005 | COMPUTER | Mary | 37 | II |
Based on the data given above answer the following questions:
(i) Identify the columns which can be considered as Candidate keys.
(ii) Write the degree and cardinality of the table.
(iii) Write the statements to:
(a) Insert a new row with appropriate data.
(b) Increase the capacity of all the labs by 10 students which are on
the 'I' Floor.
OR
(iii) Write the statements to:
(a) Add a constraints PRIMARY KEY to the column LABNO in the table.
(b) Delete the table LAB.
Concept: undefined >> undefined
Which of the following statements is FALSE about keys in a relational database?
Concept: undefined >> undefined
In case of ______ switching, before a communication starts, a dedicated path is identified between the sender and the receiver.
Concept: undefined >> undefined
Write a function, lenWords(STRING), that takes a string as an argument and returns a tuple containing length of each word of a string.
For example, if the string is "Come let us have some fun", the tuple will have (4, 3, 2, 4, 4, 3)
Concept: undefined >> undefined
