1 |
-- Backup til genopbygning af databasen:
|
2 |
-- MsSQL syntax
|
3 |
|
4 |
-- Create the database and tables
|
5 |
create database h6projekt;
|
6 |
use h6projekt;
|
7 |
|
8 |
create table Person (
|
9 |
PersonID int identity (1,1) primary key,
|
10 |
Initialer varchar(4) NOT NULL,
|
11 |
Navn varchar(50) NOT NULL,
|
12 |
Pass varchar(32),
|
13 |
Admin int
|
14 |
);
|
15 |
|
16 |
create table Udstyr (
|
17 |
Stregkode bigint primary key NOT NULL,
|
18 |
Navn varchar(20) NOT NULL,
|
19 |
Beskrivelse varchar(200),
|
20 |
Placering varchar(20) NOT NULL,
|
21 |
Status int NOT NULL
|
22 |
);
|
23 |
|
24 |
create table Udlån (
|
25 |
Udlånid int identity(1,1) primary key,
|
26 |
Personid int NOT NULL,
|
27 |
Stregkode bigint NOT NULL,
|
28 |
Startdato datetime NOT NULL,
|
29 |
Afleveringsdato datetime,
|
30 |
Antaldage int NOT NULL
|
31 |
);
|
32 |
|
33 |
create table Resevation (
|
34 |
resevationid int identity(1,1) primary key,
|
35 |
Personid int NOT NULL,
|
36 |
Stregkode bigint NOT NULL,
|
37 |
Startdato datetime NOT NULL,
|
38 |
);
|
39 |
|
40 |
create table Status (
|
41 |
Statusid int identity(1,1) primary key,
|
42 |
Beskrivelse varchar(40) NOT NULL
|
43 |
);
|
44 |
|
45 |
-- -----------------------------------------------
|
46 |
-- Basic data
|
47 |
INSERT INTO Person (Initialer,Navn,Pass,Admin)
|
48 |
VALUES ("ADM", 'Systems administrator', 'Admin', 1);
|
49 |
|
50 |
INSERT INTO Status (Statusid, Beskrivelse)
|
51 |
VALUES (1,'Udlånt');
|
52 |
|
53 |
INSERT INTO Status (Statusid, Beskrivelse)
|
54 |
VALUES (2,'Reserveret');
|
55 |
|
56 |
INSERT INTO Status (Statusid, Beskrivelse)
|
57 |
VALUES (3,'Ledig');
|
58 |
|
59 |
-- -----------------------------------------------
|
60 |
-- Testdata
|
61 |
|
62 |
insert into Person (Initialer, Navn)
|
63 |
values ('JFRE', 'Jytte Fredriksen');
|
64 |
|
65 |
insert into Udstyr (Stregkode, Navn, Beskrivelse, Placering)
|
66 |
values (5709068802148, 'Projektor', 'VGA Projektor', 'LM01');
|
67 |
|