I've shown up at a new job and discovered database which is in dire need of some help. There are many many things wrong with it, including
- No foreign keys...anywhere. They're faked by using
int
s and managing the relationship in code. - Practically every field can be
NULL
, which isn't really true - Naming conventions for tables and columns are practically non-existent
Varchar
s which are storing concatenated strings of relational information
Folks can argue, "It works", which it is. But moving forward, it's a total pain to manage all of this with code and opens us up to bugs IMO. Basically, the DB is being used as a flat file since it's not doing a whole lot of work.
I want to fix this. The issues I see now are:
- We have a lot of data (migration, possibly tricky)
- All of the DB logic is in code (with migration comes big code changes)
I'm also tempted to do something "radical" like moving to a schema-free DB.
What are some good strategies when faced with an existing DB built upon a poorly designed schema?