AppliedDatabase+ Help The ERD tool
The ERD tool
The ERD tool draws an entity-relationship diagram from a model you type. You write the entities and relationships in the book's short notation, and the crow's-foot diagram is drawn as you type, with the tables the model maps to. Use it to plan a database, to draw a diagram for a report or slides, and to try your design out: one button makes its tables in the SQL tool.
It is a window of its own, beside the book. You don't need to sign in to use it. Modules 6 and 7 of the book teach ER modelling and the notation.
On this page
- Opening the ERD tool
- 1. Type your model: the notation
- When there is a mistake
- 2. The tables it maps to
- 3. Make these tables in the SQL tool
- Saving the model and the picture
- Zoom
- Closing, Switch learner and the auto-lock
- Keys
Opening the ERD tool
- On the start screen (Who is learning?): under Tools, without signing in, press ERD tool.
- Signed in: choose ⚒ Tools in the path (under Glossary) and press Open the ERD tool on its card, or use the Tools menu.
It opens on a small example (students, courses and advisors) for you to change into your own. File ▸ Open a book model starts from one of the book's models instead: the clinic, a library, an online store, or a company. F1 shows or hides the short help at the top of the window.
1. Type your model: the notation
Write one entity per line, then one relationship per line. A line starting with # is a note and is not drawn.
An entity is its name, a colon, and its attributes:
Student: *StudentID, Name(First, Last), Email, Phone[], /Age
| Write | Means |
|---|---|
*StudentID | part of the key (underlined in the diagram) |
Name(First, Last) | a composite attribute and its parts |
Phone[] | a multivalued attribute (it becomes a table of its own) |
/Age | a derived attribute (worked out, not stored) |
A weak entity names its owner, and its partial key is marked with ~:
Dependent (weak of Employee): ~Name, Birthdate
Employee ||--o{ Dependent : has
Give it a relationship to its owner, as on the second line; without one it is drawn with a warning.
A relationship is two entities, the ends between them, a colon and a verb. Attributes of the relationship itself go in brackets after the verb:
Advisor ||--o{ Student : advises
Student }o--o{ Course : takes (Grade)
The ends say how many of each side there can be:
| Left end | Right end | Means |
|---|---|---|
|| | || | exactly one |
|o | o| | zero or one |
}| | |{ | one or many |
}o | o{ | zero or many |
So Advisor ||--o{ Student reads: each student has exactly one advisor, and an advisor advises zero or many students. Either spelling of an end is understood on either side. The same notation is shown in grey above the box while you type.
When there is a mistake
The diagram is drawn again a moment after you stop typing. The line under the box says how it went:
- Cannot draw it yet: Line 4: … is a mistake. It names the line and says what is wrong; the last good diagram stays on screen greyed out, and Make these tables is off until it is fixed.
- Drawn. Worth a look: Line 5: … is a warning. The diagram is drawn and the tables can be made, but check what it says.
The box has no line numbers, so Line n of m, under the box on the right, shows the line the cursor is on: click in the box and move up or down to find it. Notes (#) and empty lines count.
A relationship to an entity you have not written yet is drawn with a warning, not refused, so you can write the relationships first.
2. The tables it maps to
Under the box are the tables the model becomes, by the rules Module 7 teaches: each entity a table, a multivalued attribute a table of its own, a 1:N relationship a foreign key on the many side, an M:N relationship a table joining the two.
- As a list: each table on one line, its columns,
PKon the key andFK->the table a column refers to. - As CREATE TABLE: the SQL that makes them (SQLite). Tables ▸ Copy the CREATE TABLE statements copies it to paste into another program.
3. Make these tables in the SQL tool
Make these tables in the SQL tool (the button under the tables, or the Tables menu) opens the SQL tool with a new database named after your model and runs the CREATE TABLE statements there. Then add rows with INSERT or import a CSV file, and query them.
If the SQL tool already has a database with changes not saved, it asks first, because the new database takes that one's place: Yes saves it, No lets it go, Cancel leaves it as it is and no tables are made.
Saving the model and the picture
- File ▸ Save (Ctrl+S) keeps your model as a text file ending in
.er: the notation you typed, which the ERD tool opens again with Open a model file (Ctrl+O). It is plain text, so you can also open it in Notepad. The title bar shows when there are changes not saved. - Save as a picture… (the button above the diagram; File ▸ Save the diagram as a picture… in the menu) saves the diagram as a PNG picture, at twice screen size, for a document or slides, or an SVG drawing, which stays sharp at any size: choose PNG or SVG in the Save as type list. The picture is always full size, whatever the zoom. While there is a mistake it saves the last diagram drawn.
Zoom
The Zoom slider makes the diagram bigger or smaller on the screen; so does Ctrl+mouse wheel over the diagram. Fit fits the whole diagram in the space, and 100 % shows it at its own size. The line between the model and the diagram can be dragged to give either more room.
Closing, Switch learner and the auto-lock
- Closing the ERD tool, or AppliedDatabase+ itself, asks about changes not saved first; Cancel keeps it open.
- Switch learner closes the tools for the next person, asking first in the same way.
- When AppliedDatabase+ locks itself after a time without use, the tools are put away, not closed. Type your PIN and they are back as you left them. If someone else signs in, or opens a tool from the start screen, they close and changes not saved in a file are lost. Save before you walk away.
Keys
| Key | Does |
|---|---|
| Ctrl+S | Save the model |
| Ctrl+N | New model (from the small example) |
| Ctrl+O | Open a model file |
| Ctrl+mouse wheel | Zoom the diagram |
| F1 | Show or hide the help at the top of the window |