27 lines
524 B
SQL
27 lines
524 B
SQL
---
|
|
DROP TABLE IF EXISTS relations;
|
|
---
|
|
CREATE TABLE IF NOT EXISTS relations(
|
|
relation_id BIGSERIAL PRIMARY KEY,
|
|
relation_from_entity BIGINT NOT NULL,
|
|
relation_to_entity BIGINT NOT NULL,
|
|
FOREIGN KEY(relation_to_entity) REFERENCES entities(entity_id),
|
|
FOREIGN KEY(relation_from_entity) REFERENCES entities(entity_id));
|
|
---
|
|
DELETE FROM relations;
|
|
INSERT INTO relations (relation_from_entity,relation_to_entity)
|
|
VALUES
|
|
(6,1),
|
|
(6,2),
|
|
(6,3),
|
|
(6,4),
|
|
(6,5),
|
|
(6,7),
|
|
(6,8),
|
|
(6,9),
|
|
(6,10),
|
|
(6,11),
|
|
(6,12)
|
|
RETURNING *;
|
|
|