Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I want to build an E/R diagram in LaTeX such that there should be rhombus for representing the relations and squares for representing the entity sets. I dont want to import graphics in LaTeX i.e. import the graphics after drawing it in some other image drawing software but want to do it in LaTeX itself.Could someone suggest me some good links to read from??

share|improve this question
2  
I would highly recommend tikz. Here are a few questions on this site that might be useful: neural-network-representation, produce-the-following-exact-hexagon, connect-tikz-nodes-running-around-nodes –  Peter Grill Jan 16 '12 at 6:24
    
I have used the tikz-er2 library for drawing the E/R diagram but i want to draw the referential integrity i.e and a line followed by a closing bracket to represent referential integrity How could i do that in tikz-er2? –  noddy Jan 16 '12 at 8:43

2 Answers 2

You can do this easily with TikZ.

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{shapes}

\colorlet{relation@colour}[rgb]{blue}
\colorlet{entity@colour}[rgb]{red}

\tikzset{relation/.style={%
           shape=diamond,draw=relation@colour!50!gray,
           ultra thick,fill=relation@colour!25!white,
           minimum height=2em},
         entity/.style={%
           shape=rectangle,draw=entity@colour!50!gray,
           ultra thick,fill=entity@colour!25!white,
           minimum height=2em}}

\begin{document}

\begin{tikzpicture}
  \draw (0,0) node(tikz) [entity] {TikZ}
        (tikz.east) + (1,0)
              node(draws)[relation,anchor=west] {draws}
        (draws.east) + (1,0)
              node(er diagrams)[entity,anchor=west] {\textsc{er} diagrams}
        (tikz) -- (draws)
        (draws) -- (er diagrams);
\end{tikzpicture}

\end{document}

user defined ER diagram.

As a matter of fact, TikZ also provides an er library. The following shows how to use it.

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{er}

\begin{document}

\begin{tikzpicture}
  \draw (0,0) node(tikz) [entity] {TikZ}
        (tikz.east) + (1,0)
              node(draws)[relationship,anchor=west] {draws}
        (draws.east) + (1,0)
              node(er diagrams)[entity,anchor=west] {\textsc{er} diagrams}
        (tikz) -- (draws)
        (draws) -- (er diagrams);
\end{tikzpicture}

\end{document}
share|improve this answer

A simple example, run it with xelatex or latex->dvips->ps2pdf

\documentclass{article}
\usepackage{pst-node,pst-dbicons}
\begin{document}

\seticonparams{entity}{shadow,fillcolor=red!30,fillstyle=solid}
\seticonparams{relationship}{shadow,fillcolor=blue!20,fillstyle=solid}
\entity{Country} \hspace*{6cm} \entity{City}
\relationshipbetween{Country}[0:n]{City}[1:1]{in}/\ncarc[arcangle=20]/(0.4)
\relationshipbetween{Country}[1:1]/\ncarc[arcangle=-18]/%
     {City}[0:1]/\ncarc[arcangle=-12]/{Capital}/\ncarc[arcangle=-30]/(0.6)

\end{document} 

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.