Create following two tables including integrity constraints using SQL Command:
Table Name : Employee
Field Name
Data Type
Field Size
Constraints
Employee ID
Number
8
Primary Key
Employee Name
Text
20
Not Null
Street
Text
15
City
Text
3
Del,Bom,Cal
Table Name : Works
Field Name
Data Type
Employee ID
Number
Field Size
8
Company Name
Salary
20
10,2
Text
Number
Constraints
Foreign Key,
Primary Key
Primary Key
>10,000 and < 25,000
select count(employeename) from employee,works where salary > (select AVG(salary) from
works) and employeeid=empid ;
Output:-
Output:-
alter table student ADD CONSTRAINT check_age CHECK ( 20 < AGE AND AGE < 60);
Output:-
Q3. Create following two tables including integrity constraints using SQL Command:
Table Name : Part
Field Name
Data Type
Part id
Text
Name
Text
Field Size
8
20
Constraints
Primary Key
Not Null
Field Size
8
Sub Part id
Count
Cost
20
5
10,2
Constraints
Foreign Key,
Primary Key
Primary Key
>= 0 and < 100
Default 0
Text
Number
Number
List all the name of all the subparts of the part id P-100.
Find the total cost of part P-100 including subparts.
10
Output:-
11
12
13
Q4.Create following two tables including integrity constraints using SQL Command:
Table Name : Student
Field Name
Data Type
Roll No
Number
Name
Text
Address
Text
Field Size
8
20
50
Constraints
Primary Key
Not Null
Field Size
8
Course
Grade
20
1
Constraints
Foreign Key,
Primary Key
Primary Key
A,B,C,D,E
Text
Text
List all the Students enrolled for BBA and have grade A
Find the number of students enrolled in each course.
14
15
16
17
18
19
20
alter table loan add constraint fk2_isbn1 FOREIGN KEY(isbn1) REFERENCES books(isbn);
Output:-
21
alter table employee2 add CHECK(20 < AGE AND AGE < 60);
Output:-
22
Q6. Create following two tables including integrity constraints using SQL Command:
Table Name : Student
Field Name
Data Type
CSTID
Number
CSTNAME
Text
CSTCITY
Text
Field Size
4
25
3
CSTDEP
8,2
Number
Constraints
Primary Key
Not Null
Must beUDP,MNG,BNG,PJM,MAR
23
24