lundi 14 septembre 2020

Enumerations vs Database Lookup [closed]

Looking for advice on balance between maintaining static Transaction Types in my php application. I want to have a nice way to track common actions that a user performs, so an enumeration is nice when coding. Later however, having a report to lookup the transaction types would require a lookup table on DB side, hence requiring the DB to know what those transaction type-ids are.

What are the tradeoffs with having Enumerations defined in code vs a DB lookup table or both? Should I just insert strings like (USERADD, USERMOVE, etc) instead and let go of my relational DB instincts? Is it time to move to nosql?

Having a DB lookup table for a transaction type allows everything to live nicely in the DB, but you are unable to reference those keys via code. On the flip-side, defining everything in code makes it hard to translate those keys in the lookup table as the application matures.

There are pros and cons with each, I'm looking for a balance. My current approach is to use both, and periodically ensure that they are in sync.

Thanks in advance for your feedback. This is my first post.

Aucun commentaire:

Enregistrer un commentaire