-- P5-2963 create new table for samples

DROP TABLE IF EXISTS samples;

CREATE TABLE samples
(
  id SERIAL PRIMARY KEY,
  artno VARCHAR,
  material_id INTEGER,
  address_id INTEGER
);

GRANT ALL ON TABLE samples TO root;
GRANT ALL ON TABLE samples TO photowall_user;
GRANT ALL ON TABLE samples TO public;

ALTER TABLE samples
    ADD CONSTRAINT material_fkey
    FOREIGN KEY (material_id)
    REFERENCES "product-materials"(materialid) MATCH SIMPLE;

ALTER TABLE samples
    ADD CONSTRAINT address_fkey
    FOREIGN KEY (address_id)
    REFERENCES addresses(id) MATCH SIMPLE;
