Data vs business logic
Today my manager said: ‘Amir, don’t mix the business logic with data in database’. I surprisingly shocked! I said ‘Where?’.
According to wikipedia business logic is:
In computer software, business logic or domain logic is the part of the program that encodes the real-world business rules that determine how data can be created, stored, and changed.
He said category and subcategory are business logic in our definition and requirements and you shouldn’t create one-to-many relationship in database for them. Of course, you must encode them in logic and create some objects or xml for them.
We discussed around 2 or 3 hours about my database model. I believed my model has good optimization (encode some business rules in database), on other hand, he believed it is too rigid and data migration is too hard and:
Early optimization is the root of all evil.
I can wrap my day in one paragraph:
There is a thin border between data and business logic. If I can describe something in code(with algorithms, xml file, some objects, dictionary and so on) most of the time it is not data. Save only raw data.
I hope that my conclusion be correct.