Re: Diagrammi E-R (Entità – Relazione) – Basi di dati

#74139
robitex
Amministratore del forum
    Up
    0
    Down
    ::


    Ciao,
    a me funziona perfettamente.
    ecco il codice che ho leggermente corretto:
    `\documentclass{standalone}
    \usepackage[T1]{fontenc}
    \usepackage[utf8]{inputenc}
    \usepackage{tikz-er2}

    \usetikzlibrary{positioning}
    \usetikzlibrary{shadows}

    \tikzstyle{every entity} = [top color=white, bottom color=blue!30,
    draw=blue!50!black!100, drop shadow]
    \tikzstyle{every weak entity} = [drop shadow={shadow xshift=.7ex,
    shadow yshift=-.7ex}]\tikzstyle{every attribute} = [top color=white, bottom color=yellow!20,
    draw=yellow, node distance=5em, drop shadow]
    \tikzstyle{every relationship} = [top color=white, bottom color=red!20,
    draw=red!50!black!100, drop shadow]
    \tikzstyle{every isa} = [top color=white, bottom color=green!20,
    draw=green!50!black!100, drop shadow]

    \begin{document}
    \begin{tikzpicture}[node distance=9.4em, every edge/.style={link}]

    \node[entity] (autore) {Autore};
    \node[attribute] (id)

    {\key{ID}} edge (autore);
    \node[attribute] (ecc) [above=1em of autore]{…} edge(autore);

    \node[relationship] (creazione)

    {Creazione} edge node[auto,swap]{(0,N)} (autore);

    \node[entity] (opera)

    {Opera} edge node[auto,swap] {(0,N)} (creazione);
    \node[attribute] (id)

    {\key{ID}} edge (opera);
    \node[attribute] (ecc) [below right=1em of opera] {…} edge (opera);

    \node[relationship] (associazione) [below of=opera] {Associazione} edge node[auto,swap]{(0,N)} (opera);
    \node[entity] (file) [below of=associazione] {File} edge node[auto,swap] {(0,1)} (associazione);
    \node[attribute] (id) [above left=1em of file] {\key{ID}} edge (file);
    \node[attribute] (ecc) [above right=1em of file] {…} edge (file);

    \node[relationship] (esterna)

    {Esterna} edge node[auto,swap]{(0,N)} (file);
    \node[entity] (datir)

    {DatiRipresa} edge node[auto,swap] {(0,N)} (esterna);
    \node[attribute] (id)

    {\key{ID}} edge (datir);
    \node[attribute] (ecc) [above=1em of datir] {…} edge (datir);

    \node[relationship] (diritto) [below of=file] {Diritto} edge node[auto,swap]{(0,N)} (file);
    \node[entity] (copyright)

    {Copyright} edge node[auto,swap] {(0,1)} (diritto);
    \node[attribute] (id)

    {\key{ID}} edge (copyright);
    \node[attribute] (ecc) [below=1em of copyright] {…} edge (copyright);

    \node[relationship] (inserimento)

    {Inserimento} edge node[auto,swap]{(0,N)} (file);
    \node[entity] (cartella) [above of=inserimento] {Cartella} edge node[auto,swap] {(0,1)} (inserimento);
    \node[attribute] (id) [above=1em of cartella] {\key{ID}} edge (cartella);
    \node[attribute] (ecc) [above right=1em of cartella] {…} edge (cartella);

    \node[relationship] (condivisione)

    {Condivisione} edge node[auto,swap]{(0,N)} (cartella);

    \node[entity] (docente)

    {Docente} edge node[auto,swap] {(0,1)} (condivisione);
    \node[attribute] (matricola) [below left=2cm of docente] {\key{Matricola}} edge (docente);
    \node[attribute] (ecc) [below right=1em of docente] {…} edge (docente);

    \node[relationship] (correlazione) [above of=opera] {Correlazione} edge node[auto,swap]{(0,N)} (opera);

    \node[entity] (descrizione)

    {Descrizione} edge node[auto,swap] {(0,1)} (correlazione);
    \node[attribute] (id) [above=1em of descrizione] {\key{ID}} edge (descrizione);
    \node[attribute] (ecc) [below=1em of descrizione] {…} edge (descrizione);

    \node[relationship] (attribuzione)

    {Attribuzione} edge node[auto,swap]{(0,1)} (descrizione);
    \node[relationship] (istruzione)

    {Istruzione} edge node[auto,swap]{(0,N)} (docente);

    \node[entity] (insegnamento) [below of=istruzione] {Insegnamento} edge node[auto,swap] {(0,1)} (istruzione);
    \node[attribute] (id)

    {\key{ID}} edge (insegnamento);
    \node[attribute] (ecc)

    {…} edge (insegnamento);

    \node[relationship] (didattica) [below of=insegnamento] {Didattica} edge node[auto,swap]{(0,1)} (insegnamento);

    \node[entity] (corsodilaurea)

    {CorsoDiLaurea} edge node[auto,swap] {(0,N)} (didattica);
    \node[attribute] (codice) [above=0.5em of corsodilaurea] {\key{Codice}} edge (corsodilaurea);
    \node[attribute] (ecc) [below=0.5em of corsodilaurea] {…} edge (corsodilaurea);

    \draw[link] (inserimento) -|node [pos=0.85,auto, swap] {(0,N)} (docente)(docente) edge (docente);
    \draw[link] (attribuzione) -| node [pos=0.95,auto, swap] {(0,N)} (docente)(docente) edge (docente);

    \end{tikzpicture}
    \end{document}`
    Ed ecco il pdf già ritagliato:

    [attachment=319]t1.pdf[/attachment]
    Un saluto.
    R.

    Attachments:
    You must be logged in to view attached files.

    Go to top