-
Notifications
You must be signed in to change notification settings - Fork 0
/
Database Assign1.txt
103 lines (89 loc) · 1.93 KB
/
Database Assign1.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/* 1 question */
create table department
(
departmentno int not null primary key,
departmentname varchar(20) unique,
floor int,
location varchar(20)
);
desc department
create table employee
(
Employeenumber int not null primary key,
managerid int,
firstname char(20) not null,
lastname varchar(30),
userid int,
departmentno int,
salary number(10,2),
commission int,
joiningdate date,
constraint p_i foreign key(departmentno) references department (departmentno)
on delete cascade
);
desc employee
alter table employee add HRA number(5,2);
alter table employee add PF number(5,2) check (PF<=5000);
/* 2 question */
create table customer
(
custno int not null primary key,
custname varchar(20),
address varchar(30)
);
desc customer
create table order1
(
orderno int not null primary key,
custno int,
orderdate date,
constraint f foreign key(custno) references customer(custno)
);
desc order1
create table orderitem
(
itemid int not null primary key,
orderno int,
itemname varchar(20),
quantity number(2),
constraint d foreign key (orderno) references order1(orderno)
);
desc orderitem
alter table customer modify address varchar(100);
/*3 question */
create table course
(
constraint courseid_depid_c primary key (courseid,depid),
courseid varchar(5) not null,
depid varchar(5),
streamid varchar(20),
description varchar(200),
title varchar(40),
fees int
);
desc course
create table batch
(
batchid varchar(30),
courseid varchar(5),
batchname char(1)
);
desc batch
create table student
(
studid varchar(20),
lastname varchar(25),
middlename varchar(30),
firstname varchar(20),
dob date default sysdate,
address varchar(50),
city varchar(20),
state varchar(2),
zipcode varchar(9),
telephone varchar(10),
fax varchar(10),
email varchar(30),
grade char(1),
check (grade in ('A','A+','A-','B','B+','B-','C','C+','C-','D','D+','D-','F','F+','F-'))
);
desc student