Maybe, I’m getting crazy and finally I’ve forgotten everything I learned but I have a lot of doubt about a database model that I’m designing.
This is my problem:
I have a table with n columns, eight columns of them will have three possible values: YES, NO, UNKNOWN.
I’ve thought that I could use another table with a PK and a description, but I’m not sure if I can create eight foreign keys from one table to the same table.
My question is:
Do I need a second table to store YES, NO and UNKNOWN? Is it possible to have eight foreign keys to the same table?
You’re not crazy.
There is a way of modeling data that ends up with tables that function as hubs, with many other tables referencing these hubs via the FK/PK mechanism. The design is called “star schema”. The tables that act as hubs are called “fact tables”. The tables that reference them are called “dimension tables”. There is another design called “snowflake schema” where dimension tables are themselves referenced by other tables.
You can’t design a schema that is both star and normalized. They are two different disciplines, each with its best area of applicability. Star schemas are good for data warehouses, data marts, and reporting databases. Generating complex analytical queries turns out to be surprisingly easy. Updating a star schema is a royal pain. For that reason a normalized design works better when you are doing OLTP.
Star schema was originally developed as a way of moving so called “multidimensional modeling” into the world of SQL databases. Multidimensional modeling is used in structures like data cubes from Cognos and others.
However, the design goals of star schema are very different from the ones you outline in your question.