What's this join technique called ?
From: Andy Dingley <dingbat_at_codesmiths.com>
Date: Thu, 20 Oct 2005 14:11:02 +0100
Message-ID: <j65fl1hvpj77g2p1qds2om5tlklv94d1p6_at_4ax.com>
I have a CMS (web content management system). It's based on MS SQL, with a stored-procedure query layer and XSLT for the presentation. Articles are in an "article" table. Site structure is a hierarchy of Site / Section / SubSection / SubSubSection, a simple tree of tables with keys of section-id, subsection-id etc.
Date: Thu, 20 Oct 2005 14:11:02 +0100
Message-ID: <j65fl1hvpj77g2p1qds2om5tlklv94d1p6_at_4ax.com>
I have a CMS (web content management system). It's based on MS SQL, with a stored-procedure query layer and XSLT for the presentation. Articles are in an "article" table. Site structure is a hierarchy of Site / Section / SubSection / SubSubSection, a simple tree of tables with keys of section-id, subsection-id etc.
Articles can be "homed" to one or several locations simultaneously. They appear on the site wherever they're the latest article(s) for that location, either section, subsection or whatever.
There's a single table to implement this many-to-many link (which is perfectly standard SQL). On one side of the join it's a simple foreign key on article-id. However on the other it's a compound key of intra-table-id and level. "level" identifies whether it's a section or sub-section and intra-table-id is a foreign key onto _either_ the section-id, subsection-id etc. according to the value of level.
-- Cats have nine lives, which is why they rarely post to Usenet.Received on Thu Oct 20 2005 - 15:11:02 CEST