We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2
Class: 12 Marks: 20
SQL Time : 1 Hr.
--------------------------------------------------------------------------------------- Answer all the questions. 1. Write a SQL command to create a table by the following descriptions 3M Table name: sports
create table sports(id int primary key, sname varchar(30) unique,
scheduledate date not null, noofparticipants int); 2. A Computer Store “ABC” is considering to maintain their inventory using SQL to store the data. As a database administer, Simran has decided that : • Name of the database - Inventory • Name of the table - Mydata • The attributes of STORE are as follows: Productcode , Brandname, ProductName, Quantity,Price a) Write the appropriate attribute for primary key. 1M Primary Key: Productcode b) Write the data type of product code that store data like A001, B002 1M char() or varchar() c) To change the Price as 100 for the product code C007. 1M update mydata set price =100 where productcode=’C007’; d) If there are totally 7 records stored in the table then what will be the degree and cardinality of the table. 1M Degree-4, Cardinality=7 e) Write the command to open the database. 1M use inventory; 3. Ms. Shalini has just created a table named “Employee” containing columns 2M Ename, Department and Salary. After creating the table, she realized that she has forgotten to add a primary key column in the table. Help her in writing an SQL command to add a primary key column EmpId of integer type to the table Employee. Thereafter, write the command to insert the following record in the table: EmpId- 999 Ename- Shweta Department: Production Salary: 26900
ALTER TABLE Employee ADD EmpId INTEGER PRIMARY KEY;
INSERT INTO Employee(EmpId,Ename,Department,Salary) VALUES(999,"Shweta","Production",26900); 4. Zack is working in a database named SPORT, in which he has created a table named “Sports” containing columns SportId, SportName, no_of_players, and category. After creating the table, he realized that the attribute, category has to be deleted from the table and a new attribute TypeSport of data type string has to be added. This attribute TypeSport cannot be left blank. Help Zack write the commands to complete both the tasks 2M
ALTER TABLE Sports DROP category;
ALTER TABLE Sports ADD TypeSport char(10) NOT NULL; 5. Navdeep creates a table RESULT with a set of records to maintain the marks secured by students in Sem1, Sem2, Sem3, and their divisions. After the creation of the table, he entered data of 7 students in the table. 3M
Based on the data given above answer the following questions:
i. Identify the columns which can be considered as candidate keys? Candidate Keys : ADMNO, ROLLNO ii. If 2 more columns are added and 3 rows are deleted from the table result, what will be the new degree and cardinality of the above table? Degree-8, Cardinality=4 iii. Write a statement to increase the SEM2 marks by 3% for the students securing marks between 70 to 100. Update result set SEM2=SEM2+.03*SEM2 where SEM2 between 70 and 100; 6. Write a SQL statement to add a primary key for the columns location_id in the locations table. 1M alter table locations add primary key(location_id); 7. Advaitha has created a table ‘Tour’. She has forget the structure of the table. Help her with the SQL command to view the structure of the table. 1M desc tour; 8. Expand DDL and DML. 1M DDL Data Definition language DML Data manipulation Language 9. Write a SQL statement to delete the column location_id in the locations table. 1M alter table locations drop location_id; 10. d) A is false but R is True