Let's say I am building a simple Content Management System (CMS), there would be a table "Article" that contains:
id (int, Primary key)
title (varchar)
content (some large varchar)
version (int)
guid (unique guid, or even number)
When an article is edited, a new record is inserted with a new id, the new record has incremented the version, and the guid is the same as previous versions of this article. So, if you wanted to get the "current" version of the article, we could query the table to get the article where title=ABC and version is the greatest number in the set of guids of the associated versions. So......
If I wanted another table "Top articles" (id, article_guid) that has a field "article_guid" to be associated with whichever is the most recent version of that article.... what type of constraint would it be to ensure that all inserts into Top Articles will always have an article_guid that exists in the Article table?
Thanks in advance!
-Mike
id (int, Primary key)
title (varchar)
content (some large varchar)
version (int)
guid (unique guid, or even number)
When an article is edited, a new record is inserted with a new id, the new record has incremented the version, and the guid is the same as previous versions of this article. So, if you wanted to get the "current" version of the article, we could query the table to get the article where title=ABC and version is the greatest number in the set of guids of the associated versions. So......
If I wanted another table "Top articles" (id, article_guid) that has a field "article_guid" to be associated with whichever is the most recent version of that article.... what type of constraint would it be to ensure that all inserts into Top Articles will always have an article_guid that exists in the Article table?
Thanks in advance!
-Mike