We've been developing user based payment system. It's pretty much metering how much users use some contents per hour. And we send the bill at the end of every month.

I'd love to know how user based payment system table can be implemented. Any documentation or resources?


This is meant for database deign not algorithm. But in my mind there are two ways to achieve it. Also if you have an experience to implement something like this, please give me some advice.

First, event status model ( standing for "on/off" status )

whenever you create contents, 1 will be inserted, on the other hand -1 will be inserted if you destroy that. And we can only calculate from 1 to -1 part.

It's just good because we can skip start point if you already started.

Ex. create create create destroy 1 1 1 -1 <=================>

So there are many events inserted in one table (start/stop)

Secondly, contents model

It would be more simple. contents has columns "created_at" and "destroyed_at". Just whenever you create/destroy some content, the time will be inserted for each column.

Which is more efficient or any other ways?

Personally the second is little cleaner, but i'd also love to hear some opinions.

1 Answer 1


User based payment system table designing

Hi, i think this model can fit you needs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.