One Primary Many Secondary Pattern

A DesignPattern used in RelationalDatabases to handle semi-hierarchal designs.

For example, consider implementing a WebLog. We may have an "Entry" table with a ToOne? relation to a "Topic" table: Entry <<-> Topic

An entry could then be accessed like so: http://weblog.com/topic/entry

However, often entries span multiple topics. The simple answer is to make the ToOne? relation to a ToMany? relation: Entry <<->> Topic. There, now the entry could be accesses via both http://weblog.com/topic/entry AND http://weblog.com/another_topic/entry

Problem: the WebLog Entry now longer has a OneTruePath -- it's homeless! If we want to provide BreadCrumbs -style navigation, we're lost.

A simple tweak solves this issue, have two relations between Entry and Topic:

  1. the to-one primary relation: Entry <<---primary topic-> Topic
  2. the to-many secondary relation: Entry <<---secondary topics->> Topic

Thus, now we have the OneTruePath ease with the ToOne? design, with the multiple-topics flexibility of the ToMany? design.


EditText of this page (last edited August 12, 2002) or FindPage with title or text search