Skip to content

Instantly share code, notes, and snippets.

@bastienapp
Created April 21, 2020 14:04
Show Gist options
  • Save bastienapp/b7b668d9d1663c2ad58354247cddd033 to your computer and use it in GitHub Desktop.
Save bastienapp/b7b668d9d1663c2ad58354247cddd033 to your computer and use it in GitHub Desktop.
#------------------------------------------------------------
# Script MySQL.
#------------------------------------------------------------
#------------------------------------------------------------
# Table: wizard
#------------------------------------------------------------
CREATE TABLE wizard(
id_wizard Int Auto_increment NOT NULL ,
email Varchar (255) NOT NULL ,
password Varchar (255) NOT NULL
,CONSTRAINT wizard_PK PRIMARY KEY (id_wizard)
)ENGINE=InnoDB;
#------------------------------------------------------------
# Table: category
#------------------------------------------------------------
CREATE TABLE category(
id_category Int Auto_increment NOT NULL ,
title Varchar (255) NOT NULL
,CONSTRAINT category_PK PRIMARY KEY (id_category)
)ENGINE=InnoDB;
#------------------------------------------------------------
# Table: potion
#------------------------------------------------------------
CREATE TABLE potion(
id_potion Int Auto_increment NOT NULL ,
name Varchar (255) NOT NULL ,
price Float NOT NULL ,
id_category Int NOT NULL
,CONSTRAINT potion_PK PRIMARY KEY (id_potion)
,CONSTRAINT potion_category_FK FOREIGN KEY (id_category) REFERENCES category(id_category)
)ENGINE=InnoDB;
#------------------------------------------------------------
# Table: cart
#------------------------------------------------------------
CREATE TABLE cart(
id_wizard Int NOT NULL ,
id_potion Int NOT NULL ,
quantity Int NOT NULL
,CONSTRAINT cart_PK PRIMARY KEY (id_wizard,id_potion)
,CONSTRAINT cart_wizard_FK FOREIGN KEY (id_wizard) REFERENCES wizard(id_wizard)
,CONSTRAINT cart_potion0_FK FOREIGN KEY (id_potion) REFERENCES potion(id_potion)
)ENGINE=InnoDB;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment