Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DB schema for multiple composite values?

 
Peter Oikari
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greets,

We have object model which contains many subclasses and those same subclass types are used in other classes.

To clarify (simplified):

class Compositevalue ...
String value1;
String value2;


class Compositevalue2 ...
String value1;
SET<Compositevalue> value2;
SET<Compositevalue2> value3; //recursion

class ToBePersistedSomeClass ...
Compositevalue value1;
Compositevalue2 value2;


class ToBePersistedSomeClass2 ...
Compositevalue value1;
Compositevalue2 value2;
SET<Compositevalue2> value3;


Obviously plan one is to make database schema so that Compositevalues are broken to rows into db tables
representing ToBePersistedSomeClass and ToBePersistedSomeClass2.

Unfortunatelytheres lots of nested sets in Compositevalues themselves (containing other compositevalues),
so plan two is to make relational table for every instance of Compositevalue and Compositevalue2.
That in other hand leads to hundreds of small subtables and is not very practical to maintain.

So question is, is there any DB pattern or alike to make only one table for Compositevalue && Compositevalue2
and still use primary key/foreign key constraints to ensure data integrity?

Thanks,
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic