Storing Entity states in DB
-
I was looking for an efficient way to store "States" of entities in the DB. For example I had OrderStatus and that can be mapped to a table called Status and have the ID and the status Name be present in a join. If however I wanted to add more statuses for other Entity tables I don't want to have to create a new table for every Entity, is there a way to store all these statuses in one table? Thanks
-
I was looking for an efficient way to store "States" of entities in the DB. For example I had OrderStatus and that can be mapped to a table called Status and have the ID and the status Name be present in a join. If however I wanted to add more statuses for other Entity tables I don't want to have to create a new table for every Entity, is there a way to store all these statuses in one table? Thanks
You're describing the "one true lookup table" anti-pattern. It's a bad idea. Best practices for using Simple Lookup Tables[^] Look-up Tables in SQL - Simple Talk[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
You're describing the "one true lookup table" anti-pattern. It's a bad idea. Best practices for using Simple Lookup Tables[^] Look-up Tables in SQL - Simple Talk[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
Richard Deeming wrote:
It's a bad idea.
I :laugh: :laugh: :laugh: , the last project I was asked to advise on was managed by a PM who was adamant that this was the "modern" way to go (I was accused of being an old fart who was stuck in the 90's). Started off as a 2 column table and the last I saw of it was a 5 column, 2 table structure. Luckily I walked away from anything to do with the project.
Never underestimate the power of human stupidity - RAH I'm old. I know stuff - JSOP
-
You're describing the "one true lookup table" anti-pattern. It's a bad idea. Best practices for using Simple Lookup Tables[^] Look-up Tables in SQL - Simple Talk[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer