CREATE TABLE Objects (
    id nvarchar(20),
    name nvarchar(30),
    author nvarchar(30),
    last_change_date timestamp,

    UNIQUE (id),
    PRIMARY KEY (id)
);


CREATE TABLE Points (
    id nvarchar(20) REFERENCES Objects,
    x int,
    y int,

    PRIMARY KEY (id),
    CHECK (-10000 <= x AND x <= 10000),
    CHECK (-10000 <= y AND y <= 10000)
);


CREATE TABLE Lines (
    id nvarchar(20) REFERENCES Objects,
    begin_x int,
    begin_y int,
    end_x int,
    end_y int,

    PRIMARY KEY (id),
    CHECK (-10000 <= begin_x AND begin_x <= 10000),
    CHECK (-10000 <= begin_y AND begin_y <= 10000),
    CHECK (-10000 <= end_x AND end_x <= 10000),
    CHECK (-10000 <= end_y AND end_y <= 10000)
);


CREATE TABLE POLYGONS (
    id nvarchar(20) REFERENCES Objects,
    edge_order int,
    begin_x int,
    begin_y int,
    end_x int,
    end_y int,

    PRIMARY KEY (id, edge_order),
    CHECK (-10000 <= begin_x AND begin_x <= 10000),
    CHECK (-10000 <= begin_y AND begin_y <= 10000),
    CHECK (-10000 <= end_x AND end_x <= 10000),
    CHECK (-10000 <= end_y AND end_y <= 10000)
);
