python - JSON and Database: four booleans values versus one string value. What's better? -
i'm developing python api. api i'm trying create 1 similar bank use. retrieve data database , sent desktop application, using json.
i'm unsure wheter:
option 1
{ "is_current": false, "is_savings": true, "is_credit_card": false, "is_loan": false, }
has advantages/disadvantages compared to:
option 2
{ "account_type": "savings" }
i see option 2 requires less data transfer, may load quicker, current state of application, "super fast" loading times not priority (although may in distant future).
also, what's best way store in database can efficiently query it?
i've tried search site , can't seem find matches problem.
any advice appreciated.
if no 2 of 4 types of account can simultaneously true, better store single string. couple of advantages of storing single string is
- if there new types of accounts, can visualize them relative ease (without changing through hardcoded field validation in front end)
- storing single field in database make table less sparse, , make possible add new types of accounts without adding whole columns schema
disadvantages cannot show account may have both loan , credit_card properties. if context doesn't call that, shouldn't issue.
Comments
Post a Comment