I'm working with the tikz-er2.sty Package and extending it for my purposes to draw ER-Diagrams. One missing concept in this package is that of specializations. An example of the specialization notation I'm looking for is seen here. Basically, it's a subset symbol in the middle of a straight line linking two entities (or a specialization circle).
I've put some thought into how I could achieve this, but haven't come up with an elegant solution. One certainly needs to consider the direction of the line from one entity to another, in order to orient the symbol correctly. One main idea would be to predefine the symbol as a node in a macro or just use the normal $\bigcup$ symbol, and draw that in the middle with the correct rotation:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning, arrows}
% Some definitions taken from tikz-er2.sty
\tikzstyle{every entity} = []
\tikzstyle{every link} = []
\tikzstyle{link} = [>=triangle 60, draw, thick, every link]
\tikzstyle{entity} = [rectangle, draw, black, very thick,
minimum width=6em, minimum height=3em,
every entity]
\begin{document}
\begin{tikzpicture}[node distance=.5cm, every edge/.style={link}]
% This works easily
\node[entity] (left) {Left};
\node[entity, right=3cm of left] (right) {Right};
\draw[link] (left) -- node[pos=.5] (mid) {} (right);
\node[rotate=-90, xscale=1.2] (U) at (mid) {$\bigcup$};
\begin{scope}[yshift=-3cm]
% This is more difficult... how to find roation automatically?
\node[entity] (topleft) {Top Left};
\node[entity, below right=3cm and 2cm of topleft] (bottomright) {Bottom Right};
\draw[link] (topleft) -- node[pos=.5] (mid) {} (bottomright);
\node[rotate=-135, xscale=1.2] (U) at (mid) {$\bigcup$};
\end{scope}
\end{tikzpicture}
\end{document}
There's three things I don't like about this MWE:
- I find the symbol to be too small, and resizing it also influences the line thickness (which should remain the same as the link). Maybe this could be rectified by defining a standalone macro to draw a custom symbol and rotating that whole path.
- You have to use multiple draw statements, which could at best be wrapped into a macro. Maybe TikZ also has the capability of wrapping all of this into a style?
- The main Issue: With non-trivial entity positionings, you have to find a correct-looking rotation manually
Do you have an idea how to achieve what I'm looking for somewhat automatically, i.e. TikZ calculating the rotation for me?
[rotate=-90,sloped]
for your mid-side node.