Krotn
Krotn

Reputation: 23

Database Design - Monthly server billing tracker

I am trying to design a simple SQLite database to bill players on a server. The server is paid for on a monthly basis at a cost of $10 (but this might change). I would like to have the following tables (or something better):

Months:
-id (int primary key)
-ref (text) something like "JAN11 just for readability"
-cost (real) something like 10 or 9.5 the monthly cost of the server

Players:
-id (int primary key)
-name (text)

The cost should be divided among the players who logged on at the end of the month (ie. 5 people log in in January they get the $10 split among them).

In short: I don't know how to store whether or not the players logged in during the month so as to divide the cost among them.

Upvotes: 1

Views: 318

Answers (1)

mechanical_meat
mechanical_meat

Reputation: 169304

Another good table to have would be Logins, e.g.:

Logins:
    id int,
    player_id int,
    month_id int

That way you could just check if a player logged in, or even also check how many times they logged in (assuming you wanted to track that).

Upvotes: 2

Related Questions