Skip to content

Device Party Relationship

Description

Entity to define relationships between multiple tenants to multiple devices

Table Definition
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")
)

Columns

NameTypeDefaultNullableParentsComment
device_party_relationship_idVARCHARfalse{“isSqlDomainZodDescrMeta”:true,“isVarChar”:true}
device_idVARCHARfalsedevice{“isSqlDomainZodDescrMeta”:true,“isVarChar”:true}
party_idVARCHARfalseparty{“isSqlDomainZodDescrMeta”:true,“isVarChar”:true}
elaborationTEXTtrue{“isSqlDomainZodDescrMeta”:true,“isJsonText”:true}
created_atTIMESTAMPTZCURRENT_TIMESTAMPtrue
created_byTEXT’UNKNOWN’true
updated_atTIMESTAMPTZtrue
updated_byTEXTtrue
deleted_atTIMESTAMPTZtrue
deleted_byTEXTtrue
activity_logTEXTtrue{“isSqlDomainZodDescrMeta”:true,“isJsonSqlDomain”:true}

Constraints

NameTypeDefinition
device_party_relationship_idPRIMARY KEYPRIMARY KEY (device_party_relationship_id)
- (Foreign key ID: 0)FOREIGN KEYFOREIGN KEY (party_id) REFERENCES party (party_id) ON UPDATE NO ACTION ON DELETE NO ACTION MATCH NONE
- (Foreign key ID: 1)FOREIGN KEYFOREIGN KEY (device_id) REFERENCES device (device_id) ON UPDATE NO ACTION ON DELETE NO ACTION MATCH NONE
sqlite_autoindex_device_party_relationship_2UNIQUEUNIQUE (device_id, party_id)
sqlite_autoindex_device_party_relationship_1PRIMARY KEYPRIMARY KEY (device_party_relationship_id)
-CHECKCHECK(json_valid(elaboration) OR elaboration IS NULL)

Indexes

NameDefinition
idx_device_party_relationship__device_id__party_idCREATE INDEX “idx_device_party_relationship__device_id__party_id” ON “device_party_relationship”(“device_id”, “party_id”)
sqlite_autoindex_device_party_relationship_2UNIQUE (device_id, party_id)
sqlite_autoindex_device_party_relationship_1PRIMARY KEY (device_party_relationship_id)

Relations

er