1

In my project, a guest user can make donations to organisation in 2 ways.

1.organisation has invited donations for a 'x' purpose, and a fixed amount to be paid, say Rs.150. In this case list of donation exist.user can choose one or more donations and can make payment. 2.A user can pay any amount as donation to the organisation.

I want to maintain the payments record for both fixed and raw donations to the organisation.

fixed_donations table
---------------
id pk
organisation_id fk
donation_name varchar(250)
description text
price decimal(10,2)


payments table
--------------
id pk
payment_id int(10)
donation_type enum('fixed','raw')
organisation_id fk
fixed_donation_id fk
amount decimal(10,2)
name varchar(50)
email varchar(50)
contact_number int(12)
date datetime

Is there a need to keep seperate payments table for raw donation and fixed donation, or is there a better way to include both donation payments within a table

Geethu
  • 348
  • 6
  • 24

1 Answers1

1

If I understand your question correctly, a payment can be either for a known donation request, or with no donation request.

This is an example of a known problem with the relational model - it's hard to accommodate inheritance. There are lots of questions on Stack Overflow on that topic.

In your case, I would imagine that the "payments" table has several important uses in the database model - you'll want to work out total payments, payments in a period, find payments from a donor. So I would keep it pretty much as you have it, using the "single table inheritance" model. The alternatives are likely to be much harder to work with.

Neville Kuyt
  • 29,247
  • 1
  • 37
  • 52