The USER is HUMAN, and HUMAN has a COMPANY - user → person individually, person → company many-to-one.
person_id is the FK in the USER table. company_id is the FK in the PERSON table.
A MAN may not be a USER, but the USER is always HUMAN.
If company_id was in the user table, I could create a unique key based on the username and company_id, but this is not so, and it will be data duplication if it were.
I am currently using a unique username / company ID rule in the RoseDB manager shell code, but it doesn’t feel right. I would like to define a unique rule at the database level if I can, but I'm not sure how it fits into it. I tried something like this:
alter table user add unique(used_id,person.company_id);
but it does not work.
After reading the documentation, I can not find an example that does something even remotely similar. Am I trying to add functionality that does not exist, or am I missing something here?
source
share