• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Data model against a class diagram

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is something I have always encountered while creating a data model to fit a class diagram.
A simple scenario to consider is : A customer, a credit card and a Payment class. For simplicty a customer has got one credit card, can have many orders and pays them with his single credit card.
A credit card can belong to a payment object and also to a customer. In terms of storing them in database, both has to be stored in different tables. Why ? Cause a payment object cannot just point to the customers credit card. A payment object should point to a credit card that was used while paying. However the credit card details associated with the customer can change over time. I have got two options :
1. Store them in the same table but in different rows representing different objects. In this case we can assoicate the same class to customer and payment.
2. Create two different classes i) Customer Credit Card ii) Payment Credit Card and persist them in different tables.
Which option is better and why?
[ April 16, 2004: Message edited by: Anjan Pathak ]
 
Bring me the box labeled "thinking cap" ... and then read this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic