How would you design your database to achieve this functionality?
Consider a scenario where we want to create a product relation (package)...
Say that we create a ProductTbl
prod_id prod_name prod_fee
1 prepaid-A 19 usd
2 prepaid-B 29 usd
3 prepaid-C 39 usd
4 internet 9 usd
5 mms 1 usd
6 email 3 usd
We want to offer a product package that provides better fees for customer.
E.g. if customer choose prepaid-A + internet + mms they will have a pkg fee by 25 usd (instead of 29 usd).
DESIGN
- A pkg with same combination should only exist once.
- A pkg can have unlimited number of products, if possible. (Normally will be 2-4).
E.g. of a pkg combination
ProdPkgTbl
ppkg_id prod_name prod_fee
1 prepaid-A 25 usd
1 mms 25 usd
1 internet 25 usd
2 internet 10 usd
2 email 10 usd
3 prepaid-C 45 usd
3 internet 45 usd
3 mms 45 usd
3 email 45 usd
This means that combination
- pkgid 1 -> prepaid-a, mms, and internet for a pkg fee of 25 usd
- pkgid 2 -> internet and email together for a fee of 10 usd
- pkgid 3 -> prepaid-c, internet, mms, email all together for 45 usd
So if a customer got prepaid-c + internet only they not get the deal for 45 usd, they will pay normal fee of 39 + 9 = 48 usd.
NOW THIS TABLES are just for demo, I would like to get your input and advice to model it in a right direction.
We will need first to select-query a customer current fee plan (based on used products/services) and after that look into the product pkg and see if pkg deal is valid for them or not.
(How to do such selection? on pkg table?) How to have a good db model for this?
Please advice with urls, hints, anything with value to push me into the right direction.
Great thanks.