sql server - Foreign Key off of a UNIONed View -


i have view looks this:

create view   reference.test schemabinding       select        reference.highleveltestid testid, name, isactive,                   cast(1 bit) ishighleveltest               reference.highleveltest      union      select        lowleveltestid  testid, name, isactive,                    cast(0 bit) ishighleveltest                reference.lowleveltest  go 

note: highleveltestid , lowleveltestid guaranteed never have same values (no conflicts).

i have table looks this:

create table [reference].[testaddition](     [testid] [bigint] not null,     [otherstuff] [bit] not null,     ....  )  

i fk testaddition table test view on testid column (for referential integrity , ease of use odata).

is there way that?

foreign keys cannot applied views. angle: cannot apply referential integrity results returned select statement, because not stored permanently, non-persistent output of query.

to manage referential integrity, apply foreign keys or other such constraints data while have stored them permanently - in case example in tables ishighleveltest , islowleveltest. or make result of union permanent storing in table. there more ways.


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

node.js - Node - Passport Auth - Authed Post Route hangs on form submission -

Does Firefox offer AppleScript support to get URL of windows? -