Is it ok if i dont use a foreign key, when i could use it, i just dont use it?
For example, my COUNTRY_STATE table should have Country.Id as the foreign key, but i didn’t do that instead have CountryCode. I get the states for each country by CountryCode.
COUNTRY
-Id (PK)
-Code
-Name
COUNTRY_STATE
-Id (PK)
-Code
-Name
-CountryCode
A foreign key does not necessarily need to reference a primary key. It can also reference a unique constraint.
So if you want to keep the country_code in the country_state table, you can do that and still have a foreign key that ensure that only valid country codes are used: