Design of a credit system with a validity period

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.