I am hoping someone can help my muddle over a database schema i am trying to implement. It is based around selling mobile contracts and network bolt on from Network providers. The contracts are fore filled by a number of distributors who may or may not sell a networks contract the prices also differ per distributor.
Distributors
Name Address
Distributor 1 address1
Distributor2 address2
Networks
Name
Orange
O2
Vodafone
Tariffs
Network Tariff Minutes
Orange Business 600 600 Mins
Orange Business 100 100 Mins
O2 Everyday 100 200 Mins
O2 Everyday 100 100 Mins
Devices
Name Make
Apple Iphone
Samsung Galaxy
Bolt Ons
Network Description
Orange Web 500mb
Orange Unlimited Texts
O2 Web 250Mb
O2 Unlimited Texts
Order - Exactly 1 Distributor - Exactly 1 Network - Exactly 1 Tariff - 0 or more Devices - 0 or more Bolt Ons Distributor - 0 or more Orders - 1 or more Networks - 1 or more Tariffs o Unique Tariff Costs - 1 or more BoltOns o Unique Bolt on Cost - 1 or more Devices o Unique Device cost Network - 0 Orders - 0 or more Distributors - 1 or more Tariffs - 0 or more BoltOns - 0 or more Devices Tariffs - 0 or more Orders - 0 or more Distributors - Exactly 1 Network - 0 or more BoltOns - 0 Devices BoltOns - 0 or more Orders - 0 or more Distributors - Exactly 1 Network - 0 or more Tariffs - 0 or more Devices Devices - 0 or more Orders - 0 or more Distributors - 0 or more Networks - 0 Tariffs - 1 or more BoltOns
I have come up with 2 schemas but i am really not happy with it. Mainly due to the fact that a distributor may not offer all offerings from the network. And also the prices of tariffs, devices and bolt ons also varies per distributor. I was hoping for some suggestions to the schema approach?
Many Thanks
Rob
EDIT——–
following the comments i have had i have coem up with the following shema. I have added teh following assumptions
Devices and Boltons are similar enough to be in a product table:
The types of query we will need to be running is invoice generation based on what a user may have paid 6-12 months ago – prices for distributors may change monthly.
Number of phones sold per distributor per network etc…
- Tariffs are the same across distributors however the price and commission changes per distributor.
Any comments on the below schema?
[Distributors]
[Dist_ID] PK
[Name],
[Address]
[Network]
[Network_ID] PK,
[Name],
[Tarrif]
[TariffID] PK
[Name],
[Minutes] ,
[OtherMinutes] ,
[Texts] ,
[Data],
[Term] ,
[Active] BIT,
[TariffsByDistributor]
[TariffsDistributorID] PK
[DistID] FK
[TariffID] FK
[RevShare],
[Commision],
[Cost],
[Active]
[Product_Type]
[Product_Type_ID] PK,
[Name],
[Details],
[TariffsByNetwork]
[Network_ID] PK,
[TariffID] PK,
[Order] (
[Order_Id] PK,
[Customer_Id],
[Date Sold],
[PaymentStatus],
[PaymentStatusDate],
[TariffOrders] (
[Order_Id] PK,
[TariffsDistributorID] PK,
[RevenueShare],
[Commision],
[Cost],
[Products] (
[Product_Id] PK
[Product_Type_ID] FK,
[Name],
[Manufacturer],
[Colour]
[Picture],
[Active] BIT,
[ProductByDistributor]
[ProductsByDistributorID] PK,
[Dist_ID] FK,
[Product_Id] FK,
[RevShare],
[Commision],
[Cost],
[Active],
[ProductsOrder]
[Order_Id] PK,
[ProductsByDistributorID] PK,
[RevenueShare],
[Commision],
[Cost],
[Products_Network]
[Network_ID] PK,
[Product_Id] PK,
You are on the right track to finishing your schema, in that you are identifiying the relationships between distributors and offerings, distributor and pricings.
I’d start by adding in a DistributorTariff table which has relationships to both the Distributor and the Tariff. Then, look for other restrictions such as TariffPrice, etc and build up the tables there.
If you know ALL the relationship rules you’ll be able to set it out on paper first. If you share all of your rules, I can help you further with your design.
About your schema
It looks good. What might seem like extra complexity in normalising your database at this stage will save you headaches later. I’d make the following recommendations:
Hope that helps. I’m happy to elaborate on any questions.