mardi 2 décembre 2014

ER Cardinalities in LaTeX with TikZ package


enter image description here


Is it possible to put cardinalities in my diagram? Please help. Thank you :)



\documentclass[a4paper ,11 pt ,x11 names]{article}
%Gummi|062|=)
\usepackage{tikz}
\usepackage{listings}
\usepackage{color}
\usepackage{ulem}
\usepackage{tabu}
\usepackage{multicol}
\usepackage{setspace,calc}
\usepackage{graphicx}
\usepackage[margin=0.75in]{geometry}
\graphicspath{{graphics/}}
\usetikzlibrary{er}
\usepgflibrary{arrows}
\title{\textbf{Software Design Documentation}}
\date{}
\begin{document}
\maketitle
\textbf{Project Title: } Employee Information System

\textbf{Date: } 30 November 2014

\section{Scenario}
A certain company/organization wants to keep track of their employee records. They adapt a manual recording system for their employees. Given a big number of employee records,the HR personnel wants to have a software where he can automatically view an employee's information such as designation or department and later on would add other functionalities.

\section{Database Design}
\subsection{Relational Data Model}
\begin{tabular}{|l|l|l|l|l|l|l|l|}
\hline
\multicolumn{8}{|l|}{Employee}\\
\hline
\underline{employee\_id}&first\_name&middle\_name&last\_name&birth\_date&address&gender&\dashuline{position\_code}\\
\hline
\end{tabular}

\begin{tikzpicture}
\draw[thick,<-] (7.9,0.5) -- (7.9,0);
\draw[thick,-] (7.9,0) -- (-7.9,0);
\draw[thick,->] (-7.9,0) -- (-7.9,-0.5);
\end{tikzpicture}\\
\begin{tabular}{|l|l|l|}
\hline
\multicolumn{3}{|l|}{Position}\\
\hline
\underline{position\_code}& description & \dashuline{department\_code}\\
\hline
\end{tabular}\\

\begin{tikzpicture}
\draw[thick,<-] (3.3,0.5) -- (3.3,0);
\draw[thick,-] (3.3,0) -- (-3.3,0);
\draw[thick,->] (-3.3,0) -- (-3.3,-0.5);
\end{tikzpicture}\\
\begin{tabular}{|l|l|}
\hline
\multicolumn{2}{|l|}{Department}\\
\hline
\underline{department\_code}& dept\_name \\
\hline
\end{tabular}
\subsection{Entity-Relationship Diagram}
\tikzset{multi attribute/.style={attribute,double distance=2.5 pt}}
\tikzset{derived attribute/.style={attribute,dashed}}
\tikzset{total/.style={double distance=2.5 pt}}
\tikzset{every entity/.style={draw=orange,fill=orange!20}}
\tikzset{every attribute/.style={draw=MediumPurple1,fill=MediumPurple1!20}}
\tikzset{every relationship/.style={draw=Chartreuse2,fill=Chartreuse2!20}}
\newcommand{\key}[1]{\underline{#1}}
\begin{tikzpicture}[node distance=7.965 em]
\node[entity](employee){Employee};
\node[attribute] (pid)[left of=employee]{\key{employee\_id}} edge(employee);
\node[derived attribute](name)[above left of=employee]{name}edge(employee);
\node[attribute](middlename)[above left of=name]{middle\_name}edge(name);
\node[attribute](lastname)[above right of=name]{last\_name}edge(name);
\node[attribute](fname)[left of=name]{first\_name}edge(name);
\node[attribute](bday)[above right of=employee]{birth\_date}edge(employee);
\node[attribute](address)[below of=pid]{address}edge(employee);
\node[attribute](gender)[right of=employee]{gender}edge(employee);
\node[attribute](poscode)[below right of=gender]{\dashuline{position\_code}}edge(employee);
\node[relationship](uses)[below of=employee]{is part of}edge(employee);
\node[entity](tool)[below of=uses]{Position}edge[total](uses);
\node[attribute] (tid)[below left of=tool]{\key{position\_code}} edge(tool);
\node[attribute](desc)[left of=tool]{description}edge(tool);
\node[attribute](deptc)[below right of=tool]{\dashuline{department\_code}}edge(tool);
\node[relationship](ispart)[above right of=tool]{is part of}edge(tool);
\node[entity](dept)[right of=ispart]{Department}edge[total](ispart);
\node[attribute] (deptcode)[below of=dept]{\key{department\_code}} edge(dept);
\node[attribute](desc0)[right of=dept]{dept\_name}edge(dept);

\end{tikzpicture}
\subsection{Physical Database Structure}
\begin{tabu}{|l|l|l|l|l|l|l|l|}
\hline
\multicolumn{8}{|c|}{\textbf{Employee}}\\
\hline
\rowfont{\itshape\large}Field&Type&Length/Values&Default&Null&Attributes&Index&AI\\ \hline
ID&long int&system asigned&0&NO&unsigned&primary&YES\\ \hline
first\_name&varchar&20&&NO&&&N/A\\ \hline
middle\_name&varchar&30&&YES&&&N/A\\ \hline
last\_name&varchar&30&&NO&&&N/A\\ \hline
address&tiny text&N/A&&NO&&&N/A\\ \hline
birth\_date&date&N/A&&YES&&&- \\ \hline
gender&tiny int&&&NO&unsigned&&N/A\\ \hline
\dashuline{position\_code}&long int&&&NO&unsigned&foreign&YES\\ \hline
\end{tabu} \\
\newline \\
\begin{tabu}{|l|l|l|l|l|l|l|l|}
\hline
\multicolumn{8}{|c|}{\textbf{Position}}\\
\hline
\rowfont{\itshape\large}Field&Type&Length/Values&Default&Null&Attributes&Index&AI\\ \hline
\underline{position\_code}&long int&user assigned&0&NO&unsigned&primary&NO\\ \hline
description&varchar&20&&NO&&unique&N/A \\ \hline
\dashuline{department\_code}&long int&&&NO&unsigned&foreign&YES\\ \hline

\end{tabu} \\
\newline \\
\begin{tabu}{|l|l|l|l|l|l|l|l|}
\hline
\multicolumn{8}{|c|}{\textbf{Department}}\\
\hline
\rowfont{\itshape\large}Field&Type&Length/Values&Default&Null&Attributes&Index&AI\\ \hline
\underline{department\_code}&long int&system assigned&0&NO&unsigned&primary&-\\ \hline
dept\_name&varchar&20&&NO&&unique&N/A \\ \hline

\end{tabu}
\section{System/Program Design}
\par Run in Windows platform,the interfaces were made using Visual Studio 2008 Express Edition. It has the capability to add an employee's information and modify and delete an existing record.
\subsection{Interface Design}
\begin{figure}[h]
\centering
\includegraphics[scale=0.8]{fig5.png}
\caption{MDI Parent Window}
\label{fig:mesh2}
\includegraphics[scale=1]{fig3.png}
\caption{Employee Information Window Form}
\label{fig:mesh1}
\end{figure}
\begin{figure}[h]
\centering
\includegraphics[scale=0.8]{fig4.png}
\caption{Populating Form}
\label{fig:mesh2}
\end{figure}
\subsection{Control Functions}
\begin{figure}[h]
\centering
\includegraphics[scale=1]{fig1.png}
\caption{Employee Information Window Form}
\label{fig:mesh1}
\end{figure}
\begin{figure}[h]
\centering
\includegraphics[scale=0.55]{fig2.png}
\caption{Populating Form}
\label{fig:mesh2}
\end{figure}
\begin{figure}[h]
\centering
\includegraphics[scale=0.79]{fig0.png}
\caption{MDI Parent Window}
\label{fig:mesh2}
\end{figure}
\begin{multicols}{4}
[
Control functions of fig. 4,fig. 5 and fig. 6
Fig. 4 and Fig. 5 are children of Fig. 6 (MDI Parent Window)
]
Objects: \\
\texttt{lblEmployeeId} - 1\\
\texttt{txtEmployeeId} - 2\\
\texttt{lblName} - 3\\
\texttt{lblFName} - 4\\
\texttt{txtFName} - 4\\
\texttt{lblMidName} - 5\\
\texttt{txtMidName} - 5\\
\texttt{lblLName} - 6\\
\texttt{txtLName} - 6\\
\texttt{lblAddress} - 7\\
\texttt{txtAddress} - 8\\
\texttt{lblGender} - 9\\
\texttt{rdoMale} - 10\\
\texttt{lblMale} - 10\\
\texttt{lblFemale} - 11\\
\texttt{rdoFemale} - 11\\
\texttt{lblDateOfBirth} - 13\\
\texttt{dtpDateOfBirth} - 12\\
\texttt{lblDesignation} - 14\\
\texttt{cboDesignation} - 15\\
\texttt{btnNew} - 16\\
\texttt{btnEdit} - 17\\
\texttt{btnDelete} - 18\\
\texttt{btnClose} - 19\\
\texttt{pnlDataEntry} - 20\\
\texttt{frmDataEntry} - 21\\
\texttt{pnlBtn} - 22\\
\end{multicols}
\begin{multicols}{3}
Objects:\\
\texttt{colID} - 23\\
\texttt{colName} - 24\\
\texttt{colDesignation} - 25\\
\texttt{dbgrdQueryResult} - 26\\
\texttt{lblDesignation,\\rdoDesignation} - 27\\
\texttt{lblName, rdoName} - 28\\
\texttt{lblID, rdoID} - 29\\
\texttt{txtSearchQuery} - 30\\
\texttt{frmTableList} - 31\\
\texttt{frmChildWindow} - 32\\
\texttt{ftsmFile} - 33\\
\texttt{FtsmiFile} - 34\\
\texttt{mnubrMDI} - 35\\
\texttt{bgMDI} - 36\\
\texttt{hsbMDI} - 37\\
\texttt{vsbMDI} - 38
\end{multicols}
\end{document}




Aucun commentaire:

Enregistrer un commentaire