Brain Dump

Table Diagram

Tags
modelling

Is a UML model used to design a database table.

It's [see page 5, drawn] the same way as a class except the table name is prefixed by the tag <<table>>, the first box represents table columns and the last box is used for triggers or integrity check functions.

Columns are specified just like class fields with associated types (for example string[30] represents a string with at most 30 characters). You can also prefix column names with key identifiers such as PK for primary key or FK for foreign key.

Tables can be [see page 7, linked together] using a directed association. In the case of UML database diagrams this should always be from the many to the one side, that is the arrow should go from the table with the FK to the table with the PK.

\begin{figure}
  \centering
  \begin{tikzpicture}
    \umlclass[type=table]{BookCopy}{
      PK dewyID: String[30] \\
      FK ISBN: Integer}{};
    \umlclass[type=table, x=3, y=-4]{BookTitle}{
      PK ISBN: Integer \\
      name: String[50] \\
      author: String[30]}{};
    \umlVHuniassoc[attr1=copies|1..*, attr2=title|1]{BookCopy}{BookTitle};
  \end{tikzpicture}
  \caption{Example of two linked database tables.}
\end{figure}

An SQL view can be drawn as a table with a <<view>> label.