Skip to content
This repository has been archived by the owner on Sep 27, 2022. It is now read-only.

adding classwork #25

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions class2016/c4_5/B_06_Vasil_Kolev/creates.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
CREATE TABLE users(
userid INT AUTO_INCREMENT PRIMARY KEY NOT NULL,
name VARCHAR(20) NOT NULL,
email VARCHAR(50) NOT NULL,
age INT
);

CREATE TABLE groups(
groupid INT AUTO_INCREMENT PRIMARY KEY NOT NULL,
name VARCHAR(50) NOT NULL,
dateFounded TIMESTAMP NOT NULL
);

CREATE TABLE events(
eventid INT AUTO_INCREMENT PRIMARY KEY NOT NULL,
name VARCHAR(50) NOT NULL,
dateEvent TIMESTAMP NOT NULL,
location VARCHAR(50) NOT NULL
);

CREATE TABLE userGroup(
id INT AUTO_INCREMENT PRIMARY KEY NOT NULL,
refUser INT NOT NULL,
refGroup INT NOT NULL,
FOREIGN KEY (refUser) REFERENCES users(userid),
FOREIGN KEY (refGroup) REFERENCES groups(groupid)
);

CREATE TABLE groupEvents(
id INT AUTO_INCREMENT PRIMARY KEY NOT NULL,
refGroup INT NOT NULL,
refEvent INT NOT NULL,
FOREIGN KEY (refGroup) REFERENCES groups(groupid),
FOREIGN KEY (refEvent) REFERENCES events(eventid)
);
7 changes: 7 additions & 0 deletions class2016/c4_5/B_06_Vasil_Kolev/inserts.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
INSERT INTO users ( name, email, age ) VALUES ('Gosho', '[email protected]', 2);
INSERT INTO groups (name) VALUES ('bigRedBadasses');
INSERT INTO events (name, location) VALUES ('Gosho\'s Birthday', 'Sessame street no 33');
INSERT INTO events (name, location) VALUES ('Gosho\'s Freeday', 'Sessame street no 11');

INSERT INTO groupEvents (refGroup, refEvent) VALUES (0,0);
INSERT INTO userGroup (refUser, refGroup) VALUES (0,0);