I'm having trouble with the design of a temporal database. I need to know how to make sure I have only one active record for any given timeframe for a store. I have read this answer, but I'm afraid I can't wrap my head around how the trigger would work. Particularly, how I would work that trigger into my existing one that prevents updates to records, and inserts a new record instead. My real problem is that I do not know how to prevent a Store from having more than one effective date when the finished date is null. (i.e. prevent 2 active records for a store).

This is what I have, but it allows me to insert a new record for a store with a different effective date.

Table Definition:

/****** Object:  Table [PCR].[Z_STORE_TEAM]    Script Date: 05/09/2014 13:05:57 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[Z_STORE_TEAM]') AND type in (N'U'))
DROP TABLE [Z_STORE_TEAM]
GO

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[Z_STORE_TEAM]') AND type in (N'U'))
BEGIN
CREATE TABLE [Z_STORE_TEAM](
    [STORENUM] [int] NOT NULL,
    [TEAM] [varchar](10) NULL,
    [EFFECTIVE] [date] NOT NULL,
    [FINISHED] [date] NULL,
PRIMARY KEY CLUSTERED 
(
    [STORENUM] ASC,
    [EFFECTIVE] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO


Sample Data:

INSERT [Z_STORE_TEAM] ([STORENUM], [TEAM], [EFFECTIVE], [FINISHED]) VALUES (1, N'1', CAST(0x01380B00 AS Date), CAST(0x81380B00 AS Date))
INSERT [Z_STORE_TEAM] ([STORENUM], [TEAM], [EFFECTIVE], [FINISHED]) VALUES (1, N'2', CAST(0x81380B00 AS Date), NULL)
INSERT [Z_STORE_TEAM] ([STORENUM], [TEAM], [EFFECTIVE], [FINISHED]) VALUES (2, N'1', CAST(0x01380B00 AS Date), NULL)
INSERT [Z_STORE_TEAM] ([STORENUM], [TEAM], [EFFECTIVE], [FINISHED]) VALUES (2, N'2', CAST(0x20380B00 AS Date), NULL)


Instead of Update Trigger:

CREATE TRIGGER [tr_ZStoreTeam_update] 
   ON  [Z_STORE_TEAM]
   INSTEAD OF UPDATE
AS 
BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;

    -- Insert statements for trigger here
    INSERT INTO PCR.Z_STORE_TEAM(STORENUM,TEAM,EFFECTIVE)
    SELECT I.STORENUM,I.TEAM,GETDATE() AS EFFECTIVE
    FROM inserted I
    INNER JOIN PCR.Z_STORE_TEAM ST
        ON I.STORENUM = ST.STORENUM

    UPDATE ST
    SET FINISHED = GETDATE()
    FROM PCR.Z_STORE_TEAM ST
    INNER JOIN inserted I
        ON ST.STORENUM = I.STORENUM
        AND ST.EFFECTIVE = I.EFFECTIVE
END

GO



Question: Does this statement make any sense?
Answer: 
  His response: Nevermind, for the first
  time I accept I was wrong. BUT using
  lightyears to measure time is
  possible.


It's possible if you rape physics, definitions, and just organize things so that you actually, in the end, obtain time from dimensional analysis. The idea would go along this line of reasoning:


I know a man walks 5 km/h, hence
space is a unit of time because I can say 10 km is equivalent to two hours, hence
I can measure time by specifying a distance. Let's meet in 5 kilometers at the pub 200 meters from here.


But that's not a unit definition. it's just a deep misrepresentation of concepts: using this approach, you can define everything in terms of anything else, assuming there's a relationship among them. you could define time in terms of weight of apples a man can move from the tree to a box.

Also, the whole setup is pretty circular in definition. You define time as space traveled by something at a constant speed for a defined time, so in the end your pulled you own bootstraps.


  My example didn't make sense
  bacause I was wrong when I meantioned
  that I'm still measuring dist. If you
  have a signal in time domain and
  ...take the FT, I get a signal which
  DOES NOT HAVE to be in frequency
  domain.


A Fourier transform is nothing but finding the coefficients of a linear combination of plane waves. When you find these coefficients, you can express the original function as the linear combination of these coefficients and a plane wave. If you note, there's a unit relationship between the domain before the FT and after. seconds -> seconds^(-1) = Hz. So even if you want to do fourier decomposition of a space-based periodic or aperiodic system, the resulting domain will be in meters^(-1), which is eventually a wave number. 


  Clarify this to the guy who
  posted last. Now the new signal is in
  a domain defined by me and so is its
  units.


Nope, it just turns out from the dimensional analysis that this is not the case. Clearly, you can always transform your frobbles units into Hertz through an ad-hoc transformation you invent (see the man-apples above) but that would still not change the final dimensional analysis of your FT, and you would, in any case, introduce an arbitrary constant (in our case above, the walking speed) which, in the end, likely produces a circular definition.


  This signal although not equal
  to the original signal, still
  represents that if ya take an inverse
  FT. So, the idea of time will still be
  there. Now coming back to our case:
  lightyears here is not the lightyears
  you are used to read when dealing with
  distance. It represents time.


Lightyears is a measure of distance. It is a product of two well defined constants: the speed of light and a well defined amount of time. Simple dimensional analysis tells you it's a distance.

Edit: non-tech note. there's nothing wrong not to know things. Tell your friend it's not my intention to mock him. There's, however, something wrong to pretend to be right through misunderstood justification. It looks like he is mature enough to understand he is wrong, which is the spirit we should all live with. I hope my answers clarifies his doubts. Note that I could be wrong myself. I don't know the technicalities of standard unit definitions, and my exposition could be patched by someone who knows more than me on this field. The approximation I present here is good enough for the purpose of explanation, but it is wrong nevertheless when we go down to the gritty details, and I am ready to accept criticism on this regard. This is how we progress.