Example of a table with full constraints for data validity:
drop table fiscalyeartable1
CREATE TABLE FiscalYearTable1
(fiscal_year INTEGER NOT NULL,
start_date DATE NOT NULL,
end_date DATE NOT NULL
Constraint PK__fiscal_year__start_date__end_date primary key (fiscal_year, start_date, end_date),
Constraint Chk__start_date__YearMinusOne check (year(start_date) = fiscal_year -1),
Constraint Chk__start_date__SmallerThanEnddate check (start_date < end_date),
Constraint Chk__start_date__MonthIs1stJuly check (month(start_date) = 7), check(day(start_date)=1),
Constraint Chk__end_date__Year check (year(end_date) = fiscal_year),
Constraint Chk__end_date__GreaterThanStartdate check (end_date > start_date),
Constraint Chk__end_date__MonthIs30thJune check (month(end_date) = 6), check(day(end_date)=30)
);
Popular Posts
-
Kendo UI applying SUM in footer template kendo ui - KendoUI: Grid Summary values in Footer - Stack Overflow : ", footerTemplate:...
-
MVC grid example ASP.NET MVC Flexigrid sample - CodeProject : 'via Blog this'
-
A possible way of handling distributed transaction for multiple contexts without alleviation to MSDTC??? c# - Entity Framework - Using Trans...
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment