Drawings and Tables

This topic gives specific examples of interacting with drawing tables, to show how the association between drawings and database tables discussed in the Drawings and Databases topic works in practice.

 

Recall that every drawing in Manifold has a database table tied to it. Each object in the drawing corresponds to a record (one row) in the database table. Every field in the database will be a column in the database table. A drawing's table will have at least one field, the object ID field, which provides an identification number for each object in the drawing. The object ID is a unique number generated by Manifold when the drawing is created or imported. Tables can contain other fields as well. For example, a drawing showing cities as points could have a Name and Population field in the table that gives the name of each city and its population.

 

A drawing's table can be used like any database table. For example, it can be used to form relationships with other tables, including tables that are saved outside of Manifold in external database providers.

 

When drawings are imported from a GIS format that saves both object and database table information the new drawing that appears in the project will automatically have a table created that is populated with data.

 

If we import a drawing from a format, such as AutoCAD DXF, that does not save database table information, or if we create a new, blank drawing in a project, Manifold will automatically create both the drawing and a table to go with that drawing.

 

Suppose we create a new drawing in the project and name it Drawing1.

 

images\sc_dt_00.gif

 

By default, the minimum field in drawing's table is an ID field that gives the object ID number of each object in the drawing. ID numbers are assigned on a unique basis for each new object created or imported into any drawing. All ID numbers are guaranteed unique.

 

images\sc_dt_01.gif

 

We can open the drawing in a drawing window and also open the drawing's table in a table window. When a new drawing is created there are no objects in the drawing or associated records in the table. To fit conveniently as screen shots within this documentation, both the drawing window and table window will be shown as relatively small windows.

 

Note that the ID field cells in the table are shown using the default light gray color that indicates read-only cells. The ID field in a drawing's table may not be edited since the ID is the hard-wired connection between each object in a drawing and the record in the drawing's table that corresponds to that object.

 

Drawings and their Tables are Synchronized

 

For drawings and their tables, any changes in one component are immediately updated in the other component. Adding or deleting an object in the drawing will add or delete the associated record in the table.

 

images\sc_dt_02.gif

 

If we use the Tools toolbar to add an area to the drawing a record appears for it automatically in the table as well.

 

Note that the ID field cells in the table are shown using the default light gray color that indicates read-only cells. The ID field in a drawing's table may not be edited since the ID is the hard-wired connection between each object in a drawing and the record in the drawing's table that corresponds to that object.

 

Tables usually show more interesting data than Object IDs; however, as the simplest possible example of a drawing's table we will show just the Object ID field.

 

images\sc_dt_03.gif

 

Creating another area in the drawing adds another record in the table as well.

 

images\sc_dt_04.gif

 

Creating a third area adds a third record, shown with an ID of 3. [Note: It is very rare that we would ever see such low numbers in sequence as object IDs since we normally work with large, complex maps where objects are imported, deleted, created and so on in potentially large numbers. Object IDs are therefore more normally semi-random numbers and not neat, small numbers in sequence.]

 

images\sc_dt_05.gif

 

The screen shot above shows our drawing and table after we have used the Tools toolbar to add several points. See the Adding Points, Lines and Areas topic for information on how to add points to a drawing.

 

images\sc_dt_06.gif

 

Using the Tools toolbar we can add two lines as well. Note that two more records have appeared in the table.

 

Selections are Synchronized

 

A drawing and the drawing's table share a single selection since both the drawing and the table are just two different ways of seeing the same objects. Any changes to that selection in either the drawing or the drawing's table will immediately be updated in the other.

 

images\sc_dt_07.gif

 

Any Selection made in the drawing will simultaneously appear in the table with a change in background color of the associated records. Selected records will have a faint red background color by default. The example above shows we have selected two areas, a line and a point in the lower half of the drawing.

 

images\sc_dt_08.gif

 

If we change the selection by selecting two points and an area in the upper part of the drawing the selection shown in the table will immediately be updated to match.

 

images\sc_dt_09.gif

 

The Selections pane shows the same set of saved selections for both drawings and their tables. The example above shows the Selections pane opened and moved into position so it can participate in our screen shots. We have selected the three areas and have saved them as a saved selection called Areas.

 

images\sc_dt_10.gif

 

We can select the two lines and save them as a saved selection called Lines. [Note: there is nothing magical about our choice of the word Lines for the name of this saved selection other than the mnemonic value to remind us at a glance of what comprises that selection. We don't have to use the word Lines to name a saved selection that consists of lines. We could just as easily call it Fred or Bob or Points if we wanted to choose a confusing name.]

 

images\sc_dt_11.gif

 

At any time, we can click into the Selections pane and get a Preview of any of the saved selections by pushing in the Preview button in the Selections pane. When the Preview button is pushed in he highlighted saved selection will be shown in blue preview color in both the drawing and in the table. If a record is both in the current selection and in the preview it will be shown in a color mid-way between the red selection color and the blue preview color. [Manifold will automatically interpolate between whatever selection color and preview color we specify in the Tools - Options dialog].

 

images\sc_dt_12.gif

 

images\btn_selcmd_add.gif We can use the selection command buttons to combine a saved selection with the existing selection. In the illustration above we have pushed out the Preview button, clicked on the Areas saved selection and then pressed the Select Add button in the Selections pane toolbar. This adds the areas to the current selection for a selection that consists of both lines and areas.

 

images\sc_dt_13.gif

 

Deletions are synchronized as well. Suppose we select just the areas and choose Edit - Delete.

 

images\sc_dt_14.gif

 

The areas will be deleted in the drawing and their associated records will be deleted in the table as well.

 

A Drawing's Table Cannot Add Objects to the Drawing

 

We cannot add objects to a drawing by adding records to the drawing's table. The reason is that the information seen in the table is only part of the information that defines the object. An object in a drawing is defined by the geometric coordinates that specify its location and shape. These are not visible or part of the table: they are part of the data within the drawing itself.

 

Deleting an object in a drawing will delete the object's record in the drawing's table. Deleting a record in a drawing's table will delete the associated object in the drawing.

 

Note: It is possible to create a linked drawing that is created based on the contents of a table, either using geocoded tables or using geometry fields in tables. In that case, the table data controls both the linked drawing and the linked drawing's own table. If a record is added to the source table then a new point will be created in the linked drawing and a new record will appear in the linked drawing's own table. However, even in that case we can't add objects ito the linked drawing by adding records to the linked drawing's own table.

 

Attaching External Tables to a Drawing's Table

 

So far we've seen that every drawing is linked to a table and that the drawing's table is created within the project at the same time the drawing is created. All such tables exist entirely within the project. Sometimes we would like to link our drawing's table to an external table that is linked into the project.

 

To do this we use relations with linked tables. See the Attaching External Tables to Drawings topic.

 

The Info Pane

 

A convenient way of seeing data from drawing tables one record/object at a time is to use the Info pane to step through data one object at a time.

 

Tech Tip

 

The illustrations above show the first object created having an ID of 1. Although the first object created in a new drawing may well have an ID of 1, this is not guaranteed. Object IDs are unique within a given .map file but are not guaranteed to begin with 1. It is therefore entirely possible to create a new drawing and to then create a new object in that drawing that has an object ID of, say, 5. Even in the case of the first drawing in a completely blank drawing it is still possible not to get an object ID of 1 for the first object created.

 

See Also

 

The Query toolbar is a fast way to select objects in drawings using the data values they contain.