rgncycle-db/sql/create-relations-table.sql

27 lines
524 B
MySQL
Raw Normal View History

2023-03-15 14:30:41 +01:00
---
DROP TABLE IF EXISTS relations;
---
CREATE TABLE IF NOT EXISTS relations(
2023-04-25 21:36:30 +02:00
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));
2023-03-15 14:52:42 +01:00
---
DELETE FROM relations;
2023-04-25 21:36:30 +02:00
INSERT INTO relations (relation_from_entity,relation_to_entity)
2023-03-15 14:52:42 +01:00
VALUES
2023-04-25 21:36:30 +02:00
(6,1),
(6,2),
(6,3),
(6,4),
(6,5),
(6,7),
(6,8),
(6,9),
(6,10),
(6,11),
(6,12)
2023-03-15 14:52:42 +01:00
RETURNING *;