Click here to Skip to main content
15,884,472 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
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?
Posted

1 solution

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
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900