0

Guys I am developing my project in Mysql Workbench and have a confusion about my project.

I have few questions:

How do we manage different types of payments? I mean my DB has a payment table and my system has 3 modes for payment.

1]Credit Card(Will store the respective information)

2]DebitCard(Will store the respective information)

3]Cash on Delivery(the payment is done in cash and will be updated later)

I have uploaded a image here to tell you what I was thinking

Bill table-Consists of bill generation and stuff. Payment table-As to when the payment is done (I have added a type id and fks from all table so that I can use a if/else clause on the select method.) is this good practive? Home table- is the cash on delivery thong

Is there any better method to do this? Please help.

enter image description here

I have further modified the image and have chucked out the type condition and instead I am using the if(payment_type) clause to access the respective DB, I believe this should get the job done. Is there any fault in this? Please help

enter image description here

chettyharish
  • 1,704
  • 7
  • 27
  • 41

1 Answers1

2

Indeed. There is. I would go with inheritance.

Here a simple diagram:

enter image description here

You need to include your attributes and notations (oneTOone, manyTOone,...). Do some research for inheritance.

Look here: http://de.scribd.com/doc/7122945/ER-Diagram And there are more if you google or stackoverflowle.

Regards ;-)

David Sonnenfeld
  • 688
  • 5
  • 17
  • 31
  • Thank you for your help, I have made a few modifications and tried to get it done using inheritance but removed the type field. Will this work or theres even a better option? – chettyharish Feb 08 '13 at 11:42
  • yes, its correct to remove the type field, because your type is an own entity now ;) Should work, make sure u learn some ER-modelling basics. If you really want to test it, draw tables and do some custom SQL queries... – David Sonnenfeld Feb 09 '13 at 11:21