The design of a credit system with a validity period includes several tables,
User: uid username ....
Score (point table): value (points), expire (validity period )...
Order ):
Goods)
Address (shipping address table)
...
The current requirement is that there is a demand for credit card points systems like China Merchants Bank. you need to design these tables. if you need other tables, you can add them on your own.
Points can be consumed. During consumption, the system preferentially consumes expired points. you can view the points and consumed points.
Give me some ideas
Reply to discussion (solution)
Id userid? Id) money (? Points) extime (? Period ??)
1 7 10 05:11:13
2 7 20 05:11:14
3 5 20 2013-08-15 05:11:15
4 7 10 05:11:16
Suppose ?? (Id = 7) want to cancel? ? Wait, then ??? Table? Get ??, Sort? Is it based on extime? Arranged.
If? One consumption? Deduct 20 ?, So? Root? Extime sorting first deducts the id = 1? I? (If there is not enough button, you can directly delete it.) after the button is complete? 10? To deduct, then deduct id = 2? I? (Exceeded, so update required? Money value)
Id userid? Id) money (? Points) extime (? Period ??)
1 7 10 05:11:13
2 7 20 05:11:14
3 5 20 2013-08-15 05:11:15
4 7 10 05:11:16
Suppose ?? (Id = 7) want to cancel? ? Wait, then ??? Table? Get ??, Sort? Is it based on extime? Arranged.
If? One consumption? Deduct 20 ?, So? Root? Extime sorting first deducts the id = 1? I? (If there is not enough button, you can directly delete it.) after the button is complete? 10? To deduct, then deduct id = 2? I? (Exceeded, so update required? Money value)
"Too much, so we need to update it? Money value"
If the value is updated, the user's previous point records cannot be obtained.
Add a field usedmoney (used points) on the basis of #1)
Update is performed on usedmoney instead of money.
I feel that this design is a bit problematic. it is a little complicated to deduct points,
Is there any other table structure design ??? Thank you.