CREATE TABLE "User" ( "id" int, "username" varchar(255), "password" varchar(255), "email" varchar(255), "created_at" datetime, "updated_at" datetime ); CREATE TABLE "Device" ( "id" int, "uuid" int, "user_id" int, "created_at" datetime, "brand" varchar(255), "version" varchar(255), "operating_system" varchar(255), "model" varchar(255), FOREIGN KEY("user_id") REFERENCES "User" ("id") ); CREATE TABLE "Permission" ( "id" int, "from_user_id" int, "to_user_id" int, "device_id" int, "created_at" datetime, FOREIGN KEY("from_user_id") REFERENCES "User" ("id"), FOREIGN KEY("to_user_id") REFERENCES "User" ("id"), FOREIGN KEY("device_id") REFERENCES "Device" ("id") ); CREATE TABLE "Log" ( "id" int, "longitude" varchar(255), "device_id" int, "latitude" varchar(255), "timestamp" datetime, FOREIGN KEY("device_id") REFERENCES "Device" ("id") );