How to fill the third table by missing combination of values from the other two tables?
Posted: 2020-03-07 22:01
I figured it out how to prepare a selection, but I do not know how to implement it in table tsoa lookup field definition in AG in order values will offer only desired requirements according category of preselected system. And the most user friendly solution should be if it can be reduced to the list only of those requirements which was not selected to the particular system yet, in other words only those requirements which combination of system + requirement is not yet in table tsoa.
Here is my selection example, tested on https://rextester.com/ simple copy & paste
Create table syst(
ID int IDENTITY primary key,
Sys varchar(20),
Catv varchar(4),
Cati tinyint
);
create table reqt(
ID int IDENTITY primary key,
Req varchar(20),
Cat tinyint
);
create table tsoa(
ID int IDENTITY primary key,
S int references syst(id),
R int references reqt(id)
);
insert into syst values ('A','II.',2), ('B','I.',1), ('C','I.',1), ('D','III.',3), ('E','II.',2)
insert into reqt values ('Firewall', 1), ('DLP', 3), ('BIA', 1), ('RA', 1), ('Backup', 1), ('Netflow', 3), ('Proxy', 2), ('DMZ', 2), ('NAC', 3), ('VPN', 3), ('OTP', 3), ('AD', 2), ('DHCP', 1), ('Syslog Server', 3)
insert into tsoa values (1,1), (1,2), (2,3), (2,5), (2,2), (2,4), (4,2), (4,4), (4,3), (4,1), (4,5), (5,7), (5,10), (5,1), (3,12), (3,11), (3,14), (3,13)
select syst.sys, syst.catv, reqt.req, reqt.cat from syst full outer join reqt on syst.cati>=reqt.cat order by syst.sys, reqt.cat
Here is my selection example, tested on https://rextester.com/ simple copy & paste
Create table syst(
ID int IDENTITY primary key,
Sys varchar(20),
Catv varchar(4),
Cati tinyint
);
create table reqt(
ID int IDENTITY primary key,
Req varchar(20),
Cat tinyint
);
create table tsoa(
ID int IDENTITY primary key,
S int references syst(id),
R int references reqt(id)
);
insert into syst values ('A','II.',2), ('B','I.',1), ('C','I.',1), ('D','III.',3), ('E','II.',2)
insert into reqt values ('Firewall', 1), ('DLP', 3), ('BIA', 1), ('RA', 1), ('Backup', 1), ('Netflow', 3), ('Proxy', 2), ('DMZ', 2), ('NAC', 3), ('VPN', 3), ('OTP', 3), ('AD', 2), ('DHCP', 1), ('Syslog Server', 3)
insert into tsoa values (1,1), (1,2), (2,3), (2,5), (2,2), (2,4), (4,2), (4,4), (4,3), (4,1), (4,5), (5,7), (5,10), (5,1), (3,12), (3,11), (3,14), (3,13)
select syst.sys, syst.catv, reqt.req, reqt.cat from syst full outer join reqt on syst.cati>=reqt.cat order by syst.sys, reqt.cat