MySQL Forums
Forum List  »  Newbie

Re: How to normalize?
Posted by: Peter Brawley
Date: May 02, 2021 02:15PM

> You prefer SQL query text from mysql workbench instead of screenshot?

Database design is development of a set of database objects & logic that satisfies a set of detailed requirements; (i) this forum has no GUI capacities, (ii) neither does a relational database server---it reads SQL text not graphical images, (iii) requirements are textual, (iv) discussion of DDL details necessarily refers to specific rows of specific tables, text is best for that, (v) DDL is implemented as relational logic interpreted from DDL text not from graphical atoms ... so discussion of DDL here is necessarily text.

You have three expense tables that the requirement determines should be distinct, and one payment table.
Is there a requirement to always track specific payment amounts per expense type, ie when customer x pays x amount against payables, it must be apportioned to specific expenses? If so, normalising that structure entirely may be overkill, so you could consider something like ...

payments( pmtid, acctid, transactid, pmtdate, pmtamt, ...)
subpayments( subpmtid, pmtid (referencing payments), exp1amt, exp1ref, exp2amt, axp2ref, exp3amt, axp3ref, ... )

... where rules are that exp1amt+exp2amt+exp3amt=parent.pmtamt and each nom-zero exp...amt component is accompanied by an appropriate exp...ref that is enforced by a FK or at least lookup logic.

But often such rules are too strict for real-world practicality, so the client winds up with a rule exp1amt+exp2amt+exp3amt<=parent.pmtamt allowing both apportioned and unapportioned expense payments.

You'll need to explain how sequence is relevant.

Options: ReplyQuote


Subject
Written By
Posted
May 02, 2021 05:22AM
May 02, 2021 11:01AM
May 02, 2021 01:02PM
Re: How to normalize?
May 02, 2021 02:15PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.