I’ve read several posts on SO about creating one-to-one relationship:
how do i create a real one-to-one relationship in sql server
is there ever a time where using a database 11 relationship makes sense?
Database design 1 to 1 relationship
but I would be pleased to have your advice on this basic case: I have a USER and a COMPANY tables. Each USER can have 0 or 1 COMPANY.
Is it better to use two tables with the following relationship:


or did I have just to use only one table with all fields needed:

Thanks for your explanation.
Note: I’m using SQL Server (with Manager Studio to set it up) and plan to use EF.
Update: In order to be more explicit, what I’m trying to achieve is the following:
A user can own or doesn’t own a company. If he owns a company he is the sole person working for it.
Thanks
Since it is possible for a user not to own a company, this is not a true “1 to 1” relationship.
In fact, this is “1 to 0..1”, and you can model it in one of the two ways:
Have everything in one table:
Note how COMPANY_ID is both UNIQUE (preventing multiple users from owning the same company) and NULL-able (allowing for the users that don’t own a company). The separation of USER_ID and COMPANY_ID is what allows company-level foreign keys (i.e. allows child tables to reference company, while preventing them from referencing company-less users).
If there are no company-level FKs, you can omit the COMPANY_ID altogether.
You’ll also need a CHECK to ensure no other company field can be set unless COMPANY_ID is set (or at the very least that the correct subset of company fields is non-NULL).
Have two tables:
We can’t just have PKs of these two tables also be FKs (in both directions) because MS SQL Server does’t support deferred constraints that would be needed to resolve the chicken-and-egg problem when inserting new data, nor it would correctly model the “1 to 0..1” relationship (it would model “1 to 1” and not allow company-less users).
Which one of these two strategies should you choose depends largely on the number of companies compared to users: