Question

I want to build a PHP based site where, the user can view data based on the types of data they've paid for.

Allow me to use something simple for an example.

Let's say historical data for basketball was not readily available but could be purchased. Simple information such as the Winner, Loser, Final score and date are all stored in a mySQL table.

What would be involved so that, when the user logs in, they can only see the historical data they have paid for.

My theories so far about the architecture:

I imagined a mySQL table storing True or False values for all historical game data they have paid for. Based on this, a 'data chart' object enables the user to view all data within their mySQL row which has a value of 'true.'

Follow ups:

Assuming I am correct, what methods are popular or practical for this type of service.

Was it helpful?

Solution

If we're going with the sporting paradigm...

Every game needs to have a unique ID. Then you have a table of customers, each also with a unique ID. Then you have a table that describes who paid for what. A table with two columns of ID's, customerID and gameID. This is what is called normalization.

So, in your joining table you might have CUSTOMER ID 001, who have paid for games 001, 003, and 005. Here is the customer table:

.------------------------------.
| customer_id | customer_name  |
|------------------------------|
| 001         | SPM, Inc.      |
| 002         | Stack Overflow |
'------------------------------'

Here is the game table:

.---------------------------------.
| game_id     | description       |
|---------------------------------|
| 001         | Giants v. Red Sox |      |
| 002         | Blah v. Yada      |
| 003         | Vader v. Kenobi   |
| 004         | Romney v. Obama   |
| 005         | Roth v. Hagar     |
'---------------------------------'

Here is the table that corresponds to who paid for what:

.-----------------------------.
| customer_id | game_id       |
|-----------------------------|
| 001         | 001           |
| 001         | 003           |
| 001         | 005           |
| 002         | 002           |
| 002         | 005           |
'-----------------------------'

Notice how the ID's in the last table are not unique.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top