Skip to content

party_relation

Description

Entity to define relationships between parties. Each party relation has a unique ID associated with it.

Table Definition
CREATE TABLE "party_relation" (
"party_relation_id" VARCHAR PRIMARY KEY NOT NULL,
"party_id" VARCHAR NOT NULL,
"related_party_id" VARCHAR NOT NULL,
"relation_type_id" TEXT 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("party_id") REFERENCES "party"("party_id"),
FOREIGN KEY("related_party_id") REFERENCES "party"("party_id"),
FOREIGN KEY("relation_type_id") REFERENCES "party_relation_type"("code"),
UNIQUE("party_id", "related_party_id", "relation_type_id")
)

Columns

NameTypeDefaultNullableParentsComment
party_relation_idVARCHARfalse{“isSqlDomainZodDescrMeta”:true,“isVarChar”:true}
party_idVARCHARfalseparty{“isSqlDomainZodDescrMeta”:true,“isVarChar”:true}
related_party_idVARCHARfalseparty{“isSqlDomainZodDescrMeta”:true,“isVarChar”:true}
relation_type_idTEXTfalseparty_relation_type
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
party_relation_idPRIMARY KEYPRIMARY KEY (party_relation_id)
- (Foreign key ID: 0)FOREIGN KEYFOREIGN KEY (relation_type_id) REFERENCES party_relation_type (code) ON UPDATE NO ACTION ON DELETE NO ACTION MATCH NONE
- (Foreign key ID: 1)FOREIGN KEYFOREIGN KEY (related_party_id) REFERENCES party (party_id) ON UPDATE NO ACTION ON DELETE NO ACTION MATCH NONE
- (Foreign key ID: 2)FOREIGN KEYFOREIGN KEY (party_id) REFERENCES party (party_id) ON UPDATE NO ACTION ON DELETE NO ACTION MATCH NONE
sqlite_autoindex_party_relation_2UNIQUEUNIQUE (party_id, related_party_id, relation_type_id)
sqlite_autoindex_party_relation_1PRIMARY KEYPRIMARY KEY (party_relation_id)
-CHECKCHECK(json_valid(elaboration) OR elaboration IS NULL)

Indexes

NameDefinition
idx_party_relation__party_id__related_party_id__relation_type_idCREATE INDEX “idx_party_relation__party_id__related_party_id__relation_type_id” ON “party_relation”(“party_id”, “related_party_id”, “relation_type_id”)
sqlite_autoindex_party_relation_2UNIQUE (party_id, related_party_id, relation_type_id)
sqlite_autoindex_party_relation_1PRIMARY KEY (party_relation_id)

Relations

er