Feat(SQL): Locations redesigned for parent location id stored on location table and links table removed.

This commit is contained in:
2025-07-15 15:21:04 +01:00
parent a3fd8b12fe
commit e0805ec2ed
10 changed files with 13 additions and 124 deletions

View File

@@ -0,0 +1,31 @@
USE parts;
SELECT CONCAT('WARNING: Table ', TABLE_SCHEMA, '.', TABLE_NAME, ' already exists.') AS msg_warning
FROM INFORMATION_SCHEMA.TABLES
WHERE
TABLE_SCHEMA = 'parts'
AND TABLE_NAME = 'DOG_Location_Link'
;
CREATE TABLE IF NOT EXISTS parts.DOG_Location_Link (
id_link INT NOT NULL AUTO_INCREMENT PRIMARY KEY
, id_location_parent INT
, CONSTRAINT FK_DOG_Location_Link_id_location_parent
FOREIGN KEY (id_location_parent)
REFERENCES parts.DOG_Location(id_location)
, id_location_child INT
, CONSTRAINT FK_DOG_Location_Link_id_location_child
FOREIGN KEY (id_location_child)
REFERENCES parts.DOG_Location(id_location)
, active BIT NOT NULL DEFAULT 1
, created_on DATETIME
, id_user_created_by INT
, CONSTRAINT FK_DOG_Location_Link_id_user_created_by
FOREIGN KEY (id_user_created_by)
REFERENCES parts.DOG_User(id_user)
, id_change_set INT
, CONSTRAINT FK_DOG_Location_Link_id_change_set
FOREIGN KEY (id_change_set)
REFERENCES parts.DOG_Dog_Change_Set(id_change_set)
);