-
Notifications
You must be signed in to change notification settings - Fork 0
/
db.sql
89 lines (77 loc) · 2.48 KB
/
db.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
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
DROP DATABASE hig_eebs;
CREATE DATABASE hig_eebs;
USE hig_eebs;
CREATE TABLE users (
userID int(32) NOT NULL AUTO_INCREMENT,
userName varchar(32) NOT NULL,
firstName varchar(32) NOT NULL,
lastName varchar(32) NOT NULL,
password varchar(255) NOT NULL,
email varchar(64) NOT NULL,
pictureID int(64) NULL,
userLevel tinyint(1) NOT NULL,
activated tinyint(1) NOT NULL,
PRIMARY KEY (userID),
FOREIGN KEY (pictureID) REFERENCES pictures(pictureID)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
CREATE TABLE blogs (
blogID int(32) NOT NULL AUTO_INCREMENT,
userID int(32) NOT NULL,
tittel varchar(32) NOT NULL,
beskrivelse varchar(20000),
PRIMARY KEY (blogID),
FOREIGN KEY (userID) REFERENCES users(userID)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
CREATE TABLE blogUsers (
blogID int(32) NOT NULL,
userID int(32) NOT NULL,
userLevel tinyint(1) NOT NULL,
PRIMARY KEY (blogID, userID),
FOREIGN KEY (blogID) REFERENCES blog(blogID),
FOREIGN KEY (userID) REFERENCES users(userID)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
CREATE TABLE blogPosts (
postID int(32) NOT NULL AUTO_INCREMENT,
blogID int(32) NOT NULL,
userID int(32) NOT NULL,
timestamp int(10) NOT NULL,
postText varchar(20000) NOT NULL,
PRIMARY KEY(postID),
FOREIGN KEY(blogID) REFERENCES blog(blogID),
FOREIGN KEY(userID) REFERENCES bruker(userID)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
CREATE TABLE comments (
commentID int(32) NOT NULL AUTO_INCREMENT,
userID int(32) NOT NULL,
postID int(32) NOT NULL,
timestamp int(10) NOT NULL,
source varchar(256) NULL,
comment varchar(20000),
PRIMARY KEY (commentID),
FOREIGN KEY (userID) REFERENCES users(userID),
FOREIGN KEY (postID) REFERENCES blogPost(postID)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
CREATE TABLE pictures (
pictureID int(32) NOT NULL AUTO_INCREMENT,
userID int(32) NOT NULL,
url varchar(1024) NOT NULL,
timestamp int(10) NOT NULL,
PRIMARY KEY (pictureID),
FOREIGN KEY (userID) REFERENCES users(userID)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
CREATE TABLE postViews (
viewID int(255) NOT NULL AUTO_INCREMENT,
postID int(32) NOT NULL,
timestamp int(10) NOT NULL,
ipAddress varchar(15) NOT NULL,
PRIMARY KEY (viewID),
FOREIGN KEY (postID) REFERENCES blogPost(postID)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
CREATE TABLE blogViews (
viewID int(255) NOT NULL AUTO_INCREMENT,
bloggID int(32) NOT NULL,
timestamp int(10) NOT NULL,
ipAddress varchar(15) NOT NULL,
PRIMARY KEY (viewID),
FOREIGN KEY (bloggID) REFERENCES blog(blogID)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;