-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path(4) Constraints.sql
58 lines (44 loc) · 1.07 KB
/
(4) Constraints.sql
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
create database Course;
use Course;
create table Subjects
(Subject_id int primary key,
Subject_name varchar(25) not null);
describe Subjects;
insert into
Subjects(Subject_id, Subject_name)
values
(1, 'Python'),
(2, 'SQL'),
(3, 'NPV'),
(4, 'EDA'),
(5, 'Statistics');
select*from Subjects;
create table Students
(Student_id int primary key,
Student_name varchar(25) not null,
Subject_id int,
foreign key(Subject_id) references Subjects(Subject_id)
);
select*from Students;
describe Students;
insert into Students values (01,'Akshen',1);
insert into Students values (02,'Maher',2);
insert into Students values (03,'Nalini',2);
insert into Students values (04,'Rakesh',1);
insert into Students values (05,'Moksha',3);
select*from Students;
select*from Subjects;
create table department
(dept_id int primary key,
dept_name varchar(25) unique,
roll_call int unique);
insert into department values
(1, 'HR', 10),
(2, 'Accountant', 11),
(3, 'IT', 12);
select*from department;
insert into department values
(4, 'IT');
select*from department;
insert into department values
(5, 'SEO', 12);