If a customer can have 0 or 1 user account, then make the UserAccount Id the same as the Customer Id, enforced with primary key and foreign key constraints like so:
CREATE TABLE Customer
(
CustomerId int not null identity(1,1)
constraint PK_Customer
primary key clustered
,(...)
)
CREATE TABLE UserAccount
(
UserAccountId int not null
constraint PK_UserAccount
primary key clustered
constraint FK_UserAccount__Customer
foreign key references Customer (CustomerId)
,(...)
)
This way:
- you cannot create a user account without first creating a customer
- you cannot have two or more user accounts assigned to the same CustomerId
- if "your" CustomerId is not in UserAccount, then you have no user account