Created
April 4, 2017 00:36
-
-
Save thiamsantos/578dd9b8bff96e2b6d94e8717f6fb5dd to your computer and use it in GitHub Desktop.
TODOS sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE users ( | |
id BIGINT(8) AUTO_INCREMENT PRIMARY KEY, | |
username VARCHAR(16) NOT NULL, | |
email VARCHAR(255) NOT NULL, | |
password VARCHAR(32) NOT NULL | |
); | |
CREATE TABLE todos ( | |
id BIGINT(8) AUTO_INCREMENT PRIMARY KEY, | |
completed TINYINT(1) NOT NULL DEFAULT 0, | |
text VARCHAR(255) NOT NULL, | |
user_id BIGINT(8), | |
FOREIGN KEY (user_id) REFERENCES user(id) | |
); | |
INSERT INTO users (username, email, password) | |
VALUES ('batman', '[email protected]', '1234'); | |
INSERT INTO todos (text, user_id) | |
VALUES ('HEY There', 1); | |
SELECT * FROM todo JOIN user on todo.user_id = user.id; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment