CPSC 343 Database Theory and Practice Fall 2004

Using Dia

Dia is a basic diagram editor tool which can be used to draw ER diagrams (among other things). You may find it more convenient than hand-drawing diagrams, particularly for larger/more complex designs or ones which go through several stages of refinement. It does have some limitations, however - it doesn't directly support EER diagrams or relationship types with degree higher than two (though there are sufficient tools to draw the necessary elements by hand).

Start Dia from a shell with the command dia. Note: it is only installed on the lab machines (Lansing 310) - if you are using a dual-boot machine elsewhere on campus, you'll need to ssh to one of the lab machines first.

When you start Dia, you'll get two windows - one (labelled "Diagram Editor") with menus and toolbars, and one (labelled something like "Diagram1.dia") with a drawing area. To access the ER-specific shapes, look for the drop-down menu towards the middle of the "Diagram Editor" window and select "ER" from the list. Several new tool buttons will be displayed - the box with an "E" is for entity types, the diamond with an "R" is for relationship types, the circle with an "A" (though it looks more like an "R") is for attributes, and the parallel vertical lines are for participation (the lines that connect entity types and relationship types). You can use the straight line tool from the regular toolbar for connectin attributes.

Dia works like most basic drawing tools - click on one of the shapes in the "Diagram Editor" window to select it, then click in the drawing window to place it. Shift-click on the tool if you want to place several of the same kind of shape in a row, otherwise it will revert to the arrow pointer (select) tool after you've placed one shape.

Click and drag a shape in the drawing window to move it around; double-click to set its properties (including its name, weak vs. strong entity, key attribute, multivalued attribute, constraints, etc). When drawing connecting lines, make sure to connect them to one of the lightly-marked spots on the boundary of the shape you are connecting to - if the connector is colored red, you've succeeded. If the line is not properly connected, it won't be moved automatically should you move what it is connected to.

Right-click in the drawing window for a menu of all sorts of things, including "Save" and "Print" (under "File").

Valid HTML 4.01!