我有两个桌子
第一个表:
Table "public.things"
Column | Type | Collation | Nullable | Default
----------------------+-----------------------------+-------------
id | bigint | | not null |
name | character varying(255) | | not null |
slug | character varying(255) | | |
lang_id | integer | | |
Indexes:
"things_pkey" PRIMARY KEY, btree (id)
"things_slug_unique" UNIQUE CONSTRAINT, btree (slug)
第二个用于存储区域和事物的多对多表:
Table "public.values"
Column | Type | Collation | Nullable | Default | Storage
------------+--------+-----------+----------+---------+-----
thing_id | bigint | | not null | | plain |
region_id | bigint | | not null | | plain |
values | jsonb | | not null | | extended|
Indexes:
"values_pkey" PRIMARY KEY, btree (thing_id, region_id)
我有第三个表,该表应该存储表值
中的用户变体形态表 user_variants 如下:
Table "public.user_variants"
Column | Type | Collation | Nullable | Default |
-------------+--------+-----------+----------+---------+
user_id | int | | not null | |
entity_id | bigint | | not null | |
entity_type | bigint | | not null | |
content | jsonb | | not null | |
例如,我可以在 user_variants 表中存储如下内容:
user_id | entity_id | entity_type | content |
---------+-------------+----------------+----------------------+
41 | 23 | combination_1 | '{ values: [ ...] }' |
42 | 24 | combination_2 | '{ values: [ ...] }' |
我遇到了问题,我的表值没有用于存储在 entity_id 字段中的唯一 id ,但是表值具有主键“ values_pkey” 由 thing_id,region_id 组成。
如何在不将