From ef58eef8446f8882aed609d6e353425787d1bede Mon Sep 17 00:00:00 2001 From: sagardesai90 Date: Fri, 7 Sep 2018 12:30:28 -0500 Subject: [PATCH 1/2] created tables --- queries.sql | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 queries.sql diff --git a/queries.sql b/queries.sql new file mode 100644 index 0000000..38794a7 --- /dev/null +++ b/queries.sql @@ -0,0 +1,26 @@ +--org table + +CREATE TABLE organization ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + name VARCHAR (128) NOT NULL UNIQUE, + created TIMESTAMP DEFAULT CURRENT_TIMESTAMP +); + +--channel table +CREATE TABLE channel ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + name VARCHAR (128) NOT NULL UNIQUE, + organization_id INTEGER REFERENCES organization(id), + created TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + updated TIMESTAMP DEFAULT CURRENT_TIMESTAMP +); + +--user table +CREATE TABLE message ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + content text, + user_id INTEGER REFERENCES user(id), + channel_id INTEGER REFERENCES channel(id) + crated TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + updated TIMESTAMP DEFAULT CURRENT_TIMESTAMP +); \ No newline at end of file From 7776d74e983a243d6c27268a42589f175132b5c6 Mon Sep 17 00:00:00 2001 From: sagardesai90 Date: Fri, 7 Sep 2018 12:55:17 -0500 Subject: [PATCH 2/2] created inserts --- queries.sql | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/queries.sql b/queries.sql index 38794a7..d791caa 100644 --- a/queries.sql +++ b/queries.sql @@ -23,4 +23,34 @@ CREATE TABLE message ( channel_id INTEGER REFERENCES channel(id) crated TIMESTAMP DEFAULT CURRENT_TIMESTAMP, updated TIMESTAMP DEFAULT CURRENT_TIMESTAMP -); \ No newline at end of file +); + +--message table +CREATE TABLE message ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + content text, + user_id INTEGER REFERENCES user(id), + channel_id INTEGER REFERENCES channel(id) + created TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + updated TIMESTAMP DEFAULT CURRENT_TIMESTAMP +); + +INSERT INTO organization (name, username) VALUES ("Lambda School"); + +INSERT INTO user (name, username) VALUES ("Alice", "alice_wonderland"); +INSERT INTO user (name, username) VALUES ("Bod", "bob_marley"); +INSERT INTO user (name, username) VALUES ("Chris", "chrisrock"); + +INSERT into channel (name, organization_id) VALUES ("#general", 1); +INSERT into channel (name, organization_id) VALUES ("#random", 2); + +INSERT into message (content, user_id, channel_id) VALUES ("Hello, I'm Alice. What's up?", 1, 1); +INSERT into message (content, user_id, channel_id) VALUES ("Hello, I'm Bob. What's up?", 2, 1); +INSERT into message (content, user_id, channel_id VALUES ("Hello, I'm Chris. What's up?", 3, 1); +INSERT INTO message (content, user_id, channel_id) VALUES ("I'm from Kansas City.", 1, 2); +INSERT INTO message (content, user_id, channel_id) VALUES ("How's it going, I'm Bob", 2, 2); +INSERT INTO message (content, user_id, channel_id) VALUES ("How's it going, I'm Chris", 3, 2); +INSERT INTO message (content, user_id, channel_id) VALUES ("How to get back to Kansas?", 1, 2); +INSERT INTO message (content, user_id, channel_id) VALUES ("I like chilling", 2, 1); +INSERT INTO message (content, user_id, channel_id) VALUES ("How's it going, I'm also Chris", 3, 2); +INSERT INTO message (content, user_id, channel_id) VALUES ("See ya later", 1, 1);