beautypg.com

Joining two or more tables – Pitney Bowes MapInfo Professional User Manual

Page 255

background image

Object A contains Entire Object
B

Object A contains Object B

Object B within Object A

Object A contains Object B

Object B within Object A

Object B entirely Within Object A

Object A intersects Object B

Object B intersects Object A

In each case, object A contains object B because the centroid of object B is inside the boundary of object
A. However, in the cases at the left and in the middle, part of object B is outside the boundary of object
A. Only in the case to the right is all of object B inside object A. Only in this case could we assert "object
A Contains Entire Object B" or "Object B Entirely Within Object A." Further, if A contains entire B, then
A contains B, and If A is entirely within B then A is within B.

MapInfo Professional can perform a simple Contains or Within comparison more rapidly than a Contains
Entire
or Entirely Within. Therefore, unless you are absolutely sure that objects are completely inside
other objects, you should use Contains and Within rather than Contains Entire or Entirely Within.

Geographic operators provide a way of joining tables. When there are no columns in the tables on which
you can base your join, you can use a geographical operator to specify the join (in the Where Condition
field). If you want to perform a query that involves both a Cities table and a States table, you can join
the tables using either of the following expressions:

1. Cities.obj within States.obj

2. States.obj contains Cities.obj

In either case, MapInfo Professional finds the cities within each state and then associates a row for a
city with the row for the state that contains it. In the same SQL Select query, you could also use aggregate
functions to count the number of cities per state or to summarize city-based data on a statewide basis.

When you have a table of counties and one of customers, where counties are polygons and customers
are points, you could specify a geographic join using either of the following geographic expressions:

1. Customer.obj within County.obj

2. County.obj contains Customer.obj

Geographic operators are particularly useful in conjunction with subselects.

The Help System contains this related topic:

Performing Subselects

Joining Two or More Tables

Typically, you store your information in several different tables. You have your own data files, and you
may also have various databases of statistical information that you purchased from MapInfo Professional.
SQL Select allows you to create relational joins so that you can bring information from these various
tables together into a single results table.

When you want to join two tables, you must determine whether one of the columns in the first table
contains values that match one of the columns in the second table. Imagine that you have a table of
counties that has demographic information--the population of people in various age ranges, ethnic groups,
and occupational categories in each county. You may also have a database containing information about
customer orders. You want to examine these two tables and see if certain kinds of orders come from
counties having certain demographic characteristics. Perhaps you want to select counties according to
combinations of orders and demographic characteristics. To do this you have to be able to join the two
tables.

Suppose the counties table contains the name of the county. Similarly, one of the columns in the order
table contains the name of the county in which the order originated. Thus, these two tables have one
field in common, the county name. MapInfo Professional can use that common field to join the two tables.

255

MapInfo Professional User Guide

Chapter 9: Selecting and Querying Data