Path: dp-news.maxwell.syr.edu!spool.maxwell.syr.edu!drn.maxwell.syr.edu!news.maxwell.syr.edu!postnews.google.com!f14g2000cwb.googlegroups.com!not-for-mail
From: zeldorblat@gmail.com
Newsgroups: comp.databases.theory
Subject: Table with one row
Date: 19 Oct 2005 08:07:17 -0700
Organization: http://groups.google.com
Lines: 24
Message-ID: <1129734437.042073.223980@f14g2000cwb.googlegroups.com>
NNTP-Posting-Host: 64.199.1.90
Mime-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
X-Trace: posting.google.com 1129734442 31962 127.0.0.1 (19 Oct 2005 15:07:22 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Wed, 19 Oct 2005 15:07:22 +0000 (UTC)
User-Agent: G2/0.2
X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) Gecko/20050922 Fedora/1.0.7-1.1.fc4 Firefox/1.0.7,gzip(gfe),gzip(gfe)
Complaints-To: groups-abuse@google.com
Injection-Info: f14g2000cwb.googlegroups.com; posting-host=64.199.1.90;
   posting-account=ivWmoA0AAAB2VzV5eyLZ6S5_uf1FfeWZ
Xref: dp-news.maxwell.syr.edu comp.databases.theory:34064

In our system we have a table with one row ("today") that is used
solely to tell the application what the current processing date is (as
well as yesterday and tomorrow).  The table looks like this:

create table today (
        yesterday smalldatetime not null,
        today smalldatetime not null,
        tomorrow smalldatetime not null,

        check ((yesterday < today) and (today < tomorrow))
)

Since the table only has one row, we purposely join to it without a
condition (cartesian join), knowing that we won't get any more rows
than we expect.  The table is updated daily by one of our batch jobs.

My question is twofold.  First, how does one restrict the number of
rows in a table (in this case, to guarantee there's only one row) ? I
suppose you can use a trigger, but perhaps there's a better way.

Second, to be relationally correct, the table needs a primary key.
What might the key be in this situation?  It seems silly to add an
identity column since

