0

Transaction is an object which may describe a recurring transaction (an object of it "says" such things as "we receive a $10 payment every month from this PayPal user").

Organization is a customer which may pay us and in return receive some services. Currently one organization can receive max one service, but this may change in the future.

PricingPlan is something like "Gold $20/month".

Purchase links together a pricing plan with a transaction.

Note that we cannot (or can but with a hardship) add new fields to Transaction model, because it is a part of a reusable module. The rest three models are under our complete control.

I need to make a relational DB structure from these four models.

I've drawn two possible relations between the models. Which of the two: the top one or the bottom one is more normal than the other?

two diagrams

porton
  • 5,214
  • 11
  • 47
  • 95
  • I think the real question is whether you must have a transaction for every purchase. If not there is no way to get to the organization making the purchase in the second schema. – HLGEM Feb 27 '17 at 22:08
  • I think that the main idea behind all normalized forms is that the model contains as little information as possible. The first diagram (preferred) contains less information as in the second diagram it is possible that an organization refers to a transaction not related to a purchase (what is a nonsense). (Yes, in my real code there exist transactions not related to a purchase.) – porton Feb 27 '17 at 22:25
  • 1
    @porton Normalization is a way to reduce redunancy (by replacing a table by smaller ones), not change what data is stored or what it tells you. – philipxy Feb 28 '17 at 00:38
  • 2
    Normalization uses *functional dependencies* involving fields/columns in a model/table. Please give this information. If you don't understand this, don't give us a link, *read the link yourself and act on it*. Anyway, first you have to decide what you want records/rows of your models/tables to tell you about your business situations, so that you are recording everything you need. This comes before cardinalities, because only when you know what business relationship/association is recorded and what the business rules are in terms of them can you know what the cardinalities are. – philipxy Feb 28 '17 at 00:53

0 Answers0