-1

I have a CapitalIncrease table, which contains a list of available payment methods. For each payment method, I need to put some data (SepaDocument OR Iban OR Crypto).

Here is a mermaidjs graphic of how I do it now:

enter image description here

Is this a good way of storing payment information in the MethodOfPaiement, depending on the MethodOfPaiement.value (type of payment), while satisfying 5th NF?

It doesn't look right to me. How to I get that to be in the 5th NF?

1
  • Ask 1 specific researched non-duplicate question. Splitting tables for subtypes has nothing to do with DB normalization. Why do you think it does & how are you stuck answering this? What design method reference are you following & how/where are you stuck & why? help center
    – philipxy
    Aug 11 at 21:06

1 Answer 1

-2

I didn't understand if for a capitalIncrease, several investmentMethods are allowed or not. So, I tell my opinion for both cases:

  1. Every capitalIncrease uses only one investmentMethod: you need just one table:

     CREATE TABLE public.capitalIncrease (
         id serial4 NOT NULL,
         investment_method investment_method_types,
         investment_properties jsonb
     );
    
  2. In case several investmentMethods are available for a single capitalIncrease, you need just two tables and a foreign key:

    CREATE TABLE capitalIncrease (
     id serial4 NOT NULL,
    );
    
     CREATE TABLE investmentMethod (
         id serial4 NOT NULL,
         investment_method investment_method_types,
         capitalIncrease_id in4 not null,
         investment_properties jsonb
     );
     ALTER TABLE investmentMethod 
     ADD CONSTRAINT capitalIncrease_fk FOREIGN KEY (capitalIncrease_id) 
     REFERENCES capitalIncrease(id) ON DELETE RESTRICT ON UPDATE CASCADE;
    

To sum up, when you have various fields for each method, it's better to use jsonb. For investment methods, use enumeration.

Another suggestion, for name of tables and fields, use snake case as stated in here.

2
  • The schema is simplified, CapitalIncrease contains more columns. The question is only about InvesmentMethods, which can contains multiple MethodOfPaiment.
    – Valentin
    Aug 11 at 19:15
  • I understand, don't these two tables satisfy your needs?
    – Sajjad
    Aug 12 at 8:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.