SQL - Lab - Exercise (16 - To - 20) (1) (AutoRecovered)
SQL - Lab - Exercise (16 - To - 20) (1) (AutoRecovered)
1. Use a pencil to draw the table on the left-hand side of your record note.
3. Take a printout of the SQL queries and output should be attached in record
To execute SQL Queries in MySql for the given scenario and display the result
Scenario:
Suppose your school management has decided to conduct cricket matches between students of Class
XI and Class XII. Students of each class are asked to join any one of the four teams – Team Titan,
Team Rockers, Team Magnet and Team Hurricane. During summer vacations, various matches will
be conducted between these teams. Help your sports teacher to do the following:
a. It should have a column TeamID for storing an integer value between 1 to 9, which refers
to unique identification of a team.
b. Each TeamID should have its associated name (TeamName), which should be a string
of length not more than 10 characters.
c. Using constraint, make TeamID as the primary key.
d. Show the structure of the table TEAM using a SQL statement.
e. As per the preferences of the students four teams were formed as given below. Insert
these four rows in TEAM table:
i. Row 1: (1, Titan)
ii. Row 2: (2, Rockers)
iii. Row 3: (3, Magnet)
iv. Row 4: (4, Hurricane)
f. Show the contents of the table TEAM using a DML statement.
g. Now create another table MATCH_DETAILS and insert data as shown below. Choose
appropriate data types and constraints for each attribute.
Second Team
MatchID MatchDate First TeamID Second TeamID First Team Score
Score
M1 2018-07-17 1 2 90 86
M2 2018-07-18 3 4 45 48
M3 2018-07-19 1 3 78 56
M4 2018-07-19 2 4 56 67
M5 2018-07-18 1 4 32 87
M6 2018-07-17 2 3 67 51
SQL Queries and Output:
1.Database Creation:
Query:
Output:
Query:
Output:
(a),(b)&(c)
Query:
Output:
e. Inserting into table
Query:
Output:
f. To show records
Query:
Output:
Query:
Output:
Result:
The SQL commands for the given scenario is written, executed and the output verified
To execute SQL Queries in MySql for the given scenario and display the result
Scenario:
Consider the following MOVIE table and write the SQL queries based on it.
Output:
2.Query:
Output:
3.Query:
Output:
4. Query:
Output:
5.Query:
Output:
6.Query:
Output:
Result:
The SQL commands for the given scenario is written, executed and the output verified
Scenario:
In a company database, there are two tables given below :
Table:JOB
1. To display employee ids, names of employees, job ids with corresponding job titles.
2. To display names of employees, sales and corresponding job titles who have achieved sales more than
1300000.
3. To display names and corresponding job titles of those employees who have 'SINGH' (anywhere) in
their names.
4. Show employee name ,job title and salary of those employees who are working in any one of the
mentioned job( President,Vice President, Accountant)
5. Write SQL command to change the JOBID to 104 of the EMPLOYEE with ID as E4 in the table
'EMPLOYEE'.
OUTPUT:
2. QUERY:
OUTPUT:
3. QUERY:
OUTPUT:
4.QUERY:
OUTPUT:
5. QUERY:
OUTPUT:
Result:
The SQL commands for the given scenario is written, executed and the output verified
Scenario:
Consider the following ‘stock’ table to answer the queries:
OUTPUT:
2.QUERY:
OUTPUT:
3.QUERY:
OUTPUT:
4.QUERY:
OUTPUT:
5.QUERY:
OUTPUT:
Result:
The SQL commands for the given scenario is written, executed and the output verified
Scenario:
2.QUERY:
OUTPUT:
3.QUERY:
OUTPUT:
4.QUERY:
OUTPUT:
5.QUERY:
OUTPUT:
6.QUERY:
OUTPUT:
7.QUERY:
OUTPUT:
8.QUERY:
OUTPUT:
9.QUERY:
OUTPUT:
10.QUERY:
OUTPUT:
Result:
The SQL commands for the given scenario is written, executed and the output verified