-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEventBoardDDL.sql
More file actions
41 lines (34 loc) · 909 Bytes
/
EventBoardDDL.sql
File metadata and controls
41 lines (34 loc) · 909 Bytes
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
DROP DATABASE IF EXISTS EventBoard;
CREATE DATABASE EventBoard;
USE EventBoard;
CREATE TABLE Post (
PostId INT PRIMARY KEY AUTO_INCREMENT,
Title VARCHAR(20) NOT NULL,
Category VARCHAR(15) NOT NULL,
Address VARCHAR(30) NOT NULL,
ZipCode CHAR(5) NOT NULL,
Preview VARCHAR(50) NOT NULL,
EventInfo MEDIUMTEXT,
Date Datetime
);
CREATE TABLE User (
UserId INT PRIMARY KEY AUTO_INCREMENT,
UserName VARCHAR(25) NOT NULL
);
CREATE TABLE Comment (
CommentId INT PRIMARY KEY AUTO_INCREMENT,
CommentText VARCHAR(200) NOT NULL,
Date Datetime
);
ALTER TABLE Post
ADD COLUMN (
UserId INT NOT NULL),
ADD CONSTRAINT fk_PostUserId
FOREIGN KEY (UserId)
REFERENCES User(UserId);
ALTER TABLE Comment
ADD COLUMN (
PostId INT NOT NULL),
ADD CONSTRAINT fk_CommentPostId
FOREIGN KEY (PostId)
REFERENCES Post(PostId);