Skip to content

Organization Role

Description

Entity to associate individuals with roles in organizations. Each organization role has a unique ID associated with it.

Table Definition
CREATE TABLE "organization_role" (
"organization_role_id" VARCHAR PRIMARY KEY NOT NULL,
"person_id" VARCHAR NOT NULL,
"organization_id" VARCHAR NOT NULL,
"organization_role_type_id" ULID 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("person_id") REFERENCES "party"("party_id"),
FOREIGN KEY("organization_id") REFERENCES "party"("party_id"),
FOREIGN KEY("organization_role_type_id") REFERENCES "organization_role_type"("organization_role_type_id"),
UNIQUE("person_id", "organization_id", "organization_role_type_id")
)

Columns

NameTypeDefaultNullableParentsComment
organization_role_idVARCHARfalse{“isSqlDomainZodDescrMeta”:true,“isVarChar”:true}
person_idVARCHARfalseparty{“isSqlDomainZodDescrMeta”:true,“isVarChar”:true}
organization_idVARCHARfalseparty{“isSqlDomainZodDescrMeta”:true,“isVarChar”:true}
organization_role_type_idULIDfalseorganization_role_type{“isSqlDomainZodDescrMeta”:true,“isUlid”: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
organization_role_idPRIMARY KEYPRIMARY KEY (organization_role_id)
- (Foreign key ID: 0)FOREIGN KEYFOREIGN KEY (organization_role_type_id) REFERENCES organization_role_type (organization_role_type_id) ON UPDATE NO ACTION ON DELETE NO ACTION MATCH NONE
- (Foreign key ID: 1)FOREIGN KEYFOREIGN KEY (organization_id) REFERENCES party (party_id) ON UPDATE NO ACTION ON DELETE NO ACTION MATCH NONE
- (Foreign key ID: 2)FOREIGN KEYFOREIGN KEY (person_id) REFERENCES party (party_id) ON UPDATE NO ACTION ON DELETE NO ACTION MATCH NONE
sqlite_autoindex_organization_role_2UNIQUEUNIQUE (person_id, organization_id, organization_role_type_id)
sqlite_autoindex_organization_role_1PRIMARY KEYPRIMARY KEY (organization_role_id)
-CHECKCHECK(json_valid(elaboration) OR elaboration IS NULL)

Indexes

NameDefinition
idx_organization_role__person_id__organization_id__organization_role_type_idCREATE INDEX “idx_organization_role__person_id__organization_id__organization_role_type_id” ON “organization_role”(“person_id”, “organization_id”, “organization_role_type_id”)
sqlite_autoindex_organization_role_2UNIQUE (person_id, organization_id, organization_role_type_id)
sqlite_autoindex_organization_role_1PRIMARY KEY (organization_role_id)

Relations

er