· 6 years ago · Mar 21, 2019, 12:20 PM
1CREATE DATABASE IF NOT EXISTS odoo;
2USE odoo;
3CREATE TABLE products (
4 id INTEGER auto_increment primary key,
5 name VARCHAR(50),
6 price decimal(19,2),
7 creationDate DATE NOT NULL
8)
9
10CREATE TABLE categories (
11 id INTEGER AUTO_INCREMENT PRIMARY KEY,
12 name VARCHAR(50),
13 public tinyint NOT NULL DEFAULT 1,
14)
15
16CREATE TABLE categories_has_products (
17 categoriesId INTEGER NOT NULL,
18 productsId INTEGER NOT NULL,
19 CONSTRAINT FK_categories_products_pro FOREIGN KEY FK_categories_products_pro (productsId)
20 REFERENCES products(id)
21 ON DELETE RESTRICT
22 ON UPDATE RESTRICT,
23 CONSTRAINT FK_categories_products_cat FOREIGN KEY FK_categories_products_cat (categoriesId)
24 REFERENCES categories(id)
25 ON DELETE RESTRICT
26 ON UPDATE RESTRICT
27)