用户包和信用系统的数据库设计 [英] Database design for user packages and credit system

查看:67
本文介绍了用户包和信用系统的数据库设计的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发用户可以购买软件包的Web应用程序。在这些包的基础上,用户可以执行不同的操作。目前我正在使用以下结构。



表格 - 套餐

< td> 8000
PackageId(PK) 名称 Amount PackageTypeId
1 启动 3000 1
2 高级 5000 1
3 专业 2




表 - PackageType



PackageTypeId(PK) 姓名
1 交易
2 业务




表 - UserPackages



UserPackageId(PK) UserId PackageId(FK) ExpireDate isActive
1(PK) 300 1(FK) 2013-2-10




表格 - 用户发票​​



InvoiceId(PK) UserId UserPackageId(FK) 金额 TransactionId
1 300 1 3000 200000333




我的问题是。



此数据库设计是否正确

现在我希望用户可以升级他的包裹



(启动 - > Premium或专业)

(高级 - >专业)



应该保存这些包优先级吗?



我的想法。我必须创建具有以下结构的新表(PackagePriority)



PriorityId(PK) - PackageId(FK) - PriorPackage (这也将是具有不同名称的PackageId)



1(PK) - 1(FK) - 2(FK)



2(PK) - 1(FK) - 3(FK)



3(PK) - 2(FK) - 3(FK)< br $> b $ b

这是个正确的主意吗?



怎么能ind用户当前包可升级到其他包吗?

I am working on web application in which user can purchase packages. On the base of these packages user can do different operations. Currently I am using following structure.

Table - Packages

PackageId (PK) NameAmountPackageTypeId
1Startup30001
2Premium50001
3Professional80002


Table - PackageType

PackageTypeId (PK) Name
1Deal
2Business


Table - UserPackages

UserPackageId (PK) UserIdPackageId (FK)ExpireDateisActive
1 (PK) 3001 (FK)2013-2-10yes


Table - UserInvoices

InvoiceId (PK)UserIdUserPackageId (FK)AmountTransactionId
130013000200000333


My Questions Are.

Is this database design is correct
Now i want user can upgrade his package

(Startup --> Premium or Professional)
(Premium --> Professional)

Where these package priority should be saved?

My thought. I have to create new table ( PackagePriority ) with following structure

PriorityId (PK) - PackageId (FK) - PriorPackage (this will also PackageId with different name)

1 (PK) - 1 (FK) - 2 (FK)

2 (PK) - 1 (FK) - 3 (FK)

3 (PK) - 2 (FK) - 3 (FK)

is this right idea?

How can i find user current package is upgradeable to other packages?

推荐答案

你的数据库设计是可行的,从来没有一个'正确'的答案,但这将有效。要知道某些软件包是否可以升级而其他软件包无法升级,您可以将其存储在软件包类型的新列中
Your DB design is workable, there's never one 'right' answer, but this will work. To know if some packages can be upgraded and others cannot, you store that as a bit in a new column on the package types


这篇关于用户包和信用系统的数据库设计的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆