28 lines
995 B
SQL
28 lines
995 B
SQL
CREATE TABLE collections
|
|
(
|
|
id serial NOT NULL,
|
|
name character varying(255) NOT NULL,
|
|
inserted timestamp with time zone NOT NULL DEFAULT now(),
|
|
updated timestamp with time zone,
|
|
designer_id integer NOT NULL,
|
|
path character varying(255) NOT NULL,
|
|
CONSTRAINT collections_pkey PRIMARY KEY (id),
|
|
CONSTRAINT collections_designer_id_fkey FOREIGN KEY (designer_id)
|
|
REFERENCES designers (designerid) MATCH SIMPLE
|
|
ON UPDATE CASCADE ON DELETE CASCADE
|
|
);
|
|
|
|
CREATE TABLE collections_products
|
|
(
|
|
id serial NOT NULL,
|
|
collection_id integer NOT NULL,
|
|
product_id integer,
|
|
CONSTRAINT collections_products_pkey PRIMARY KEY (id),
|
|
CONSTRAINT collections_products_collection_id_fkey FOREIGN KEY (collection_id)
|
|
REFERENCES collections (id) MATCH SIMPLE
|
|
ON UPDATE CASCADE ON DELETE CASCADE,
|
|
CONSTRAINT collections_products_product_id_fkey FOREIGN KEY (product_id)
|
|
REFERENCES "product-products" (productid) MATCH SIMPLE
|
|
ON UPDATE CASCADE ON DELETE CASCADE
|
|
);
|