2

I am modeling a "pizza place" and a customer has an account info. I created a separate table for account info. In here a customer will have an amount spent and method of payment attributes. The payment methods can be cash, cheque or credit card. If it is credit card, it needs to have a number. I'm wondering how to best represent this attribute. Does it need to be another table.

4

1 Answer 1

3

Credit card info should be in a separate table because normally, you need to have more than just a number. You will also need, at the very least, the card's expiry date. You may also need to store cardholder information (name, address, etc...) in case it is different from the name on the account. All of that extra information is only relevant to customers that pay by credit card. And will you allow multiple cards for one account? How will you handle cards that expire and need to be replaced? Delete the old record, mark as expired, add a new one? Or just update existing data?

And although it's not necessarily going to be reflected in an ER diagram, you have to consider security if you plan to implement this. You might want to start looking here: https://www.pcisecuritystandards.org/

6
  • This is for a college project design. I'm not sure if I need to enforce strict security standards.
    – devcoder
    Mar 20, 2012 at 19:17
  • 1
    @JohnSmith: For course work, probably not (unless the instructor hints at it in the assignment paper). You could make mention of it, or explain how you might encrypt the card numbers/expiry dates if you store complete card numbers. Mar 20, 2012 at 19:19
  • In response to the other part of your answer - I am going to assume that each person has only one card. So I'm thinking I can store all the info related to the card in a separate table and have an id for the card as unique id, which would be stored as the payment method in the account info table. For people who don't pay with card, I could just put in "cash" or "cheque". Am I thinking right ?
    – devcoder
    Mar 20, 2012 at 19:24
  • I would keep the payment method (cash, card, etc...) as separate from the field that stores any reference to a card. Mar 20, 2012 at 19:29
  • 1
    @JohnSmith: I could but then I'd want the class credit for it! :P Mar 20, 2012 at 19:47

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.