device_party_relationship

Column Type PK Required Default
device_party_relationship_id VARCHAR Yes Yes
device_id VARCHAR No Yes
party_id VARCHAR No Yes
elaboration TEXT No No
created_at TIMESTAMPTZ No No CURRENT_TIMESTAMP
created_by TEXT No No 'UNKNOWN'
updated_at TIMESTAMPTZ No No
updated_by TEXT No No
deleted_at TIMESTAMPTZ No No
deleted_by TEXT No No
activity_log TEXT No No

Foreign Keys

Column Name Foreign Key
party_id party_id references party.party_id
device_id device_id references device.device_id

Indexes

Column Name Index Name
device_id idx_device_party_relationship__device_id__party_id
party_id idx_device_party_relationship__device_id__party_id
device_id sqlite_autoindex_device_party_relationship_2
party_id sqlite_autoindex_device_party_relationship_2
device_party_relationship_id sqlite_autoindex_device_party_relationship_1

SQL DDL

CREATE TABLE "device_party_relationship" (
    "device_party_relationship_id" VARCHAR PRIMARY KEY NOT NULL,
    "device_id" VARCHAR NOT NULL,
    "party_id" VARCHAR NOT NULL,
    "elaboration" TEXT CHECK(json_valid(elaboration) OR elaboration IS NULL),
    "created_at" TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP,
    "created_by" TEXT DEFAULT 'UNKNOWN',
    "updated_at" TIMESTAMPTZ,
    "updated_by" TEXT,
    "deleted_at" TIMESTAMPTZ,
    "deleted_by" TEXT,
    "activity_log" TEXT,
    FOREIGN KEY("device_id") REFERENCES "device"("device_id"),
    FOREIGN KEY("party_id") REFERENCES "party"("party_id"),
    UNIQUE("device_id", "party_id")
)