Last active
October 3, 2017 13:35
-
-
Save bastienapp/f8abf4c00424d50b5e6bfeeebdff4611 to your computer and use it in GitHub Desktop.
Modelisation
This file contains hidden or 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
#------------------------------------------------------------ | |
# Script MySQL. | |
#------------------------------------------------------------ | |
#------------------------------------------------------------ | |
# Table: user | |
#------------------------------------------------------------ | |
CREATE TABLE user( | |
user_id int (11) Auto_increment NOT NULL , | |
name Varchar (255) NOT NULL , | |
email Varchar (255) NOT NULL , | |
PRIMARY KEY (user_id ) | |
)ENGINE=InnoDB; | |
#------------------------------------------------------------ | |
# Table: organization | |
#------------------------------------------------------------ | |
CREATE TABLE organization( | |
organization_id int (11) Auto_increment NOT NULL , | |
name Varchar (255) NOT NULL , | |
website_url Varchar (255) NOT NULL , | |
PRIMARY KEY (organization_id ) | |
)ENGINE=InnoDB; | |
#------------------------------------------------------------ | |
# Table: tweet | |
#------------------------------------------------------------ | |
CREATE TABLE tweet( | |
tweet_id int (11) Auto_increment NOT NULL , | |
content Text , | |
user_id Int NOT NULL , | |
PRIMARY KEY (tweet_id ) | |
)ENGINE=InnoDB; | |
#------------------------------------------------------------ | |
# Table: belong | |
#------------------------------------------------------------ | |
CREATE TABLE belong( | |
user_id Int NOT NULL , | |
organization_id Int NOT NULL , | |
PRIMARY KEY (user_id ,organization_id ) | |
)ENGINE=InnoDB; | |
ALTER TABLE tweet ADD CONSTRAINT FK_tweet_user_id FOREIGN KEY (user_id) REFERENCES user(user_id); | |
ALTER TABLE belong ADD CONSTRAINT FK_belong_user_id FOREIGN KEY (user_id) REFERENCES user(user_id); | |
ALTER TABLE belong ADD CONSTRAINT FK_belong_organization_id FOREIGN KEY (organization_id) REFERENCES organization(organization_id); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment