xtopher's avatar

transaction vs purchase table names

I am re-designing a database for a Laravel project but I got stuck with naming conventions and table normalization.

Currently, I have a transactions table with the following columns transaction_id ref_id, credit, debit, wallet_balance, status, product_type, product_description

my question now is: should I have a separate table for purchases where the product and its attributes should be and a transaction table just for the movement of funds in the user wallet?

0 likes
3 replies
martinbean's avatar

@xtopher Well it completely depends on what you’re trying to model. Why do you have “product” columns in your transactions table in the first place? What if someone purchases more than one product?

I think you need to think your models through a bit more. If this is some sort of e-commerce site then you’d have an orders table, that has many order_line_items records: one for each product that makes up the order. “Transactions” usually refers to the movement of funds, i.e. a customer paying for an order, a customer being refunded either in part or in full, etc.

xtopher's avatar

@martinbean thanks for responding. The project is not an e-commerce but a utility bill payment platform.

martinbean's avatar

@xtopher Either way, you still need to look at your business logic and then deduce the entities that are involved. They’ll then influence your table (and Eloquent model) names and their attributes and relations.

Please or to participate in this conversation.