|
Hi Nefi,
I am not an expert on architecture issues, but I
think the clue lies in your focussing on users, where you should focus on
accounts. Or, in other words, when you define a user, you should not worry about
accounts. Define users something like this:
CREATE TABLE USERS (USER_ID BIGINT NOT NULL
(generated as identy or whatever),
USER_NAME
VARCHAR(255),
PRIMARY KEY
(USER_ID)
)
No reference whatsoever to accounts.
Now define your accounts keeping in mind the one to
one relationship user vs account, something like this:
CREATE TABLE ACCOUNTS (ACCOUNT_ID BIGINT NOT NULL
(generated as identy or whatever),
USER_ID BIGINT NOT NULL UNIQUE,
PRIMARY KEY (ACCOUNT_ID),
FOREIGN KEY (USER_ID) REFERENCES USERS
)
When searching for a user's account, you search the
accounts table with the userid.
When searching for a user you search the users
table.
I did not test or verify the above statements, so
there may be typo's or other stupid mistakes.
But is this what you are looking for?
Kind regards, Piet Blok
----- Original Message -----
|
- Re: nullable FK constraint Piet Blok
- Re: nullable FK constraint Nefi Percola
- Re: nullable FK constraint Craig L Russell
- Re: nullable FK constraint Nefi Percola
