0

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.

4

1 回答 1

0

如果我们要遵循体育范式...

每个游戏都需要有一个唯一的 ID。然后你有一个客户表,每个客户都有一个唯一的 ID。然后你有一个表格,描述了谁为什么支付了费用。包含两列 ID、customerID 和 gameID 的表。这就是所谓的标准化。

因此,在您的联接表中,您可能有 CUSTOMER ID 001,他们为游戏 001、003 和 005 付费。这是客户表:

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

这是游戏桌:

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

这是对应于谁为什么支付的表格:

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

注意最后一个表中的 ID 不是唯一的。

于 2012-12-04T23:03:00.647 回答