Q.
(a) What is the difference between Candidate key and Alternate key?
(b) What is the degree and cardinality of a table having 10 rows and 5 columns?
(c) For the given table, do as directed:
Table: STUDENT
ColumnName | DataType | size | Constraint |
---|---|---|---|
ROLLNO | Integer | 4 | Primary Key |
SNAME | Varchar | 25 | Not Null |
GENDER | Char | 1 | Not Null |
DOB | Date | Not Null | |
FEES | Integer | 4 | Not Null |
HOBBY | Varchar | 15 | Null |
(i) Write SQL query to create the table.
(ii) Write SQL query to increase the size of SNAKE to hold 30 characters.
(iii) Write SQL query to remove the column HOBBY.
(iv) Write SQL query to insert a row in the table with any values of your choice that can be accommodated there.
Answer =
(a)
Candidate key: - All attribute combinations inside a relation that can serve as primary key are candidate key as these are candidates for primary key position.
Alternate key:- A Candidate key that is not primary key, is called an alternate key.
(b)
Number of:-
Degree: 5
Cardinality: 10
(c)
(i)
Create table STUDENT (
ROLLNO Integer(4) Primary Key ,
SNAME Varchar(25) Not Null,
GENDER char(1) Not Null,
DOB date Not Null,
FEES int(4) Not Null
HOBBY Varchar(15)
) ;
(ii)
Alter table STUDENT modify column SNAME char(30) ;
(iii)
Alter table STUDENT
Drop HOBBY ;
(iv)
Alter table STUDENT add column Path_wala char(30) ;
Post a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )