Advertisement
anchormodeling

Temporal Entity Integrity

Feb 24th, 2012
818
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 1.08 KB | None | 0 0
  1. -- create one identity
  2. exec kST_Stage 1
  3.  
  4. -- insert one row, should succeed
  5. insert into ST_NAM_Stage_Name values
  6. (1, 'Alpha', '2001-01-01', '2012-01-01', '9999-12-31');
  7.  
  8. -- insert "same" row, should fail due to primary key constraint
  9. insert into ST_NAM_Stage_Name values
  10. (1, 'Alpha', '2001-01-01', '2012-01-01', '9999-12-31');
  11.  
  12. -- insert overlapping row, should fail due to overlapping constraint
  13. insert into ST_NAM_Stage_Name values
  14. (1, 'Alpha', '2001-01-01', '2012-01-01', '2012-02-02');
  15.  
  16. -- insert negative interval, should fail due to interval constraint
  17. insert into ST_NAM_Stage_Name values
  18. (1, 'Omega', '2001-01-02', '2012-01-01', '2001-01-01');
  19.  
  20. -- insert temporal duplicate, should fail due to uniqueness constraint
  21. insert into ST_NAM_Stage_Name values
  22. (1, 'Omega', '2001-01-01', '2013-01-01', '9999-12-31');
  23.  
  24. -- insert changed value, should succeed
  25. insert into ST_NAM_Stage_Name values
  26. (1, 'Omega', '9999-12-31', '2012-01-01', '9999-12-31');
  27.  
  28. -- looking at some values
  29. select * from ST_NAM_Stage_Name
  30. select * from lST_Stage
  31. select * from pST_Stage('2012-01-02')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement