-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata.sql
More file actions
87 lines (72 loc) · 2.46 KB
/
data.sql
File metadata and controls
87 lines (72 loc) · 2.46 KB
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
DROP TABLE caseoppgave.Studieprogram_Student;
DROP TABLE caseoppgave.Studieprogram;
DROP TABLE caseoppgave.Semester;
DROP TABLE caseoppgave.Student;
DROP TABLE caseoppgave.Person;
CREATE TABLE caseoppgave.Person
(
fodselsnr VARCHAR(11) NOT NULL,
fornavn VARCHAR(40),
etternavn VARCHAR(50),
PRIMARY KEY (fodselsnr)
);
CREATE TABLE caseoppgave.Student
(
studentnr int UNSIGNED AUTO_INCREMENT,
fodselsnr VARCHAR(11) NOT NULL,
PRIMARY KEY (studentnr),
CONSTRAINT P_studentFnr FOREIGN KEY (fodselsnr) REFERENCES Person (fodselsnr)
);
CREATE TABLE caseoppgave.Semester
(
semesterkode VARCHAR(2) NOT NULL,
semester_navn VARCHAR(7),
PRIMARY KEY (semesterkode)
);
CREATE TABLE caseoppgave.Studieprogram
(
studieprogramkode VARCHAR(10) NOT NULL,
studieprogram_navn VARCHAR(100),
fakultetkode VARCHAR(5),
instnr int,
PRIMARY KEY (studieprogramkode)
);
CREATE TABLE caseoppgave.Studieprogram_Student
(
studentnr int UNSIGNED NOT NULL,
studieprogramkode VARCHAR(10) NOT NULL,
uteksaminering_aar int,
uteksaminering_semesterkode VARCHAR(2),
PRIMARY KEY (studentnr, studieprogramkode),
CONSTRAINT P_StudprogstudStudnr FOREIGN KEY (studentnr)
REFERENCES Student (studentnr),
CONSTRAINT P_StudprogstudStudieprogKode FOREIGN KEY (studieprogramkode)
REFERENCES Studieprogram (studieprogramkode),
CONSTRAINT P_StudprogstudSemsterkode FOREIGN KEY (uteksaminering_semesterkode)
REFERENCES Semester (semesterkode)
);
INSERT INTO caseoppgave.Person
VALUES ('17912099997', 'Karl', 'Marx'),
('29822099635', 'Princess', 'Diana'),
('05840399895', 'Donald', 'Duck'),
('12829499914', 'Mikke', 'Mus'),
('12905299938', 'Alle', 'André');
INSERT INTO caseoppgave.Student (fodselsnr)
VALUES ('17912099997'),
('29822099635'),
('05840399895'),
('12829499914'),
('12905299938');
INSERT INTO caseoppgave.Semester
VALUES ('VI', 'Vinter'),
('VA', 'Vår'),
('SO', 'Sommer'),
('HO', 'Høst');
INSERT INTO caseoppgave.Studieprogram
VALUES ('GAM-PC', 'Gaming på PC - Master', 'IFI', 1),
('MAT-10', 'Mat og helse - Bachelor', 'SAM', 1),
('POD-RAD', 'Podcast og Radio - Årsstudium', 'RAD', 2),
('GAM-PS', 'Gaming på Play Station', 'NAT', 3),
('GAM-XB', 'Gaming på XBOX', 'NAT', 3);
INSERT INTO caseoppgave.Studieprogram_Student
VALUES (4, 'POD-RAD', 2025, 'VA');