Knowledge Base Exchange framework

Extension of the Data Exchange framework


kb-exchange

Edit and compile if you like:

% Knowledge Base Exchange framework
% Author: Elena Botoeva
\documentclass{article}
\usepackage{tikz}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{5pt}%
\usetikzlibrary{shapes,shadows,calc}
\usepgflibrary{arrows}

\newcommand{\A}{\mathcal{A}}
\newcommand{\K}{\mathcal{K}}
\newcommand{\M}{\mathcal{M}}
\newcommand{\T}{\mathcal{T}}


\tikzset{
  sshadow/.style={opacity=.25, shadow xshift=0.05, shadow yshift=-0.06},
}

%-----#1 size, #2 angle, #3 aspect, #4 label next to the diamond
%-----#5 name of the node, #6 coordinate, #7 label
\def\schemel[#1,#2,#3,#4,#5,#6]#7{ %
  \node[draw, diamond, shape aspect=#3, rotate=#2, minimum size=#1, %
  bottom color=green!55, top color=green!25, color=green!65!black, %
  drop shadow={sshadow,color=green!60!black}, #4] (#5) at #6
  {\textcolor{green!40}{bla}}; %
  \node at #6 {#7};%
}

\def\schemer[#1,#2,#3,#4,#5,#6]#7{ %
  \node[draw, diamond, shape aspect=#3, rotate=#2, minimum size=#1, %
  bottom color=green!65, top color=green!30, color=green!60!black, %
  drop shadow={sshadow,color=green!65!black}, #4] (#5) at #6
  {\textcolor{green!53}{bla}}; %
  \node at #6 {#7}; %
}

%-----TBoxes
%-----#1 height, #2 width, #3 anchor for the label, #4 name of the node, #5
%-----coordinate, #6 label
\def\tboxl[#1,#2,#3,#4,#5]#6{%
  \node[draw, drop shadow={opacity=.35}, minimum height=#1, minimum width=#2, %
  inner color=blue!45, outer color=blue!55, color=blue!40!black] (#4) at #5 {}; %
  \node[anchor=#3,inner sep=2pt] at (#4.#3) {#6};%
}

\def\tboxr[#1,#2,#3,#4,#5]#6{%
  \node[draw, drop shadow={opacity=.35}, minimum height=#1, minimum width=#2, %
  inner color=blue!35, outer color=blue!45, color=blue!50!black] (#4) at #5 {}; %
  \node[anchor=#3,inner sep=2pt] at (#4.#3) {#6}; %
}

%-----#1 name of the node, #2 coordinate, #3 label
\def\entity[#1,#2]#3;{
  \node[draw,drop shadow={opacity=.4,shadow xshift=0.04, shadow
    yshift=-0.04},color=blue!30!black,fill=white,rounded corners=3] (#1) at #2 {#3};
}

%-----#1 from node, #2 to node, #3 specification of a node (label), #4
%-----dashed, or other parameters for draw
\def\isaedge[#1,#2,#3,#4];{ 
  \draw[-triangle 60,color=black!20!black,#4,fill=white] (#1) -- #3
  (#2);  
}

%-----ABoxes
%-----#1 height, #2 width, #3 aspect, #4 name of the node, #5
%-----coordinate, #6 label
\def\aboxl[#1,#2,#3,#4,#5]#6{%
  \node[draw, cylinder, alias=cyl, shape border rotate=90, aspect=#3, %
  minimum height=#1, minimum width=#2, outer sep=-0.5\pgflinewidth, %
  color=orange!40!black, left color=orange!70, right color=orange!80, middle
  color=white] (#4) at #5 {};%
  \node at #5 {#6};%
  \fill [orange!30] let \p1 = ($(cyl.before top)!0.5!(cyl.after top)$), \p2 =
  (cyl.top), \p3 = (cyl.before top), \n1={veclen(\x3-\x1,\y3-\y1)},
  \n2={veclen(\x2-\x1,\y2-\y1)} in (\p1) ellipse (\n1 and \n2); }
    
\def\aboxr[#1,#2,#3,#4,#5]#6{%
  \node[draw, cylinder, alias=cyl, shape border rotate=90, aspect=#3, %
  minimum height=#1, minimum width=#2, outer sep=-0.5\pgflinewidth, %
  color=orange!50!black, left color=orange!50, right color=orange!60, middle
  color=white] (#4) at #5 {};%
  \node at #5 {#6};%
  \fill [orange!20] let \p1 = ($(cyl.before top)!0.5!(cyl.after top)$), \p2 =
  (cyl.top), \p3 = (cyl.before top), \n1={veclen(\x3-\x1,\y3-\y1)},
  \n2={veclen(\x2-\x1,\y2-\y1)} in (\p1) ellipse (\n1 and \n2); }

%-----#1 height, #2 width, #3 name of the node, #4
%-----coordinate, #5 label
\def\kbbox[#1,#2,#3,#4,#5]#6{
        \draw[dashed] node[draw,color=gray!50,minimum
        height=#1,minimum width=#2] (#4) at #5 {}; 
        \node[anchor=#3,inner sep=2pt] at (#4.#3)  {#6};
}

%-----#1 from node, #2 to node, #3 specification of a node (label), #4
%-----dashed, or other parameters for draw
\def\soledge[#1,#2,#3,#4];{
        \draw[dashed,-latex,#4] (#1) -- #3 (#2);
}

\begin{document}
  \begin{tikzpicture}
    \small
    
    % schemas
    \schemel[30,23,4,label=below:{source signature},p1,(0,5)] {$\Sigma_1$};
    \schemer[25,23,3,label=below:{target signature},p2,(6,5)] {$\Sigma_2$};
    \draw[-latex] (p1) .. node[above] {$\M$} controls (2.5,6) and (3.5,6) ..  (p2); 

    % source KB
    \kbbox[144,94,south,k1,(0,1.25)] {source KB $\K_1$};
    \tboxl[60,80,north east,t1,(0,2.5)] {$\T_1$};
    \entity[A1,(-0.9,3.1)] {$A_1$};
    \entity[B1,(-0.4,1.9)] {$B_1$};
    \entity[C1,(0.9,1.9)] {$C_1$};
    \entity[D1,(0.4,3.1)] {$D_1$};
    \isaedge[B1,A1,,];
    \isaedge[C1,B1,,];
    \isaedge[C1,D1,,];
    \aboxl[45,40,1.6,a1,(0,0)] {$\A_1$};

    % target KB
    \kbbox[144,84,south,k2,(6,1.25)] {target KB $\K_2$};
    \tboxr[60,70,north east,t2,(6,2.5)] {$\T_2$};
    \entity[A2,(6,3.1)] {$A_2$};
    \entity[B2,(5.3,1.9)] {$B_2$};
    \entity[C2,(6.7,1.9)] {$C_2$};
    \isaedge[B2,A2,,];
    \isaedge[C2,B2,,];
    \aboxr[40,50,1.4,a2,(6,0)] {$\A_2$};

    \soledge[k1,k2,,dashed];
  \end{tikzpicture}
\end{document}

Click to download: kb-exchange.texkb-exchange.pdf
Open in Overleaf: kb-exchange.tex