Django с Postgres - Уникальное ограничение для одного арендатора в многотенантной базе данных
Я читал, читал и читал, читал и читал, но наконец решил составить короткий список своих вопросов относительно многопользовательского Postgres с Django. Я совсем новичок в использовании Django, поэтому, пожалуйста, потерпите меня.
Мы разрабатываем многоарендную бизнес-платформу с более чем 300 таблицами. Для идентификаторов арендаторов мы выбрали UUID4, и вот мои вопросы:
- Is it enough to use UUID4 for tenants' and users' ids only and then reference them as foreign keys in every other table? If not,
- Is there a need to use UUID4 in every table? That means that pk in each table will be UUID and that table will have all foreign keys as UUID4s as well.... The second solution would be the UUID4 for tenants' and users' pks only. Other tables would have bigint pks and only 2 foreign keys as UUID (tenant & user).
- In some tables, we need to have other unique data than just pk (such as names, document numbers, tax data and so on). Is there a way to determine/check the uniqueness of such data in a tenant dataset by db constraint or should that be solved by code?
- The data volume and number of tenants and users are in millions of rows per year, just to mention.
Буду признателен за все ваши мысли, ссылки или любые другие источники для дальнейшего изучения.
Спасибо!