• 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

Help in pattern hunt

 
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've been out to the Pattern Repository and done some Google hunting, but I'm drawing a blank. Hoping that if I describe my basic problem, someone can point me either to a specific pattern or a set of keywords to help me in my hunt. . . This post is long, because the basic problem is I'm attempting to crystallize my problem, trying to make it into something more recognizable.
We're building a system that will let researchers search and browse against a database of medical data. That data will be of varying types (dates, coded values, images, . . .), all tied together in pretty well-known way (it all belongs to some woman who went in for a doctor's visit on a particular day). So far, so good - I can group Attributes together using the Composite pattern to form more manageable UI items, etc, etc.
I guess the gut problem is this: I have a dynamic data application. The set of fields in my database will change over time (more will be added, basically, as that data is scrubbed), and I don't want to change my application every time a field is added, particularly since there's no business logic associated with the data - simply read. So there's no reason to encapsulate the given data into objects - the objects are the things that interact with the data in a generic way. So, I need a way to deal with both knowing that the attributes are there, and some set of semantics about them (essentially, the stuff I'd store in the idea of an Attribute: descriptions, that the set of values is within a certain range, etc.).
How do I tie the idea of the attribute to the data itself? I envision the data being stored in your basic relational database structure to assist in searching (1 woman has multiple visits, each with their own set of attributes), and the set of attribute data being stored somewhere else. But I haven't made the conceptual pattern leap to tie the two together. E.g., I want to retrieve the set of data from the database, and know its attribute structure, as well.
I have a sample application that I've been poking at (the open source Scarab issue tracking system) - trying to get some insight there, since it deals with a set of dynamic attributes for issues.
Not an easy post/question, but hoping it's intriguing enough to someone to post some ideas.
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think the first you should do is stop thinking about the database. Instead, think about how to model your solution using objects. http://martinfowler.com/apsupp/properties.pdf might help with that.
Once you have a reasonable class/object model, *than* you can start thinking about how to persist it. I would even like to question wether you really should start with a database...
 
Tina Coleman
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Reasonable advice, Ilya. I'm also tasked with designing the database, so probably have my head too close to both problems at the same time.
 
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My guess is that you may be missing the point of relational databases, a bit.
When I first encountered relational database tables, I found them really limiting because I felt I had to pre-specify every attribute as a column. I designed columns like "phone1", "phone2" and so on, and had headaches if a user had more than two phone numbers. Later I learned not to be afraid of joins, and now would probably code the above with a separate table of "user", "phone" and join when necessary.
The case of arbitrary attributes is very similar. Imagine (simplisticly) you have tables simething like
person (person_id, name)
attribute (person_id, attribute_type, value)
attribute_def (attribute_type, description, validation details etc ...)
Now you can get all the attributes for a named person (for example) using something like:
[code]
SELECT
p.person_id,
def.description,
attr.value
FROM
person p,
attribute attr,
attribute_definition_def
WHERE
p.name = ? AND
attr.person_id = p.person_id AND
attr.attribute_type = def.attribute_type
[code]
I hope I'm not "teaching you to suck eggs", here, but implementing arbitrary attributes in a database is not usually a big problem.
 
Tina Coleman
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Database-wise, I've done exactly what you describe, Frank. Works well, albeit making some queries a bit more complex. I guess that doesn't seem to handle my whole case, somehow. Got the gut reaction that it doesn't feel right, though I'm still trying to wrap my hands around the problem enough to verify the gut reaction. Thanks for the feedback, though. ..
reply
    Bookmark Topic Watch Topic
  • New Topic