If Object_ID('T_Nekudot') Is Not Null Drop Table T_Nekudot;
Go
Create Table T_Nekudot(Nekuda Char(1) Primary Key);
Go
Insert
Into T_Nekudot
Select 'A' Union All
Select 'B' Union All
Select 'C' Union All
Select 'D' Union All
Select 'E' Union All
Select 'F' Union All
Select 'G' Union All
Select 'H' Union All
Select 'I' Union All
Select 'J' Union All
Select 'K' Union All
Select 'L';
If Object_ID('T_Kavim') Is Not Null Drop Table T_Kavim;
Go
Create Table T_Kavim(Kav Char(2) Primary Key);
Go
Insert
Into T_Kavim
Select 'AK' Union All
Select 'CE' Union All
Select 'FH' Union All
Select 'IK' Union All
Select 'AL' Union All
Select 'BF' Union All
Select 'EI' Union All
Select 'HL' Union All
Select 'BC' Union All
Select 'EF' Union All
Select 'HI' Union All
Select 'KL';
If Object_ID('T_KavimNekudot') Is Not Null Drop Table T_KavimNekudot;
Go
Create Table T_KavimNekudot(Kav Char(2) Not Null,
Nekuda Char(1) Not Null);
Alter Table T_KavimNekudot Add Constraint PK_T_Nekudot Primary Key Clustered (Kav,Nekuda);
Go
Alter Table T_KavimNekudot
Add Foreign Key (Kav) References T_Kavim(Kav);
Go
Alter Table T_KavimNekudot
Add Foreign Key (Nekuda) References T_Nekudot(Nekuda);
Go
Insert
Into T_KavimNekudot
Select 'AK','A' Union All
Select 'AK','B' Union All
Select 'AK','E' Union All
Select 'AK','H' Union All
Select 'AK','K' Union All
Select 'CE','E' Union All
Select 'CE','D' Union All
Select 'CE','C' Union All
Select 'FH','H' Union All
Select 'FH','G' Union All
Select 'FH','F' Union All
Select 'IK','K' Union All
Select 'IK','J' Union All
Select 'IK','I' Union All
Select 'AL','A' Union All
Select 'AL','C' Union All
Select 'AL','F' Union All
Select 'AL','I' Union All
Select 'AL','L' Union All
Select 'BF','B' Union All
Select 'BF','D' Union All
Select 'BF','F' Union All
Select 'EI','E' Union All
Select 'EI','G' Union All
Select 'EI','I' Union All
Select 'HL','H' Union All
Select 'HL','J' Union All
Select 'HL','L' Union All
Select 'BC','B' Union All
Select 'BC','C' Union All
Select 'EF','E' Union All
Select 'EF','F' Union All
Select 'HI','H' Union All
Select 'HI','I' Union All
Select 'KL','K' Union All
Select 'KL','L';