SlideShare a Scribd company logo
1 of 122
Every connection is a new opportunity™
MapInfo User Group UK & Ireland
Working with MapInfo Professional
and Spatial Databases
Peter Horsbøll Møller
GIS/LI Pre-Sales Specialist
June, 2014
Every connection is a new opportunity™
Agenda
How to setup a spatial database to be used by MapInfo
Professional 12.0
How to work with a spatial database from MapInfo
Professional 12.0
How to take advantage of a spatial database in general
Every connection is a new opportunity™
A few words about myself
Live in Denmark with my family
Worked with the largest Danish partner from 1996 until 2008
where I were developing MapBasic applications, doing
training and support.
Worked on a number of project using Oracle and SQL Server
with SpatialWare (R.I.P.)
Have been working with Pitney Bowes Software for the last 6
years as a pre-sales specialist
Moderator and an active member on the MapInfo-L
Feel free to connect: dk.linkedin.com/in/peterhorsbollmoller/
Every connection is a new opportunity™
The tools
MapInfo Professional 12.0, no introduction required
EasyLoader, our tool for uploading tables to spatial
databases
SQL Server 2008, the spatial database
SQL Server Management Studio, the management
interface to the database
Every connection is a new opportunity™
Every connection is a new opportunity™
DAY 1
Every connection is a new opportunity™
Creating database, login and users
Every connection is a new opportunity™
A few words on login and users
In most cases you will use Windwos Authentication and
use the Windows usernames (and Active Directory)
This let’s you assign permissions to a AD group or a single
Windows user
The SQL Server users can be used for giving a certain
application access
Every connection is a new opportunity™
Creating database, login and users
Every connection is a new opportunity™
Schemas
Every connection is a new opportunity™
What is a schema in SQL Server?
A schema in SQL Server is a way to organise for instance
your tables
Schemaes also lets you assign permission to a number of
tables, by assigning permissions to the schema in stead
of directly to the tables
You can use Schemaes as a way of organising your tables
instead of using several databases
When you access the database from MapInfo Professional
you can in the Open dialog choose what Schema you
want to browse. In this way you can limit the number of
tables shown in the dialog.
Every connection is a new opportunity™
Creating a new schema
Every connection is a new opportunity™
Creating a ODBC Data source
Data
Data
Every connection is a new opportunity™
Creating a SQL Server 2008 data source
Data sources can be created manually or in a centralised
way
They can be stored in files or in the registry
For MapInfo Professional 32bit, the ODBC data source
must be created as 32bit data sources
For SQL Server 2008 you should use:
”SQL Server Native Client 10.0” driver
For SQL Server 2012 and Windows7 you should use:
”SQL Server Native Client 11.0” driver
Every connection is a new opportunity™
MARS connection
Multiple Active Result Sets (MARS)
Supported
 MapInfo Professional 10.5.2
 SQLServer 2005, 2008 & 2012
MapInfo Professional will by default add this string to the connection
string:
 “MARS Connection=true”
Improved performance when access a table, especially using Live with
Cache. Access can be 5-10 times faster.
Every connection is a new opportunity™
Creating a SQL Server 2008 data source
Every connection is a new opportunity™
The MapInfo Map Catalog
Every connection is a new opportunity™
Map Catalog
The Map Catalog (MapInfo.MapInfo_MapCatalog) describes spatial
tables in the database with values like:
 Kind of spatial table, for example. XY, SpatialWare, Oracle, SQL
Server, PostgreSQL/PostGIS, etc.
 Coordinate system
 Data bounds
 Symbol, default and per row
 Default view
• The Map Catalog must exist once in the
databases holding spatial data, that is to be
accessed by MapInfo Professional
Every connection is a new opportunity™
Map Catalog – Spatial type
Data storage
 1 : MapInfo Code, XY with MapInfo key (3 columns)
 4 : XY stored in two columns
 13: Oracle Spatial
 14: MapInfo SpatialWare for MS SQL Server
 17: SQL Server 2008 Geometry
 18: SQL Server 2008 Geography
 19: PostgreSQL/PostGIS
Object types
 .0: Only Points
 .1: Only Lines/Polylines
 .2: Only Regions/Polygons
 .3: Mixture of object types is possible
Every connection is a new opportunity™
Creating the Map Catalog
You can create the Map Catalog using EasyLoader, directly
in the database using SQL or you can use the DBMS
Catalog tool
The user creating the Map Catalog using EasyLoader
needs a sysadmin server role.
If you create the Map Catalog using EasyLoader, make
sure that you close all connections to the database
before creating the Map Catalog. If not you might have
issues using the Per Row Style option when making
DBMS tables mappable.
Every connection is a new opportunity™
Creating the Map Catalog – EasyLoader
Every connection is a new opportunity™
Tables
Every connection is a new opportunity™
Creating tables
You can create tables manually thru the Management
Studio
Or thru MapInfo Professional
If you use MapInfo Professional it will do a number of
things automatically for you, like adding the table to the
MapCatalog, creating spatial index and primary index.
Every connection is a new opportunity™
Creating tables – data types
Exact numerics
 Bigint (MapInfo type: Float)
– -9.223.372.036.854.775.808 – 9.223.372.036.854.775.807
 Int (MapInfo type: Integer)
– -2.147.483.648 – 2.147.483.647
 SmallInt (MapInfo type: SmallInt)
– -32.768 – 32.767
 TinyInt (MapInfo type: SmallInt)
– 0 – 255
 Bit (MapInfo type: Logical)
– 1 or 0
 Decimal / numerical (MapInfo type: Decimal)
– -10^38 +1 – 10^38 –1
Every connection is a new opportunity™
Creating tables – data types
Approximate Numerics
 Float (MapInfo type: Float)
 Real (MapInfo type: Float)
Date and time
 Datetime (MapInfo type: DateTime)
– From January 1, 1753, through December 31, 9999, with an
accuracy of three-hundredths of a second, or 3,33
milliseconds
 Date (MapInfo type: Date)
– From January 1, 1 A.D. through December 31, 9999 A.D.
Every connection is a new opportunity™
Creating tables – data types
Character strings
 Char (MapInfo type: Char)
– Fixed-length non-Unicode data, max. 8.000 characters
 VarChar (MapInfo type: Char)
– Variable-length non-Unicode data, max. 8.000 characters
 Text (MapInfo type: Char)
– Variable-length non-Unicode data, max. 2,147,483,647
characters
Note: Character columns longer than 254 will be made read-only when
opened in MapInfo Professional and they will only show the first 254
characters
Every connection is a new opportunity™
Creating tables – data types
Spatial types
 Geometry (MapInfo type: Object)
– Does require the table to be registered in the MapCatalog,
more on this later
 Geography (MapInfo type: Object)
– Does require the table to be registered in the MapCatalog,
more on this later
Every connection is a new opportunity™
Creating a table - naming
Consider only using the characters A – Z and the numbers 0 – 9 and
underscores (_) when naming your tables
Use the same naming convention for columns
SQL Server does however support national characters, spaces and
some other special characters.
SQL Server has a list of reserved words that can’t be used as table or
column names, see the complete list here:
 http://technet.microsoft.com/en-us/library/ms189822.aspx
If the tables must be used from MapInfo Professional it’s recommended
to limit the names to 31 characters
Also note that the columns for table and column names in the
MapCatalog is limited to 32 characters. If you want to use longer
names, you need to extend these
Every connection is a new opportunity™
Creating tables – considerations
Avoid the unicode column types (nchar, nvarchar, ntext) as MapInfo
Professional can’t edit these
Avoid creating character string column wider than 254 as MapInfo
Professional can’t edit these
Consider naming your Primary key column MI_PRINX. MapInfo
Professional will use this as the primary key in views
Consider adding Identity columns to all your table for the Primary Index
column. This will automatically update this column with unique
values when inserting new records (similar to AutoNumber in MS
Access)
Every connection is a new opportunity™
Creating tables thru Management Studio
Every connection is a new opportunity™
Create a new table thru MapInfo Pro
You can create a new table in SQL Server directly
from MapInfo Professional.
MapInfo Professional will automatically add this
new table to the MapInfo MapCatalog in the
database.
MapInfo Professional will also guide you thru the
choises when making the table mappable and
adding a primary index column to the table
Every connection is a new opportunity™
Creating tables thru MapInfo Pro
Every connection is a new opportunity™
Uploading tables to SQL Server
Every connection is a new opportunity™
EasyLoader
EasyLoader …
… is provided with MapInfo Professional. It can also be
downloaded from our website
… is a standalone application that can run outside of
MapInfo Professional
… is a Windows application but it can connect to databases
running on other operating systems
… can be run in batch mode
 command prompt
 bat file
 program
Every connection is a new opportunity™
Uploading thru EasyLoader
Every connection is a new opportunity™
Using EasyLoader as a batch uploader
Samples on how to pass parameters to EasyLoader for doing batch uploads
Upload a single table
 “C:ProgramMapInfoProfessionalToolseasyloader.exe”
/B dbo /E /F c:ezload.log /G /K /P R
/S DSN=GIS;UID=AdminUK;PWD=Admin
/Q /Y MI_STYLE
/T C:MapsAddresses.tab;Addresses
Upload multiple tables using a text file
 “C:ProgramMapInfoProfessionalToolseasyloader.exe”
/B MAPS /E /F c:ezload.log /G /K /P R
/S DSN=GIS;UID=AdminUK;PWD=Admin
/Q /Y MI_STYLE
/L C:tabfiles.txt
Makes it easy to rerun the uploads!
Every connection is a new opportunity™
Uploading thru EasyLoader - batchmode
Every connection is a new opportunity™
Upload using Save as
Within MapInfo Professional you can save your table
directly to the data using File > Save Copy as…
Make sure you select the database connection in the file
type drop down list
Enter the name of the server table
Enter the name of the tab file (using Live connection)
• Will automatically add:
– MI_PRINX
– MI_STYLE
Every connection is a new opportunity™
MapBasic syntax for Save as
The MapBasic syntax for saving table to a database looks
like this:
Commit Table AV97_W
As "C:DBMSBuildings.tab"
Type ODBC Connection 1
Table """dbo""."“Buildings"""
Type SQLServerSpatial Geometry
ConvertDateTime ON Interactive
Some of the parameters are optional
Every connection is a new opportunity™
Uploading thru Save as
Every connection is a new opportunity™
Spatial errors
Certain objects from MapInfo tabellens can result in errors. It can be a
good idea to run queries like these to find obvious issues:
Regions with an area of less than 1 sq meter
Select * From MY_TABLE
Where Str$(ObjectInfo(OBJ, 1)) In (”7”, ”8”, ”9”)
And CartesianArea(OBJ, ”sq m”) < 1
Into __POSSIBLE_ISSUES_REGIONS
Lines with a length of less than 1 meter
Select * From MY_TABLE
Where Str$(ObjectInfo(OBJ, 1)) In (”3”, ”4”)
And CartesianObjectLen(OBJ, ”m”) < 1
Into __POSSIBLE_ISSUES_LINES
Every connection is a new opportunity™
Opening tables into MapInfo Professional
Every connection is a new opportunity™
Opening a remote table
Select File > Open
Click on Open DBMS Connection or select the open
connection in the Files of Type dropdown list
Select the schema
Check the table(s) to open
Select Linked or Live (with Cache)
Every connection is a new opportunity™
Opening DBMS tables into MapInfo Pro
Every connection is a new opportunity™
Reopening a remote table
It’s only the first time you open a DBMS table, that you need to specify
which data to open
Afterwards you can reopen this table by opening the tab file
The tab file contains all the necessary information
 Table structure
 Connection information
 Can also hold the Username and Password
If the table was opened as ”Linked”, you may want to refresh the data.
If the table was opened as ”Live”, MapInfo will read the latest data from
the database
Every connection is a new opportunity™
Meta data section - Linked
!table
!version 400
!charset WindowsLatin1
Definition Table
Type LINKED Charset "WindowsLatin1"
Fields 4
MI_PRINX Integer ReadOnly ;
PLACENAME Char (50) ;
DESCRIPTION Char (250) ;
TYPE Char (20) ;
begin_metadata
"DATALINK" = ""
"DATALINKConnectionString" = "DSN=GIS2;Description=SQL Server
2008 GIS database;UID=AdminUser;APP=MapInfo
Professional®;WSID=DKMP12948"
"DATALINKQuery" = "select ""MI_PRINX"", ""PLACENAME"",
""DESCRIPTION"", ""TYPE"", ""OBJECT"" from
""GIS"".""dbo"".""PointsOfInterest"""
"IsReadOnly" = "FALSE"
end_metadata
Every connection is a new opportunity™
Meta data section - Live
!table
!version 500
!charset WindowsLatin1
Definition Table
Type ODBC
begin_metadata
"IsReadOnly" = "FALSE"
"DATALINK" = ""
"DATALINKQuery" = "Select * From
""GIS"".""dbo"".""PointsOfInterest"""
"DATALINKConnectionString" = "DSN=GIS2;Description=SQL Server
2008 GIS database;UID=AdminUser;APP=MapInfo
Professional®;WSID=DKMP12948"
"DATALINKToolKit" = "ODBC"
"CACHE" = "ON"
"MBRSEARCH" = "ON"
end_metadata
Every connection is a new opportunity™
MapInfo Pro: Linked vs Live tables
Every connection is a new opportunity™
Linked
• Data is copied to the MapInfo table the when you create the linked
table and when you refresh it
• Access to the database is only needed when saving or refreshing ->
working offline and long transactions are built in so your data is
locally available
• Speed is as fast as local data after download
• Data can be accessed read-only without a primary key
• Using a query to get just the data you need, will speed up download
time. Queries are set when you create the linked table via the Row,
Column or Expert dialogs
• Data is downloaded to the same location as the .TAB file
• Duplicate data
Every connection is a new opportunity™
Live with/without cache
• First time opening a table may be faster – depending on the zoom of
your map window
• One “view entire layer” or zoom out to the entire view will download
the whole table
• Data must have a primary key
• You always need access to the database
Every connection is a new opportunity™
Live without cache
• MapInfo Professional “always” reads directly from the database
• Every draw, browse, select click which can negatively affect
performance.
• Data is reread from the server on every access
Every connection is a new opportunity™
Live with Cache
• Uses a temporary cache
 Since 9.5.1
– MapInfo table stored in a temporary MapInfo table.
– The cache is progressive, as you pan, zoom out or have
more than one map window of the same data, the cache
grows
• Data is cached as used in the map, so subsequent access to the
same data will be quicker
• The cache is cleared when the table closes
Every connection is a new opportunity™
Conclusions
Only use LIVE WITHOUT CACHE when
 The data is highly volatile (changing minute to minute or even
sooner)
Use LIVE WITH CACHE when
 The table data is very large and it is not feasible to create a filter
query to download less data
 Your data changes regulary, for instance every day or during the
day
Use LINKED when
 Your data is static or only changes ones a day/week/month/year
 Performance is important
 You want to do advanced spatial analysis on the data in
MapInfo Pro
Every connection is a new opportunity™
Conclusions
• If you have a small data size in your table, it will probably not matter
if you choose Live or Linked
• Using a LIVE table ensures that users log onto the database before
they can access the data
• If you use live tables we recommend that you access your data thru
a workspace with zoom levels set on the live table to prevent
downloading unnecessary data
• The support for MARS has improved the use of live with cache
Every connection is a new opportunity™
DAY 2
Every connection is a new opportunity™
Querying
Every connection is a new opportunity™
When is the query performed?
For Linked tables query is performed when
 the table is opened the first time
 the table is refreshed.
For Live with cache tables query is performed when
 the table is added to a map
 you zoom or pan in the map
For Live without cache query is performed when
 the table is added to a map
 you zoom or pan in the map
 you refresh the map
 …
Every connection is a new opportunity™
Row filtering
You can specify which records to retrieve from the database by attributes
And by geography
Value of Current_Mapper and Selection are static and not updated when the
table is refreshed.
“Selection” only available when a selection
is active
“Current_Mapper” only available when a
map is active
“Object” is only available for mappable
tables
“Like” and “not like” only available for text
columns
Do not use ”” around text values!
Every connection is a new opportunity™
Querying - Expert
Write your own SQL statement
Syntax depends on the SQL dialect of the database
MapInfo Professional will “translate” certain expression when passing
the query to the database:
 Object
 Within
 Selection
 Current_Mapper
 …
You can save and open queries using the two buttons on the right side
of the dialog
Every connection is a new opportunity™
Metadata of a spatial query
!table
!version 650
!charset WindowsLatin1
Definition Table
Type LINKED Charset "WindowsLatin1"
Fields 3
MI_PRINX Integer ReadOnly ;
NAME Char (50) ;
TYPE Char (50) ;
begin_metadata
"IsReadOnly" = "FALSE“
"DATALINK" = ""
"DATALINKConnectionString" = "DSN=GIS;MARS_Connection=Yes"
"DATALINKQuery" = "select ""MI_PRINX"", ""NAME"", ""TYPE"", ""OBJECT""
from ""GIS"".""dbo"".""POI"" where (OBJECT within Rectangle(
628163.45078508,6112409.85175394,720526.19639343,6186305.28363101))"
"DATALINKSpatialObj" = "ST_Spatial(HG_Box(ST_Point(628163.451003735300,
6186305.285449981700),ST_Point(720526.200186016970,6112409.856650807900)
) ,ST_Point(674344.821471954000,6149357.566051412400))"
end_metadata
Every connection is a new opportunity™
Editing tables from SQL Server
Every connection is a new opportunity™
Editing
The remote table must contain a primary unique index
 In a view this column should be named MI_PRINX
You can edit the data with every tool available in MapInfo Professional
When editing coordinates of a XY-coordinate table, the coordinates are
updated in the columns with the X and Y coordinates in the
database table
When changing the style on a table that has ”per row style” enabled the
new style will be stored in the column holding the style. On other
tables the change of style will be dismissed when you refresh the
table
Every connection is a new opportunity™
Editing – by multiple users
If multiple users are editing the same table in SQL Server,
they must not access this database table thru the same
physical file on disk.
If they do only one user will be able to edit the table at a
time – the others will be prevented from editing as soon
as the first users starts editing.
They must access the database table thru their own (local)
copy of a MapInfo table, can be linked as well as live
Every connection is a new opportunity™
Saving
Click Save Table to save the pending edits to the DBMS table
When saving the edits to the database, MapInfo checks if the records
you have changed, have been changed in the database since you
accessed these. If so, a dialog appears asking you to solve the
conflict
If you are using a linked table, MI Pro will ask if you want to refresh the
table as well. I would recommend that you say yes
Saving changes offline (only for Linked tables) can be done by closing
the table. MapInfo will ask how to store the pending edits:
 Save Changes to MapInfo Table
 Save Changed to Server
 Discard Changes
Every connection is a new opportunity™
Editing
Every connection is a new opportunity™
Conflict resolution in MapInfo Pro
If a table has been changed in the database when being saved,
MapInfo will prompt the user with a Conflict Resolution dialog like
this one
Here you can see what has been changed.
You can see the original server version, the current MapInfo version
and the current server version
You can decide what to keep and what to change – column by column
• Here you can see that column KATEGORI has
been changed, and how.
• You can also see that the geometry (object)
has been changed. Harder to see how that has
changed
Every connection is a new opportunity™
Editing – conflict resolution
Every connection is a new opportunity™
Refreshing linked tables
Every connection is a new opportunity™
Refreshing
Reloading data from the database can be done with Table >
Maintenance > Refresh DBMS Table...
Refreshing a DBMS table
 Checks the database for changes
 Reapplies the query condition. Note that the query conditions
are static.
 If you have specified to filter using the current map or current
selection, this filter will always be applied to the table. To specify
a different map extent, you have to reopen the table from the
database.
MapBasic syntax is: Server Refresh name_of_table
Every connection is a new opportunity™
Refreshing DBMS tables thru a
workspace
!Workspace
!Version 950
!Charset WindowsLatin1
Dim nConn As Integer
nConn = Server_Connect( "ODBC", "DSN=GIS;UID=EditUser;PWD=Edit" )
Print “Connection opened as no: " + nConn
Print “Now opening tables..."
Open Table "D:3. demodbmsBuildings.tab" Interactive
Map From Buildings
Print “Refreshing the DBMS tables..."
Server Refresh Buildings
Close Table Buildings
Print “We are done!"
Server nConn Disconnect
Undim nConn
Every connection is a new opportunity™
Files versus database
Every connection is a new opportunity™
Files versus database
The are a number of differences between MapInfo’s flat tab files and
keeping the data in SQL Server
 Several applications can access the data, not only MapInfo
software
 Multiple user editing
 The entire database stuff: relations, views, security, triggers etc.
When data is kept in the flat MapInfo tab files, the application needs to
handle things like
 timestamp on change
 keeping historic versions
 etc.
When the data is in the database, the database can manage these
things.
Every connection is a new opportunity™
Introduction to joins
Every connection is a new opportunity™
Inner Join
ID NAME LASTNAME
1 Peter 1
2 Paul 3
3 Mary 5
4 Ann 2
ID LASTNAME
1 Møller
2 Smith
3 McCartney
4 Probert
ID NAME LASTNAME
1 Peter Møller
2 Paul McCartney
4 Ann Smith
SELECT P.ID, P.NAME, L.LASTNAME
FROM dbo.PERSONS AS P
INNER JOIN dbo.LASTNAMES AS L
ON (P.LASTNAME = L.ID)
Every connection is a new opportunity™
Left Outer Join
ID NAME LASTNAME
1 Peter 1
2 Paul 3
3 Mary 5
4 Ann 2
ID LASTNAME
1 Møller
2 Smith
3 McCartney
4 Probert
ID NAME LASTNAME
1 Peter Møller
2 Paul McCartney
3 Mary <NULL>
4 Ann Smith
SELECT P.ID, P.NAME, L.LASTNAME
FROM dbo.PERSONS AS P
LEFT OUTER JOIN dbo.LASTNAMES AS L
ON (P.LASTNAME = L.ID)
Every connection is a new opportunity™
Cross Join
ID NAME LASTNAME
1 Peter 1
2 Paul 3
3 Mary 5
4 Ann 2
ID LASTNAME
1 Møller
2 Smith
3 McCartney
4 Probert
ID NAME LASTNAME
1 Peter Møller
2 Paul McCartney
4 Ann Smith
SELECT P.ID, P.NAME, L.LASTNAME
FROM dbo.PERSONS AS P
CROSS JOIN dbo.LASTNAMES AS L
WHERE (P.LASTNAME = L.ID)
Note: A Cross Join without condition will join every
record in the first table with every record in the
other table
Every connection is a new opportunity™
Some (spatial) join types of SQL Server
Inner Join
SELECT R.*, P.PLACENAME
FROM dbo.ROADS AS R INNER JOIN dbo.PLACES AS P
ON (R.SP_GEOMETRY.STIntersects(P.SP_GEOMETRY) = 1)
Left Outer Join
SELECT R.*, P.PLACENAME
FROM dbo.ROADS AS R LEFT OUTER JOIN dbo.PLACES AS P
ON (R.SP_GEOMETRY.STIntersects(P.SP_GEOMETRY) = 1)
Cross Join
SELECT R.*, P.PLACENAME
FROM dbo.ROADS AS R CROSS JOIN dbo.PLACES AS P
WHERE (R.SP_GEOMETRY.STIntersects(P.SP_GEOMETRY) = 1)
Every connection is a new opportunity™
Creating spatial joins
Every connection is a new opportunity™
Introduction to Geometry type
Every connection is a new opportunity™
Geometry vs Geography
The geometry data type supports planar, or Euclidean (flat-earth),
data. The geometry data type conforms to the Open Geospatial
Consortium (OGC) Simple Features for SQL Specification version
1.1.0.
In addition, SQL Server supports the geography data type, which
stores ellipsoidal (round-earth) data, such as GPS latitude and
longitude coordinates.
Read more:
• http://msdn.microsoft.com/en-us/library/bb964711.aspx
Point
Line/Pline
Region
Region
Pline
Multi
Point
Collection
Every connection is a new opportunity™
Geometry OGC methods
• STArea
• STAsBinary
• STAsText
• STBoundary
• STBuffer
• STCentroid
• STContains
• STConvexHull
• STCrosses
• STDifference
• STDimension
• STDisjoint
• STDistance
• STEndpoint
• STEnvelope
• STEquals
• STExteriorRing
• STGeometryN
• STGeometryType
• STInteriorRingN
• STIntersection
• STIntersects
• STIsClosed
• STIsEmpty
• STIsRing
• STIsSimple
• STIsValid
• STLength
• STNumGeometries
• STNumInteriorRing
• STNumPoints
• STOverlaps
• STPointN
• STPointOnSurface
• STRelate
• STSrid
• STStartPoint
• STSymDifference
• STTouches
• STUnion
• STWithin
• STX
• STY
They are all case sensitive!!!
Every connection is a new opportunity™
Invalid geometries
Find records with invalid geometries
Select * From dbo.MYTABLE
Where SP_Geometri.STIsValid() = 0
Fix records with invalide geometries
– pure magic!? Or not!?
Update dbo.MYTABLE
Set SP_Geometri = SP_Geometri.MakeValid()
Every connection is a new opportunity™
Coordinate systems – EPSG codes
Querying EPSG codes for a table, også known as SRID:
select distinct SP_GEOMETRY.STSrid from dbo.MYTABLE
If it isn’t ”right”, you can change it using this statement:
Update dbo.MYTABLE Set SP_GEOMETRY.STSrid = 25832
But do not change the EPSG code to one of a completely different coordinate system.
But there does exist coordinate systems with different EPSG codes!:
"UTM Zone 32 Euref89p25832“
, 8, 115, 7, 9.0, 0, 0.9996, 500000, 0
"ETRS TM Zone 32, Northern Hemisphere (ETRS89)p3044“
, 8, 115, 7, 9, 0, 0.9996, 500000, 0
Note that EasyLoader has its own projection file!!
Every connection is a new opportunity™
Spatial SQL samples
Adding a column with the area
Select *, SP_GEOMETRY.STArea() As Area
From dbo.PLACES
Adding a column with the length
Select *, SP_GEOMETRY.STLength() As Length
From dbo.ROADS
Every connection is a new opportunity™
Spatial SQL samples
Finding municipalities and their neighbours
Select t1.NAME, t2.NAME
From dbo.MUNICIPALITIES t1, dbo.MUNICIPALITIES t2
Where (t1.SP_GEOMETRY.STTouches(t2.SP_GEOMETRY) = 1
Or t1.SP_GEOMETRY.STIntersects(t2.SP_GEOMETRY) = 1)
And t1.MI_PRINX <> t2.MI_PRINX
Order By t1.NAME
Every connection is a new opportunity™
Spatial SQL samples
Adding city name to only those roads, that intersects a city
Select R.*, P.PLACENAME
FROM dbo.ROADS AS R
CROSS JOIN dbo.PLACES AS P
WHERE (R.SP_GEOMETRY.STIntersects(P.SP_GEOMETRY) = 1)
Adding city name to the roads, that intersects a city and NULL to the other
roads
Select R.*, P.PLACENAME
FROM dbo.ROADS AS R
LEFT OUTER JOIN dbo.PLACES AS P
On (R.SP_GEOMETRY.STIntersects(P.SP_GEOMETRY) = 1)
Every connection is a new opportunity™
DAY 3
Every connection is a new opportunity™
Creating views in SQL Server
Every connection is a new opportunity™
What is a view?
Et view can be seen as a way to look at your data
With a view you can
• limit the number of columns and/or records you want to see, for
instance to separate a table of roads into different road classes
• merge multiple columns to one column, for instance merge road
name and house no to a address column
• enrich one table with data from another table, for isntance by
transfering the postal area name from a postal table to a table with
addresses. You often do this by joining these tables. This can be
done thru alphanumerical or spatial attributes
• combine multiple tables into one.
Every connection is a new opportunity™
Creating views in SQL Server – mappable
If the views must be mappable from
within MapInfo Pro, you need to make
the view mappable
You can also manually add the view to
the MapInfo_MapCatalog – if you
know all the parameters
Or you can copy the record of the base
table in the Map Catalog, insert the
copy and change the name of the
table to the name of the view
Every connection is a new opportunity™
Creating views
Every connection is a new opportunity™
Making a DBMS table mappable
Every connection is a new opportunity™
Making a DBMS table mappable
This will add a record of that table to the MapInfo
MapCatalog specifying how MapInfo Professional should
show this table in a map
You need to specify where to get the spatial data, what
coordinate system to use and what symbology to apply
to the spatial data when displaying it in MapInfo
Professional
You can do this thru Table > Maintenance > Make DBMS
Table Mappable in MapInfo Professional
or by copying and modifying a record in the MapCatalog
Every connection is a new opportunity™
Making DBMS tables mappable
Every connection is a new opportunity™
A view that merges tables
The statement below should be run from a Query-vindue – not thru
View > Create New:
Create View dbo.viewAddressesUnion As
SELECT *
FROM dbo.ADDRESSES_A
UNION ALL
SELECT *
FROM dbo.ADDRESSES_B
Add it to the MapCatalog if it is mappable
Every connection is a new opportunity™
Improved performance with views
If you create a view that you want to search for specific records, it might
be an idea to index the view
To be able to index your views, you need to bind the views with the
data used in the views, this is called SCHEMABINDING
You also need a unique clustered index. Otherwise you can’t index
other columns
Now you can index other columns, for instance the column with your
addresses or the like.
Read more here:
 http://en.wikipedia.org/wiki/Materialized_view
 http://msdn.microsoft.com/en-us/library/dd171921.aspx
 http://www.mssqltips.com/sqlservertip/1610/sql-server-schema-
binding-and-indexed-views/
Every connection is a new opportunity™
SCHEMABINDING
Right click on your view and select Scritp View As > Alter To > New
Query Window
Add ”WITH SCHEMABINDING” as shown below
Hit F5 or click the Execute button to modify the view
Or set it while creating the view
Every connection is a new opportunity™
Unique Clustered Index
Right click on the Index folder of your view and select Create New....
Write a name, like ”PK_” + the name of your view
Pick the primary key column using the Add button
Choose Clustered and check Unique
Hit OK
Every connection is a new opportunity™
Creating indexed views
Every connection is a new opportunity™
Triggers i SQL Server
Every connection is a new opportunity™
What are Triggers?
A trigger can be called when something happens in the
database
It can be called when records are inserted, updated,
deleted
It can be called when a user logs onto the database
A trigger can be used to stamp records with information on
who changed them and when
A trigger can be used to copy changed records to a historic
table
Every connection is a new opportunity™
Temporary tables in triggers
SQL Server has two temporary tables, that can be accessed in a trigger:
inserted
 Contains the new records, that are to be inserted. This table
contains the changed records as they look after the change
 Exists on insert and on update
deleted
 Contains the records that have been deleted or updated. This table
contains the records as they look before they are changed/deleted
 Exists on update and on delete
Every connection is a new opportunity™
Trigger statement
CREATE TRIGGER [schema_name.] trigger_name
ON { table | view }
[ WITH <dml_trigger_option> [ ,...n ] ]
{ FOR | AFTER | INSTEAD OF } { [INSERT] [,] [UPDATE] [,] [DELETE]}
[ NOT FOR REPLICATION ]
AS { sql_statement [ ; ]
[ ,...n ]
| EXTERNAL NAME <method specifier [ ; ] > }
Every connection is a new opportunity™
Create a timestamp trigger on update
CREATE TRIGGER dbo.trg_MY_TABLE_AfterUpdate
ON dbo. MY_TABLE
AFTER UPDATE
AS
Begin
Update dbo.MY_TABLE
Set DATE_CHANGED = CURRENT_TIMESTAMP,
USER_CHANGED = USER
Where MI_PRINX In (Select MI_PRINX From inserted);
End
GO
Every connection is a new opportunity™
Create a timestamp trigger after insert
CREATE TRIGGER dbo.trg_MY_TABLE_AfterInsert
ON dbo. MY_TABLE
AFTER INSERT
AS
Begin
Update dbo.MY_TABLE
Set DATE_CREATED = CURRENT_TIMESTAMP,
USER_CREATED = USER
Where MI_PRINX In (Select MI_PRINX From inserted);
End
GO
Every connection is a new opportunity™
Create a ”history” trigger
CREATE TRIGGER dbo.trgCopyToHistory
ON dbo.ADM_KOMMUNE_2007
AFTER DELETE,UPDATE
AS
Begin
Insert Into dbo.ADM_KOMMUNE_2007_history
(OBJECTID, NAME, OBJECTTYPE, ADM_CODE
, MI_PRINX_ORIGINAL, SP_GEOMETRY, MI_STYLE)
Select OBJECTID, NAME, OBJECTTYPE, ADM_CODE
, MI_PRINX, SP_GEOMETRY, MI_STYLE
From deleted
End
Go
Every connection is a new opportunity™
Trigger updating X and Y columns
Create TRIGGER [dbo].[trg_MYTABLE_AfterUpdate]
ON [dbo].[MYTABLE]
AFTER INSERT, UPDATE
AS
BEGIN
UPDATE DBO.MYTABLE
SET X = SP_GEOMETRY.STX,
Y = SP_GEOMETRY.STY
WHERE MI_PRINX IN (SELECT MI_PRINX FROM inserted)
END
Every connection is a new opportunity™
Creating triggers
Every connection is a new opportunity™
Using MapBasic to access SQL Server
Every connection is a new opportunity™
Process
Create connection
nConn = Server_Connect("ODBC“, "DSN=GIS")
Do something
Server Create Map
Server Create Style
Server Create Table
Server Link Table
Register Table
Server Refresh
Server Set Map
Server_Execute
Commit Table
…
Close Connection
Server nConn Disconnect
Every connection is a new opportunity™
Server_Execute
You can use the Server_Execute function to send SQL statements to
the SQL Server to be executed
Make sure that you have an connection to the database open
Print Server_Execute(1, ”Drop table dbo.PLACES”)
Print Server_Execute(1, ”Delete From
MapInfo.MapInfo_MapCatalog
Where OWNERNAME = ’dbo’
and TABLENAME = ’PLACES’”)
Do remember to replace the ” and ’ in the MapBasic window when
copied from a PowerPoint
Every connection is a new opportunity™
MapBasic applications - FindDBMS
Find DBMS is a small utility showing how a search can be done using a
spatial database on the back end
The tool searches a predefined table in the database using the
connection #1. This could be changed to be a specific data source.
The tool lets you enter some value to search for. When you hit Enter,
the SQL Select is sent to the database and the matching values are
returned and shown in a listbox.
When you click on any of the returned values, the matching record is
highlighted in the map and the map is zoomed to the record
Note that you should have the table searched open in a map. The
name of this table is specified in the config file: FIND DBMS.ini
Every connection is a new opportunity™
Find DBMS
Every connection is a new opportunity™
Find DBMS
Every connection is a new opportunity™
MapBasic applications - TableRefresh
TableRefresh is a small utility that will search a file structure for tables
The tables found will be opened and if they are either a Linked or a
WFS table, the application can refresh them if this has been
specified
The tool is controlled by the configuration file
Every connection is a new opportunity™
Table Refresh
Every connection is a new opportunity™
Partner offerings
A number of our partners has seen a need for helping
customers take advantage of spatial databases
This has resulted in a number of applications for this area.
Here are two examples, but there are more out there
Every connection is a new opportunity™
LE34 – GIS34 Manager
Every connection is a new opportunity™
Aligned Assets - GeoStore
Every connection is a new opportunity™
Final Words
We have now looked at how to
• prepare a database to be used by MapInfo Professional
• access a spatial database from MapInfo Professional
• upload data to the spatial database using EasyLoader
• open tables from a spatial database from MapInfo
Professional
• create views in a spatial database
• implement some triggers in the spatial database
• take advantage of the spatial database from MapBasic
Every connection is a new opportunity™
Questions
 Peter Horsbøll Møller
 peter.moller@pb.com
 www.mapinfo.com
Every connection is a new opportunity™
Every connection is a new opportunity
™

More Related Content

What's hot

Cơ sở hạ tầng mã hóa khóa công khai PKI trong bài toán quản lý sinh viên.pdf
Cơ sở hạ tầng mã hóa khóa công khai PKI trong bài toán quản lý sinh viên.pdfCơ sở hạ tầng mã hóa khóa công khai PKI trong bài toán quản lý sinh viên.pdf
Cơ sở hạ tầng mã hóa khóa công khai PKI trong bài toán quản lý sinh viên.pdfMan_Ebook
 
Bao cao thuc tap co so
Bao cao thuc tap co soBao cao thuc tap co so
Bao cao thuc tap co soHiên Ngọc
 
Introducing the eDB360 Tool
Introducing the eDB360 ToolIntroducing the eDB360 Tool
Introducing the eDB360 ToolCarlos Sierra
 
Khóa luận tốt nghiệp Phân tích, thiết kế hệ thống thông tin quản lý nhân sự t...
Khóa luận tốt nghiệp Phân tích, thiết kế hệ thống thông tin quản lý nhân sự t...Khóa luận tốt nghiệp Phân tích, thiết kế hệ thống thông tin quản lý nhân sự t...
Khóa luận tốt nghiệp Phân tích, thiết kế hệ thống thông tin quản lý nhân sự t...https://www.facebook.com/garmentspace
 
Processos threads senai
Processos threads senaiProcessos threads senai
Processos threads senaiCarlos Melo
 
Đề tài: Xây dựng hệ thống thi trắc nghiệm qua mạng LAN, 9đ
Đề tài: Xây dựng hệ thống thi trắc nghiệm qua mạng LAN, 9đĐề tài: Xây dựng hệ thống thi trắc nghiệm qua mạng LAN, 9đ
Đề tài: Xây dựng hệ thống thi trắc nghiệm qua mạng LAN, 9đViết thuê trọn gói ZALO 0934573149
 
Rename domain controller server 2012
Rename domain controller server 2012Rename domain controller server 2012
Rename domain controller server 2012laonap166
 
Bai giang asp.net full
Bai giang asp.net fullBai giang asp.net full
Bai giang asp.net fullBoom Su
 
Manipulação de formulários com PHP. Uso de Cookies e Session com PHP.
Manipulação de formulários com PHP. Uso de Cookies e Session com PHP.Manipulação de formulários com PHP. Uso de Cookies e Session com PHP.
Manipulação de formulários com PHP. Uso de Cookies e Session com PHP.Leonardo Soares
 
Hệ quản trị cơ sở dữ liệu phạm gia tiến[bookbooming.com]
Hệ quản trị cơ sở dữ liệu   phạm gia tiến[bookbooming.com]Hệ quản trị cơ sở dữ liệu   phạm gia tiến[bookbooming.com]
Hệ quản trị cơ sở dữ liệu phạm gia tiến[bookbooming.com]bookbooming1
 
Báo cáo môn đảm bảo chất lượng phần mềm
Báo cáo môn đảm bảo chất lượng phần mềmBáo cáo môn đảm bảo chất lượng phần mềm
Báo cáo môn đảm bảo chất lượng phần mềmThuyet Nguyen
 
Apresentação Semáforos, monitores, troca de mensagens, Deadlock
Apresentação Semáforos, monitores, troca de mensagens, DeadlockApresentação Semáforos, monitores, troca de mensagens, Deadlock
Apresentação Semáforos, monitores, troca de mensagens, DeadlockWilliams Gomes da Silva
 
Mastering PostgreSQL Administration
Mastering PostgreSQL AdministrationMastering PostgreSQL Administration
Mastering PostgreSQL AdministrationEDB
 
Apostila Programação Java
Apostila Programação JavaApostila Programação Java
Apostila Programação Javainfo_cimol
 

What's hot (20)

Cơ sở hạ tầng mã hóa khóa công khai PKI trong bài toán quản lý sinh viên.pdf
Cơ sở hạ tầng mã hóa khóa công khai PKI trong bài toán quản lý sinh viên.pdfCơ sở hạ tầng mã hóa khóa công khai PKI trong bài toán quản lý sinh viên.pdf
Cơ sở hạ tầng mã hóa khóa công khai PKI trong bài toán quản lý sinh viên.pdf
 
Bao cao thuc tap co so
Bao cao thuc tap co soBao cao thuc tap co so
Bao cao thuc tap co so
 
Tuning the g1gc
Tuning the g1gcTuning the g1gc
Tuning the g1gc
 
Tìm hiểu về NodeJs
Tìm hiểu về NodeJsTìm hiểu về NodeJs
Tìm hiểu về NodeJs
 
Introducing the eDB360 Tool
Introducing the eDB360 ToolIntroducing the eDB360 Tool
Introducing the eDB360 Tool
 
Khóa luận tốt nghiệp Phân tích, thiết kế hệ thống thông tin quản lý nhân sự t...
Khóa luận tốt nghiệp Phân tích, thiết kế hệ thống thông tin quản lý nhân sự t...Khóa luận tốt nghiệp Phân tích, thiết kế hệ thống thông tin quản lý nhân sự t...
Khóa luận tốt nghiệp Phân tích, thiết kế hệ thống thông tin quản lý nhân sự t...
 
Processos threads senai
Processos threads senaiProcessos threads senai
Processos threads senai
 
Rac 12c optimization
Rac 12c optimizationRac 12c optimization
Rac 12c optimization
 
Lập trình Python cơ bản
Lập trình Python cơ bảnLập trình Python cơ bản
Lập trình Python cơ bản
 
Đề tài: Xây dựng hệ thống thi trắc nghiệm qua mạng LAN, 9đ
Đề tài: Xây dựng hệ thống thi trắc nghiệm qua mạng LAN, 9đĐề tài: Xây dựng hệ thống thi trắc nghiệm qua mạng LAN, 9đ
Đề tài: Xây dựng hệ thống thi trắc nghiệm qua mạng LAN, 9đ
 
Rename domain controller server 2012
Rename domain controller server 2012Rename domain controller server 2012
Rename domain controller server 2012
 
Bai giang asp.net full
Bai giang asp.net fullBai giang asp.net full
Bai giang asp.net full
 
Manipulação de formulários com PHP. Uso de Cookies e Session com PHP.
Manipulação de formulários com PHP. Uso de Cookies e Session com PHP.Manipulação de formulários com PHP. Uso de Cookies e Session com PHP.
Manipulação de formulários com PHP. Uso de Cookies e Session com PHP.
 
Đề tài: Phần mềm quản lý thư viện và website tra cứu sách, HOT
Đề tài: Phần mềm quản lý thư viện và website tra cứu sách, HOTĐề tài: Phần mềm quản lý thư viện và website tra cứu sách, HOT
Đề tài: Phần mềm quản lý thư viện và website tra cứu sách, HOT
 
Hệ quản trị cơ sở dữ liệu phạm gia tiến[bookbooming.com]
Hệ quản trị cơ sở dữ liệu   phạm gia tiến[bookbooming.com]Hệ quản trị cơ sở dữ liệu   phạm gia tiến[bookbooming.com]
Hệ quản trị cơ sở dữ liệu phạm gia tiến[bookbooming.com]
 
Báo cáo môn đảm bảo chất lượng phần mềm
Báo cáo môn đảm bảo chất lượng phần mềmBáo cáo môn đảm bảo chất lượng phần mềm
Báo cáo môn đảm bảo chất lượng phần mềm
 
Apresentação Semáforos, monitores, troca de mensagens, Deadlock
Apresentação Semáforos, monitores, troca de mensagens, DeadlockApresentação Semáforos, monitores, troca de mensagens, Deadlock
Apresentação Semáforos, monitores, troca de mensagens, Deadlock
 
Mastering PostgreSQL Administration
Mastering PostgreSQL AdministrationMastering PostgreSQL Administration
Mastering PostgreSQL Administration
 
Stored procedure
Stored procedureStored procedure
Stored procedure
 
Apostila Programação Java
Apostila Programação JavaApostila Programação Java
Apostila Programação Java
 

Similar to MapInfo Professional 12.0 and SQL Server 2008

Muguki session on MapInfo Professional 11 and SQL Server 2008
Muguki session on MapInfo Professional 11 and SQL Server 2008Muguki session on MapInfo Professional 11 and SQL Server 2008
Muguki session on MapInfo Professional 11 and SQL Server 2008Peter Horsbøll Møller
 
Taking Advantage of a Spatial Database with MapInfo Professional
Taking Advantage of a Spatial Database with MapInfo ProfessionalTaking Advantage of a Spatial Database with MapInfo Professional
Taking Advantage of a Spatial Database with MapInfo ProfessionalPeter Horsbøll Møller
 
Building Applications for SQL Server 2008
Building Applications for SQL Server 2008Building Applications for SQL Server 2008
Building Applications for SQL Server 2008Dave Bost
 
Spatial query tutorial for nyc subway income level along subway
Spatial query tutorial  for nyc subway income level along subwaySpatial query tutorial  for nyc subway income level along subway
Spatial query tutorial for nyc subway income level along subwayVivian S. Zhang
 
Doing data visualizations with tableau
Doing data visualizations with tableauDoing data visualizations with tableau
Doing data visualizations with tableauRay Schwartz
 
Data analytics online training
Data analytics online trainingData analytics online training
Data analytics online trainingankitha reddy
 
Concepts and Methods of Embedding Statistical Data into Maps
Concepts and Methods of Embedding Statistical Data into MapsConcepts and Methods of Embedding Statistical Data into Maps
Concepts and Methods of Embedding Statistical Data into MapsMohammad Liton Hossain
 
data-spread-demo
data-spread-demodata-spread-demo
data-spread-demoBofan Sun
 
Data Analytics with R and SQL Server
Data Analytics with R and SQL ServerData Analytics with R and SQL Server
Data Analytics with R and SQL ServerStéphane Fréchette
 
Distributed computing poli
Distributed computing poliDistributed computing poli
Distributed computing poliivascucristian
 
Best Practices for Building and Deploying Data Pipelines in Apache Spark
Best Practices for Building and Deploying Data Pipelines in Apache SparkBest Practices for Building and Deploying Data Pipelines in Apache Spark
Best Practices for Building and Deploying Data Pipelines in Apache SparkDatabricks
 
HARJOT.ppt
HARJOT.pptHARJOT.ppt
HARJOT.pptsatgup78
 
SharePoint - Crunch the Numbers Together
SharePoint - Crunch the Numbers TogetherSharePoint - Crunch the Numbers Together
SharePoint - Crunch the Numbers TogetherDavid J Rosenthal
 
02 data warehouse applications with hive
02 data warehouse applications with hive02 data warehouse applications with hive
02 data warehouse applications with hiveSubhas Kumar Ghosh
 
datavisualization-5thUnit.pdf
datavisualization-5thUnit.pdfdatavisualization-5thUnit.pdf
datavisualization-5thUnit.pdfBrijeshPatil13
 
Sql server lesson5
Sql server lesson5Sql server lesson5
Sql server lesson5Ala Qunaibi
 
Doing data visualizations with tableau
Doing data visualizations with tableauDoing data visualizations with tableau
Doing data visualizations with tableauRay Schwartz
 

Similar to MapInfo Professional 12.0 and SQL Server 2008 (20)

Muguki session on MapInfo Professional 11 and SQL Server 2008
Muguki session on MapInfo Professional 11 and SQL Server 2008Muguki session on MapInfo Professional 11 and SQL Server 2008
Muguki session on MapInfo Professional 11 and SQL Server 2008
 
Taking Advantage of a Spatial Database with MapInfo Professional
Taking Advantage of a Spatial Database with MapInfo ProfessionalTaking Advantage of a Spatial Database with MapInfo Professional
Taking Advantage of a Spatial Database with MapInfo Professional
 
Building Applications for SQL Server 2008
Building Applications for SQL Server 2008Building Applications for SQL Server 2008
Building Applications for SQL Server 2008
 
Spatial query tutorial for nyc subway income level along subway
Spatial query tutorial  for nyc subway income level along subwaySpatial query tutorial  for nyc subway income level along subway
Spatial query tutorial for nyc subway income level along subway
 
Doing data visualizations with tableau
Doing data visualizations with tableauDoing data visualizations with tableau
Doing data visualizations with tableau
 
Data analytics online training
Data analytics online trainingData analytics online training
Data analytics online training
 
Concepts and Methods of Embedding Statistical Data into Maps
Concepts and Methods of Embedding Statistical Data into MapsConcepts and Methods of Embedding Statistical Data into Maps
Concepts and Methods of Embedding Statistical Data into Maps
 
data-spread-demo
data-spread-demodata-spread-demo
data-spread-demo
 
Dbms fast track 2/3
Dbms fast track 2/3Dbms fast track 2/3
Dbms fast track 2/3
 
Data Analytics with R and SQL Server
Data Analytics with R and SQL ServerData Analytics with R and SQL Server
Data Analytics with R and SQL Server
 
My tableau
My tableauMy tableau
My tableau
 
Tableau training course
Tableau training courseTableau training course
Tableau training course
 
Distributed computing poli
Distributed computing poliDistributed computing poli
Distributed computing poli
 
Best Practices for Building and Deploying Data Pipelines in Apache Spark
Best Practices for Building and Deploying Data Pipelines in Apache SparkBest Practices for Building and Deploying Data Pipelines in Apache Spark
Best Practices for Building and Deploying Data Pipelines in Apache Spark
 
HARJOT.ppt
HARJOT.pptHARJOT.ppt
HARJOT.ppt
 
SharePoint - Crunch the Numbers Together
SharePoint - Crunch the Numbers TogetherSharePoint - Crunch the Numbers Together
SharePoint - Crunch the Numbers Together
 
02 data warehouse applications with hive
02 data warehouse applications with hive02 data warehouse applications with hive
02 data warehouse applications with hive
 
datavisualization-5thUnit.pdf
datavisualization-5thUnit.pdfdatavisualization-5thUnit.pdf
datavisualization-5thUnit.pdf
 
Sql server lesson5
Sql server lesson5Sql server lesson5
Sql server lesson5
 
Doing data visualizations with tableau
Doing data visualizations with tableauDoing data visualizations with tableau
Doing data visualizations with tableau
 

More from Peter Horsbøll Møller

Be Location Intelligent with MapInfo Pro v2019
Be Location Intelligent with MapInfo Pro v2019Be Location Intelligent with MapInfo Pro v2019
Be Location Intelligent with MapInfo Pro v2019Peter Horsbøll Møller
 
MapInfo Pro v2019: Improving the Way You Query
MapInfo Pro v2019: Improving the Way You QueryMapInfo Pro v2019: Improving the Way You Query
MapInfo Pro v2019: Improving the Way You QueryPeter Horsbøll Møller
 
Eksklusivsmagning - 10 års jubilæum, Oksenvad Whiskylaug
Eksklusivsmagning - 10 års jubilæum, Oksenvad WhiskylaugEksklusivsmagning - 10 års jubilæum, Oksenvad Whiskylaug
Eksklusivsmagning - 10 års jubilæum, Oksenvad WhiskylaugPeter Horsbøll Møller
 
Llinking Spectrum dataflows to MapInfo Pro
Llinking Spectrum dataflows to MapInfo ProLlinking Spectrum dataflows to MapInfo Pro
Llinking Spectrum dataflows to MapInfo ProPeter Horsbøll Møller
 
Getting Started with the Ribbon library - MUGUKI User Group Meeting 2016
Getting Started with the Ribbon library - MUGUKI User Group Meeting 2016Getting Started with the Ribbon library - MUGUKI User Group Meeting 2016
Getting Started with the Ribbon library - MUGUKI User Group Meeting 2016Peter Horsbøll Møller
 
Using Spectrum on Demand from MapInfo Pro
Using Spectrum on Demand from MapInfo ProUsing Spectrum on Demand from MapInfo Pro
Using Spectrum on Demand from MapInfo ProPeter Horsbøll Møller
 
MapInfo Pro 64 bit og MapInfo Pro Advanced 64 bit
MapInfo Pro 64 bit og MapInfo Pro Advanced 64 bitMapInfo Pro 64 bit og MapInfo Pro Advanced 64 bit
MapInfo Pro 64 bit og MapInfo Pro Advanced 64 bitPeter Horsbøll Møller
 
MapInfo Pro Raster og de danske højdedata
MapInfo Pro Raster og de danske højdedataMapInfo Pro Raster og de danske højdedata
MapInfo Pro Raster og de danske højdedataPeter Horsbøll Møller
 
Blend, Single Grain og Single Malt Whisky
Blend, Single Grain og Single Malt WhiskyBlend, Single Grain og Single Malt Whisky
Blend, Single Grain og Single Malt WhiskyPeter Horsbøll Møller
 
MapInfo Pro og SQL Server - Uden opgaver
MapInfo Pro og SQL Server - Uden opgaverMapInfo Pro og SQL Server - Uden opgaver
MapInfo Pro og SQL Server - Uden opgaverPeter Horsbøll Møller
 

More from Peter Horsbøll Møller (20)

MapInfo Pro v12.5 to v2021.1 Overview
MapInfo Pro v12.5 to v2021.1 OverviewMapInfo Pro v12.5 to v2021.1 Overview
MapInfo Pro v12.5 to v2021.1 Overview
 
MapInfo Pro Tips & Tricks med Geograf
MapInfo Pro Tips & Tricks med GeografMapInfo Pro Tips & Tricks med Geograf
MapInfo Pro Tips & Tricks med Geograf
 
Introduction to MapBasic
Introduction to MapBasicIntroduction to MapBasic
Introduction to MapBasic
 
Precisely MapInfo Pro v2019 and Roadmap
Precisely MapInfo Pro v2019 and RoadmapPrecisely MapInfo Pro v2019 and Roadmap
Precisely MapInfo Pro v2019 and Roadmap
 
Be Location Intelligent with MapInfo Pro v2019
Be Location Intelligent with MapInfo Pro v2019Be Location Intelligent with MapInfo Pro v2019
Be Location Intelligent with MapInfo Pro v2019
 
MapInfo Pro v2019: Improving the Way You Query
MapInfo Pro v2019: Improving the Way You QueryMapInfo Pro v2019: Improving the Way You Query
MapInfo Pro v2019: Improving the Way You Query
 
Eksklusivsmagning - 10 års jubilæum, Oksenvad Whiskylaug
Eksklusivsmagning - 10 års jubilæum, Oksenvad WhiskylaugEksklusivsmagning - 10 års jubilæum, Oksenvad Whiskylaug
Eksklusivsmagning - 10 års jubilæum, Oksenvad Whiskylaug
 
Llinking Spectrum dataflows to MapInfo Pro
Llinking Spectrum dataflows to MapInfo ProLlinking Spectrum dataflows to MapInfo Pro
Llinking Spectrum dataflows to MapInfo Pro
 
Clynelish - Oksenvad Whiskylaug
Clynelish - Oksenvad WhiskylaugClynelish - Oksenvad Whiskylaug
Clynelish - Oksenvad Whiskylaug
 
Getting Started with the Ribbon library - MUGUKI User Group Meeting 2016
Getting Started with the Ribbon library - MUGUKI User Group Meeting 2016Getting Started with the Ribbon library - MUGUKI User Group Meeting 2016
Getting Started with the Ribbon library - MUGUKI User Group Meeting 2016
 
MapInfo Discover 3D: From 2D to 3D
MapInfo Discover 3D: From 2D to 3DMapInfo Discover 3D: From 2D to 3D
MapInfo Discover 3D: From 2D to 3D
 
Whiskysmagning: Samaroli
Whiskysmagning: SamaroliWhiskysmagning: Samaroli
Whiskysmagning: Samaroli
 
Using Spectrum on Demand from MapInfo Pro
Using Spectrum on Demand from MapInfo ProUsing Spectrum on Demand from MapInfo Pro
Using Spectrum on Demand from MapInfo Pro
 
Hvad sker der hos Pitney Bowes
Hvad sker der hos Pitney BowesHvad sker der hos Pitney Bowes
Hvad sker der hos Pitney Bowes
 
MapInfo Discover 2015.2 64 bit
MapInfo Discover 2015.2 64 bitMapInfo Discover 2015.2 64 bit
MapInfo Discover 2015.2 64 bit
 
MapInfo Pro 64 bit og MapInfo Pro Advanced 64 bit
MapInfo Pro 64 bit og MapInfo Pro Advanced 64 bitMapInfo Pro 64 bit og MapInfo Pro Advanced 64 bit
MapInfo Pro 64 bit og MapInfo Pro Advanced 64 bit
 
MapInfo Pro Raster og de danske højdedata
MapInfo Pro Raster og de danske højdedataMapInfo Pro Raster og de danske højdedata
MapInfo Pro Raster og de danske højdedata
 
64 bits of MapInfo Pro - Danish version
64 bits of MapInfo Pro - Danish version64 bits of MapInfo Pro - Danish version
64 bits of MapInfo Pro - Danish version
 
Blend, Single Grain og Single Malt Whisky
Blend, Single Grain og Single Malt WhiskyBlend, Single Grain og Single Malt Whisky
Blend, Single Grain og Single Malt Whisky
 
MapInfo Pro og SQL Server - Uden opgaver
MapInfo Pro og SQL Server - Uden opgaverMapInfo Pro og SQL Server - Uden opgaver
MapInfo Pro og SQL Server - Uden opgaver
 

Recently uploaded

Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 

Recently uploaded (20)

Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 

MapInfo Professional 12.0 and SQL Server 2008

  • 1. Every connection is a new opportunity™ MapInfo User Group UK & Ireland Working with MapInfo Professional and Spatial Databases Peter Horsbøll Møller GIS/LI Pre-Sales Specialist June, 2014
  • 2. Every connection is a new opportunity™ Agenda How to setup a spatial database to be used by MapInfo Professional 12.0 How to work with a spatial database from MapInfo Professional 12.0 How to take advantage of a spatial database in general
  • 3. Every connection is a new opportunity™ A few words about myself Live in Denmark with my family Worked with the largest Danish partner from 1996 until 2008 where I were developing MapBasic applications, doing training and support. Worked on a number of project using Oracle and SQL Server with SpatialWare (R.I.P.) Have been working with Pitney Bowes Software for the last 6 years as a pre-sales specialist Moderator and an active member on the MapInfo-L Feel free to connect: dk.linkedin.com/in/peterhorsbollmoller/
  • 4. Every connection is a new opportunity™ The tools MapInfo Professional 12.0, no introduction required EasyLoader, our tool for uploading tables to spatial databases SQL Server 2008, the spatial database SQL Server Management Studio, the management interface to the database
  • 5. Every connection is a new opportunity™
  • 6. Every connection is a new opportunity™ DAY 1
  • 7. Every connection is a new opportunity™ Creating database, login and users
  • 8. Every connection is a new opportunity™ A few words on login and users In most cases you will use Windwos Authentication and use the Windows usernames (and Active Directory) This let’s you assign permissions to a AD group or a single Windows user The SQL Server users can be used for giving a certain application access
  • 9. Every connection is a new opportunity™ Creating database, login and users
  • 10. Every connection is a new opportunity™ Schemas
  • 11. Every connection is a new opportunity™ What is a schema in SQL Server? A schema in SQL Server is a way to organise for instance your tables Schemaes also lets you assign permission to a number of tables, by assigning permissions to the schema in stead of directly to the tables You can use Schemaes as a way of organising your tables instead of using several databases When you access the database from MapInfo Professional you can in the Open dialog choose what Schema you want to browse. In this way you can limit the number of tables shown in the dialog.
  • 12. Every connection is a new opportunity™ Creating a new schema
  • 13. Every connection is a new opportunity™ Creating a ODBC Data source Data Data
  • 14. Every connection is a new opportunity™ Creating a SQL Server 2008 data source Data sources can be created manually or in a centralised way They can be stored in files or in the registry For MapInfo Professional 32bit, the ODBC data source must be created as 32bit data sources For SQL Server 2008 you should use: ”SQL Server Native Client 10.0” driver For SQL Server 2012 and Windows7 you should use: ”SQL Server Native Client 11.0” driver
  • 15. Every connection is a new opportunity™ MARS connection Multiple Active Result Sets (MARS) Supported  MapInfo Professional 10.5.2  SQLServer 2005, 2008 & 2012 MapInfo Professional will by default add this string to the connection string:  “MARS Connection=true” Improved performance when access a table, especially using Live with Cache. Access can be 5-10 times faster.
  • 16. Every connection is a new opportunity™ Creating a SQL Server 2008 data source
  • 17. Every connection is a new opportunity™ The MapInfo Map Catalog
  • 18. Every connection is a new opportunity™ Map Catalog The Map Catalog (MapInfo.MapInfo_MapCatalog) describes spatial tables in the database with values like:  Kind of spatial table, for example. XY, SpatialWare, Oracle, SQL Server, PostgreSQL/PostGIS, etc.  Coordinate system  Data bounds  Symbol, default and per row  Default view • The Map Catalog must exist once in the databases holding spatial data, that is to be accessed by MapInfo Professional
  • 19. Every connection is a new opportunity™ Map Catalog – Spatial type Data storage  1 : MapInfo Code, XY with MapInfo key (3 columns)  4 : XY stored in two columns  13: Oracle Spatial  14: MapInfo SpatialWare for MS SQL Server  17: SQL Server 2008 Geometry  18: SQL Server 2008 Geography  19: PostgreSQL/PostGIS Object types  .0: Only Points  .1: Only Lines/Polylines  .2: Only Regions/Polygons  .3: Mixture of object types is possible
  • 20. Every connection is a new opportunity™ Creating the Map Catalog You can create the Map Catalog using EasyLoader, directly in the database using SQL or you can use the DBMS Catalog tool The user creating the Map Catalog using EasyLoader needs a sysadmin server role. If you create the Map Catalog using EasyLoader, make sure that you close all connections to the database before creating the Map Catalog. If not you might have issues using the Per Row Style option when making DBMS tables mappable.
  • 21. Every connection is a new opportunity™ Creating the Map Catalog – EasyLoader
  • 22. Every connection is a new opportunity™ Tables
  • 23. Every connection is a new opportunity™ Creating tables You can create tables manually thru the Management Studio Or thru MapInfo Professional If you use MapInfo Professional it will do a number of things automatically for you, like adding the table to the MapCatalog, creating spatial index and primary index.
  • 24. Every connection is a new opportunity™ Creating tables – data types Exact numerics  Bigint (MapInfo type: Float) – -9.223.372.036.854.775.808 – 9.223.372.036.854.775.807  Int (MapInfo type: Integer) – -2.147.483.648 – 2.147.483.647  SmallInt (MapInfo type: SmallInt) – -32.768 – 32.767  TinyInt (MapInfo type: SmallInt) – 0 – 255  Bit (MapInfo type: Logical) – 1 or 0  Decimal / numerical (MapInfo type: Decimal) – -10^38 +1 – 10^38 –1
  • 25. Every connection is a new opportunity™ Creating tables – data types Approximate Numerics  Float (MapInfo type: Float)  Real (MapInfo type: Float) Date and time  Datetime (MapInfo type: DateTime) – From January 1, 1753, through December 31, 9999, with an accuracy of three-hundredths of a second, or 3,33 milliseconds  Date (MapInfo type: Date) – From January 1, 1 A.D. through December 31, 9999 A.D.
  • 26. Every connection is a new opportunity™ Creating tables – data types Character strings  Char (MapInfo type: Char) – Fixed-length non-Unicode data, max. 8.000 characters  VarChar (MapInfo type: Char) – Variable-length non-Unicode data, max. 8.000 characters  Text (MapInfo type: Char) – Variable-length non-Unicode data, max. 2,147,483,647 characters Note: Character columns longer than 254 will be made read-only when opened in MapInfo Professional and they will only show the first 254 characters
  • 27. Every connection is a new opportunity™ Creating tables – data types Spatial types  Geometry (MapInfo type: Object) – Does require the table to be registered in the MapCatalog, more on this later  Geography (MapInfo type: Object) – Does require the table to be registered in the MapCatalog, more on this later
  • 28. Every connection is a new opportunity™ Creating a table - naming Consider only using the characters A – Z and the numbers 0 – 9 and underscores (_) when naming your tables Use the same naming convention for columns SQL Server does however support national characters, spaces and some other special characters. SQL Server has a list of reserved words that can’t be used as table or column names, see the complete list here:  http://technet.microsoft.com/en-us/library/ms189822.aspx If the tables must be used from MapInfo Professional it’s recommended to limit the names to 31 characters Also note that the columns for table and column names in the MapCatalog is limited to 32 characters. If you want to use longer names, you need to extend these
  • 29. Every connection is a new opportunity™ Creating tables – considerations Avoid the unicode column types (nchar, nvarchar, ntext) as MapInfo Professional can’t edit these Avoid creating character string column wider than 254 as MapInfo Professional can’t edit these Consider naming your Primary key column MI_PRINX. MapInfo Professional will use this as the primary key in views Consider adding Identity columns to all your table for the Primary Index column. This will automatically update this column with unique values when inserting new records (similar to AutoNumber in MS Access)
  • 30. Every connection is a new opportunity™ Creating tables thru Management Studio
  • 31. Every connection is a new opportunity™ Create a new table thru MapInfo Pro You can create a new table in SQL Server directly from MapInfo Professional. MapInfo Professional will automatically add this new table to the MapInfo MapCatalog in the database. MapInfo Professional will also guide you thru the choises when making the table mappable and adding a primary index column to the table
  • 32. Every connection is a new opportunity™ Creating tables thru MapInfo Pro
  • 33. Every connection is a new opportunity™ Uploading tables to SQL Server
  • 34. Every connection is a new opportunity™ EasyLoader EasyLoader … … is provided with MapInfo Professional. It can also be downloaded from our website … is a standalone application that can run outside of MapInfo Professional … is a Windows application but it can connect to databases running on other operating systems … can be run in batch mode  command prompt  bat file  program
  • 35. Every connection is a new opportunity™ Uploading thru EasyLoader
  • 36. Every connection is a new opportunity™ Using EasyLoader as a batch uploader Samples on how to pass parameters to EasyLoader for doing batch uploads Upload a single table  “C:ProgramMapInfoProfessionalToolseasyloader.exe” /B dbo /E /F c:ezload.log /G /K /P R /S DSN=GIS;UID=AdminUK;PWD=Admin /Q /Y MI_STYLE /T C:MapsAddresses.tab;Addresses Upload multiple tables using a text file  “C:ProgramMapInfoProfessionalToolseasyloader.exe” /B MAPS /E /F c:ezload.log /G /K /P R /S DSN=GIS;UID=AdminUK;PWD=Admin /Q /Y MI_STYLE /L C:tabfiles.txt Makes it easy to rerun the uploads!
  • 37. Every connection is a new opportunity™ Uploading thru EasyLoader - batchmode
  • 38. Every connection is a new opportunity™ Upload using Save as Within MapInfo Professional you can save your table directly to the data using File > Save Copy as… Make sure you select the database connection in the file type drop down list Enter the name of the server table Enter the name of the tab file (using Live connection) • Will automatically add: – MI_PRINX – MI_STYLE
  • 39. Every connection is a new opportunity™ MapBasic syntax for Save as The MapBasic syntax for saving table to a database looks like this: Commit Table AV97_W As "C:DBMSBuildings.tab" Type ODBC Connection 1 Table """dbo""."“Buildings""" Type SQLServerSpatial Geometry ConvertDateTime ON Interactive Some of the parameters are optional
  • 40. Every connection is a new opportunity™ Uploading thru Save as
  • 41. Every connection is a new opportunity™ Spatial errors Certain objects from MapInfo tabellens can result in errors. It can be a good idea to run queries like these to find obvious issues: Regions with an area of less than 1 sq meter Select * From MY_TABLE Where Str$(ObjectInfo(OBJ, 1)) In (”7”, ”8”, ”9”) And CartesianArea(OBJ, ”sq m”) < 1 Into __POSSIBLE_ISSUES_REGIONS Lines with a length of less than 1 meter Select * From MY_TABLE Where Str$(ObjectInfo(OBJ, 1)) In (”3”, ”4”) And CartesianObjectLen(OBJ, ”m”) < 1 Into __POSSIBLE_ISSUES_LINES
  • 42. Every connection is a new opportunity™ Opening tables into MapInfo Professional
  • 43. Every connection is a new opportunity™ Opening a remote table Select File > Open Click on Open DBMS Connection or select the open connection in the Files of Type dropdown list Select the schema Check the table(s) to open Select Linked or Live (with Cache)
  • 44. Every connection is a new opportunity™ Opening DBMS tables into MapInfo Pro
  • 45. Every connection is a new opportunity™ Reopening a remote table It’s only the first time you open a DBMS table, that you need to specify which data to open Afterwards you can reopen this table by opening the tab file The tab file contains all the necessary information  Table structure  Connection information  Can also hold the Username and Password If the table was opened as ”Linked”, you may want to refresh the data. If the table was opened as ”Live”, MapInfo will read the latest data from the database
  • 46. Every connection is a new opportunity™ Meta data section - Linked !table !version 400 !charset WindowsLatin1 Definition Table Type LINKED Charset "WindowsLatin1" Fields 4 MI_PRINX Integer ReadOnly ; PLACENAME Char (50) ; DESCRIPTION Char (250) ; TYPE Char (20) ; begin_metadata "DATALINK" = "" "DATALINKConnectionString" = "DSN=GIS2;Description=SQL Server 2008 GIS database;UID=AdminUser;APP=MapInfo Professional®;WSID=DKMP12948" "DATALINKQuery" = "select ""MI_PRINX"", ""PLACENAME"", ""DESCRIPTION"", ""TYPE"", ""OBJECT"" from ""GIS"".""dbo"".""PointsOfInterest""" "IsReadOnly" = "FALSE" end_metadata
  • 47. Every connection is a new opportunity™ Meta data section - Live !table !version 500 !charset WindowsLatin1 Definition Table Type ODBC begin_metadata "IsReadOnly" = "FALSE" "DATALINK" = "" "DATALINKQuery" = "Select * From ""GIS"".""dbo"".""PointsOfInterest""" "DATALINKConnectionString" = "DSN=GIS2;Description=SQL Server 2008 GIS database;UID=AdminUser;APP=MapInfo Professional®;WSID=DKMP12948" "DATALINKToolKit" = "ODBC" "CACHE" = "ON" "MBRSEARCH" = "ON" end_metadata
  • 48. Every connection is a new opportunity™ MapInfo Pro: Linked vs Live tables
  • 49. Every connection is a new opportunity™ Linked • Data is copied to the MapInfo table the when you create the linked table and when you refresh it • Access to the database is only needed when saving or refreshing -> working offline and long transactions are built in so your data is locally available • Speed is as fast as local data after download • Data can be accessed read-only without a primary key • Using a query to get just the data you need, will speed up download time. Queries are set when you create the linked table via the Row, Column or Expert dialogs • Data is downloaded to the same location as the .TAB file • Duplicate data
  • 50. Every connection is a new opportunity™ Live with/without cache • First time opening a table may be faster – depending on the zoom of your map window • One “view entire layer” or zoom out to the entire view will download the whole table • Data must have a primary key • You always need access to the database
  • 51. Every connection is a new opportunity™ Live without cache • MapInfo Professional “always” reads directly from the database • Every draw, browse, select click which can negatively affect performance. • Data is reread from the server on every access
  • 52. Every connection is a new opportunity™ Live with Cache • Uses a temporary cache  Since 9.5.1 – MapInfo table stored in a temporary MapInfo table. – The cache is progressive, as you pan, zoom out or have more than one map window of the same data, the cache grows • Data is cached as used in the map, so subsequent access to the same data will be quicker • The cache is cleared when the table closes
  • 53. Every connection is a new opportunity™ Conclusions Only use LIVE WITHOUT CACHE when  The data is highly volatile (changing minute to minute or even sooner) Use LIVE WITH CACHE when  The table data is very large and it is not feasible to create a filter query to download less data  Your data changes regulary, for instance every day or during the day Use LINKED when  Your data is static or only changes ones a day/week/month/year  Performance is important  You want to do advanced spatial analysis on the data in MapInfo Pro
  • 54. Every connection is a new opportunity™ Conclusions • If you have a small data size in your table, it will probably not matter if you choose Live or Linked • Using a LIVE table ensures that users log onto the database before they can access the data • If you use live tables we recommend that you access your data thru a workspace with zoom levels set on the live table to prevent downloading unnecessary data • The support for MARS has improved the use of live with cache
  • 55. Every connection is a new opportunity™ DAY 2
  • 56. Every connection is a new opportunity™ Querying
  • 57. Every connection is a new opportunity™ When is the query performed? For Linked tables query is performed when  the table is opened the first time  the table is refreshed. For Live with cache tables query is performed when  the table is added to a map  you zoom or pan in the map For Live without cache query is performed when  the table is added to a map  you zoom or pan in the map  you refresh the map  …
  • 58. Every connection is a new opportunity™ Row filtering You can specify which records to retrieve from the database by attributes And by geography Value of Current_Mapper and Selection are static and not updated when the table is refreshed. “Selection” only available when a selection is active “Current_Mapper” only available when a map is active “Object” is only available for mappable tables “Like” and “not like” only available for text columns Do not use ”” around text values!
  • 59. Every connection is a new opportunity™ Querying - Expert Write your own SQL statement Syntax depends on the SQL dialect of the database MapInfo Professional will “translate” certain expression when passing the query to the database:  Object  Within  Selection  Current_Mapper  … You can save and open queries using the two buttons on the right side of the dialog
  • 60. Every connection is a new opportunity™ Metadata of a spatial query !table !version 650 !charset WindowsLatin1 Definition Table Type LINKED Charset "WindowsLatin1" Fields 3 MI_PRINX Integer ReadOnly ; NAME Char (50) ; TYPE Char (50) ; begin_metadata "IsReadOnly" = "FALSE“ "DATALINK" = "" "DATALINKConnectionString" = "DSN=GIS;MARS_Connection=Yes" "DATALINKQuery" = "select ""MI_PRINX"", ""NAME"", ""TYPE"", ""OBJECT"" from ""GIS"".""dbo"".""POI"" where (OBJECT within Rectangle( 628163.45078508,6112409.85175394,720526.19639343,6186305.28363101))" "DATALINKSpatialObj" = "ST_Spatial(HG_Box(ST_Point(628163.451003735300, 6186305.285449981700),ST_Point(720526.200186016970,6112409.856650807900) ) ,ST_Point(674344.821471954000,6149357.566051412400))" end_metadata
  • 61. Every connection is a new opportunity™ Editing tables from SQL Server
  • 62. Every connection is a new opportunity™ Editing The remote table must contain a primary unique index  In a view this column should be named MI_PRINX You can edit the data with every tool available in MapInfo Professional When editing coordinates of a XY-coordinate table, the coordinates are updated in the columns with the X and Y coordinates in the database table When changing the style on a table that has ”per row style” enabled the new style will be stored in the column holding the style. On other tables the change of style will be dismissed when you refresh the table
  • 63. Every connection is a new opportunity™ Editing – by multiple users If multiple users are editing the same table in SQL Server, they must not access this database table thru the same physical file on disk. If they do only one user will be able to edit the table at a time – the others will be prevented from editing as soon as the first users starts editing. They must access the database table thru their own (local) copy of a MapInfo table, can be linked as well as live
  • 64. Every connection is a new opportunity™ Saving Click Save Table to save the pending edits to the DBMS table When saving the edits to the database, MapInfo checks if the records you have changed, have been changed in the database since you accessed these. If so, a dialog appears asking you to solve the conflict If you are using a linked table, MI Pro will ask if you want to refresh the table as well. I would recommend that you say yes Saving changes offline (only for Linked tables) can be done by closing the table. MapInfo will ask how to store the pending edits:  Save Changes to MapInfo Table  Save Changed to Server  Discard Changes
  • 65. Every connection is a new opportunity™ Editing
  • 66. Every connection is a new opportunity™ Conflict resolution in MapInfo Pro If a table has been changed in the database when being saved, MapInfo will prompt the user with a Conflict Resolution dialog like this one Here you can see what has been changed. You can see the original server version, the current MapInfo version and the current server version You can decide what to keep and what to change – column by column • Here you can see that column KATEGORI has been changed, and how. • You can also see that the geometry (object) has been changed. Harder to see how that has changed
  • 67. Every connection is a new opportunity™ Editing – conflict resolution
  • 68. Every connection is a new opportunity™ Refreshing linked tables
  • 69. Every connection is a new opportunity™ Refreshing Reloading data from the database can be done with Table > Maintenance > Refresh DBMS Table... Refreshing a DBMS table  Checks the database for changes  Reapplies the query condition. Note that the query conditions are static.  If you have specified to filter using the current map or current selection, this filter will always be applied to the table. To specify a different map extent, you have to reopen the table from the database. MapBasic syntax is: Server Refresh name_of_table
  • 70. Every connection is a new opportunity™ Refreshing DBMS tables thru a workspace !Workspace !Version 950 !Charset WindowsLatin1 Dim nConn As Integer nConn = Server_Connect( "ODBC", "DSN=GIS;UID=EditUser;PWD=Edit" ) Print “Connection opened as no: " + nConn Print “Now opening tables..." Open Table "D:3. demodbmsBuildings.tab" Interactive Map From Buildings Print “Refreshing the DBMS tables..." Server Refresh Buildings Close Table Buildings Print “We are done!" Server nConn Disconnect Undim nConn
  • 71. Every connection is a new opportunity™ Files versus database
  • 72. Every connection is a new opportunity™ Files versus database The are a number of differences between MapInfo’s flat tab files and keeping the data in SQL Server  Several applications can access the data, not only MapInfo software  Multiple user editing  The entire database stuff: relations, views, security, triggers etc. When data is kept in the flat MapInfo tab files, the application needs to handle things like  timestamp on change  keeping historic versions  etc. When the data is in the database, the database can manage these things.
  • 73. Every connection is a new opportunity™ Introduction to joins
  • 74. Every connection is a new opportunity™ Inner Join ID NAME LASTNAME 1 Peter 1 2 Paul 3 3 Mary 5 4 Ann 2 ID LASTNAME 1 Møller 2 Smith 3 McCartney 4 Probert ID NAME LASTNAME 1 Peter Møller 2 Paul McCartney 4 Ann Smith SELECT P.ID, P.NAME, L.LASTNAME FROM dbo.PERSONS AS P INNER JOIN dbo.LASTNAMES AS L ON (P.LASTNAME = L.ID)
  • 75. Every connection is a new opportunity™ Left Outer Join ID NAME LASTNAME 1 Peter 1 2 Paul 3 3 Mary 5 4 Ann 2 ID LASTNAME 1 Møller 2 Smith 3 McCartney 4 Probert ID NAME LASTNAME 1 Peter Møller 2 Paul McCartney 3 Mary <NULL> 4 Ann Smith SELECT P.ID, P.NAME, L.LASTNAME FROM dbo.PERSONS AS P LEFT OUTER JOIN dbo.LASTNAMES AS L ON (P.LASTNAME = L.ID)
  • 76. Every connection is a new opportunity™ Cross Join ID NAME LASTNAME 1 Peter 1 2 Paul 3 3 Mary 5 4 Ann 2 ID LASTNAME 1 Møller 2 Smith 3 McCartney 4 Probert ID NAME LASTNAME 1 Peter Møller 2 Paul McCartney 4 Ann Smith SELECT P.ID, P.NAME, L.LASTNAME FROM dbo.PERSONS AS P CROSS JOIN dbo.LASTNAMES AS L WHERE (P.LASTNAME = L.ID) Note: A Cross Join without condition will join every record in the first table with every record in the other table
  • 77. Every connection is a new opportunity™ Some (spatial) join types of SQL Server Inner Join SELECT R.*, P.PLACENAME FROM dbo.ROADS AS R INNER JOIN dbo.PLACES AS P ON (R.SP_GEOMETRY.STIntersects(P.SP_GEOMETRY) = 1) Left Outer Join SELECT R.*, P.PLACENAME FROM dbo.ROADS AS R LEFT OUTER JOIN dbo.PLACES AS P ON (R.SP_GEOMETRY.STIntersects(P.SP_GEOMETRY) = 1) Cross Join SELECT R.*, P.PLACENAME FROM dbo.ROADS AS R CROSS JOIN dbo.PLACES AS P WHERE (R.SP_GEOMETRY.STIntersects(P.SP_GEOMETRY) = 1)
  • 78. Every connection is a new opportunity™ Creating spatial joins
  • 79. Every connection is a new opportunity™ Introduction to Geometry type
  • 80. Every connection is a new opportunity™ Geometry vs Geography The geometry data type supports planar, or Euclidean (flat-earth), data. The geometry data type conforms to the Open Geospatial Consortium (OGC) Simple Features for SQL Specification version 1.1.0. In addition, SQL Server supports the geography data type, which stores ellipsoidal (round-earth) data, such as GPS latitude and longitude coordinates. Read more: • http://msdn.microsoft.com/en-us/library/bb964711.aspx Point Line/Pline Region Region Pline Multi Point Collection
  • 81. Every connection is a new opportunity™ Geometry OGC methods • STArea • STAsBinary • STAsText • STBoundary • STBuffer • STCentroid • STContains • STConvexHull • STCrosses • STDifference • STDimension • STDisjoint • STDistance • STEndpoint • STEnvelope • STEquals • STExteriorRing • STGeometryN • STGeometryType • STInteriorRingN • STIntersection • STIntersects • STIsClosed • STIsEmpty • STIsRing • STIsSimple • STIsValid • STLength • STNumGeometries • STNumInteriorRing • STNumPoints • STOverlaps • STPointN • STPointOnSurface • STRelate • STSrid • STStartPoint • STSymDifference • STTouches • STUnion • STWithin • STX • STY They are all case sensitive!!!
  • 82. Every connection is a new opportunity™ Invalid geometries Find records with invalid geometries Select * From dbo.MYTABLE Where SP_Geometri.STIsValid() = 0 Fix records with invalide geometries – pure magic!? Or not!? Update dbo.MYTABLE Set SP_Geometri = SP_Geometri.MakeValid()
  • 83. Every connection is a new opportunity™ Coordinate systems – EPSG codes Querying EPSG codes for a table, også known as SRID: select distinct SP_GEOMETRY.STSrid from dbo.MYTABLE If it isn’t ”right”, you can change it using this statement: Update dbo.MYTABLE Set SP_GEOMETRY.STSrid = 25832 But do not change the EPSG code to one of a completely different coordinate system. But there does exist coordinate systems with different EPSG codes!: "UTM Zone 32 Euref89p25832“ , 8, 115, 7, 9.0, 0, 0.9996, 500000, 0 "ETRS TM Zone 32, Northern Hemisphere (ETRS89)p3044“ , 8, 115, 7, 9, 0, 0.9996, 500000, 0 Note that EasyLoader has its own projection file!!
  • 84. Every connection is a new opportunity™ Spatial SQL samples Adding a column with the area Select *, SP_GEOMETRY.STArea() As Area From dbo.PLACES Adding a column with the length Select *, SP_GEOMETRY.STLength() As Length From dbo.ROADS
  • 85. Every connection is a new opportunity™ Spatial SQL samples Finding municipalities and their neighbours Select t1.NAME, t2.NAME From dbo.MUNICIPALITIES t1, dbo.MUNICIPALITIES t2 Where (t1.SP_GEOMETRY.STTouches(t2.SP_GEOMETRY) = 1 Or t1.SP_GEOMETRY.STIntersects(t2.SP_GEOMETRY) = 1) And t1.MI_PRINX <> t2.MI_PRINX Order By t1.NAME
  • 86. Every connection is a new opportunity™ Spatial SQL samples Adding city name to only those roads, that intersects a city Select R.*, P.PLACENAME FROM dbo.ROADS AS R CROSS JOIN dbo.PLACES AS P WHERE (R.SP_GEOMETRY.STIntersects(P.SP_GEOMETRY) = 1) Adding city name to the roads, that intersects a city and NULL to the other roads Select R.*, P.PLACENAME FROM dbo.ROADS AS R LEFT OUTER JOIN dbo.PLACES AS P On (R.SP_GEOMETRY.STIntersects(P.SP_GEOMETRY) = 1)
  • 87. Every connection is a new opportunity™ DAY 3
  • 88. Every connection is a new opportunity™ Creating views in SQL Server
  • 89. Every connection is a new opportunity™ What is a view? Et view can be seen as a way to look at your data With a view you can • limit the number of columns and/or records you want to see, for instance to separate a table of roads into different road classes • merge multiple columns to one column, for instance merge road name and house no to a address column • enrich one table with data from another table, for isntance by transfering the postal area name from a postal table to a table with addresses. You often do this by joining these tables. This can be done thru alphanumerical or spatial attributes • combine multiple tables into one.
  • 90. Every connection is a new opportunity™ Creating views in SQL Server – mappable If the views must be mappable from within MapInfo Pro, you need to make the view mappable You can also manually add the view to the MapInfo_MapCatalog – if you know all the parameters Or you can copy the record of the base table in the Map Catalog, insert the copy and change the name of the table to the name of the view
  • 91. Every connection is a new opportunity™ Creating views
  • 92. Every connection is a new opportunity™ Making a DBMS table mappable
  • 93. Every connection is a new opportunity™ Making a DBMS table mappable This will add a record of that table to the MapInfo MapCatalog specifying how MapInfo Professional should show this table in a map You need to specify where to get the spatial data, what coordinate system to use and what symbology to apply to the spatial data when displaying it in MapInfo Professional You can do this thru Table > Maintenance > Make DBMS Table Mappable in MapInfo Professional or by copying and modifying a record in the MapCatalog
  • 94. Every connection is a new opportunity™ Making DBMS tables mappable
  • 95. Every connection is a new opportunity™ A view that merges tables The statement below should be run from a Query-vindue – not thru View > Create New: Create View dbo.viewAddressesUnion As SELECT * FROM dbo.ADDRESSES_A UNION ALL SELECT * FROM dbo.ADDRESSES_B Add it to the MapCatalog if it is mappable
  • 96. Every connection is a new opportunity™ Improved performance with views If you create a view that you want to search for specific records, it might be an idea to index the view To be able to index your views, you need to bind the views with the data used in the views, this is called SCHEMABINDING You also need a unique clustered index. Otherwise you can’t index other columns Now you can index other columns, for instance the column with your addresses or the like. Read more here:  http://en.wikipedia.org/wiki/Materialized_view  http://msdn.microsoft.com/en-us/library/dd171921.aspx  http://www.mssqltips.com/sqlservertip/1610/sql-server-schema- binding-and-indexed-views/
  • 97. Every connection is a new opportunity™ SCHEMABINDING Right click on your view and select Scritp View As > Alter To > New Query Window Add ”WITH SCHEMABINDING” as shown below Hit F5 or click the Execute button to modify the view Or set it while creating the view
  • 98. Every connection is a new opportunity™ Unique Clustered Index Right click on the Index folder of your view and select Create New.... Write a name, like ”PK_” + the name of your view Pick the primary key column using the Add button Choose Clustered and check Unique Hit OK
  • 99. Every connection is a new opportunity™ Creating indexed views
  • 100. Every connection is a new opportunity™ Triggers i SQL Server
  • 101. Every connection is a new opportunity™ What are Triggers? A trigger can be called when something happens in the database It can be called when records are inserted, updated, deleted It can be called when a user logs onto the database A trigger can be used to stamp records with information on who changed them and when A trigger can be used to copy changed records to a historic table
  • 102. Every connection is a new opportunity™ Temporary tables in triggers SQL Server has two temporary tables, that can be accessed in a trigger: inserted  Contains the new records, that are to be inserted. This table contains the changed records as they look after the change  Exists on insert and on update deleted  Contains the records that have been deleted or updated. This table contains the records as they look before they are changed/deleted  Exists on update and on delete
  • 103. Every connection is a new opportunity™ Trigger statement CREATE TRIGGER [schema_name.] trigger_name ON { table | view } [ WITH <dml_trigger_option> [ ,...n ] ] { FOR | AFTER | INSTEAD OF } { [INSERT] [,] [UPDATE] [,] [DELETE]} [ NOT FOR REPLICATION ] AS { sql_statement [ ; ] [ ,...n ] | EXTERNAL NAME <method specifier [ ; ] > }
  • 104. Every connection is a new opportunity™ Create a timestamp trigger on update CREATE TRIGGER dbo.trg_MY_TABLE_AfterUpdate ON dbo. MY_TABLE AFTER UPDATE AS Begin Update dbo.MY_TABLE Set DATE_CHANGED = CURRENT_TIMESTAMP, USER_CHANGED = USER Where MI_PRINX In (Select MI_PRINX From inserted); End GO
  • 105. Every connection is a new opportunity™ Create a timestamp trigger after insert CREATE TRIGGER dbo.trg_MY_TABLE_AfterInsert ON dbo. MY_TABLE AFTER INSERT AS Begin Update dbo.MY_TABLE Set DATE_CREATED = CURRENT_TIMESTAMP, USER_CREATED = USER Where MI_PRINX In (Select MI_PRINX From inserted); End GO
  • 106. Every connection is a new opportunity™ Create a ”history” trigger CREATE TRIGGER dbo.trgCopyToHistory ON dbo.ADM_KOMMUNE_2007 AFTER DELETE,UPDATE AS Begin Insert Into dbo.ADM_KOMMUNE_2007_history (OBJECTID, NAME, OBJECTTYPE, ADM_CODE , MI_PRINX_ORIGINAL, SP_GEOMETRY, MI_STYLE) Select OBJECTID, NAME, OBJECTTYPE, ADM_CODE , MI_PRINX, SP_GEOMETRY, MI_STYLE From deleted End Go
  • 107. Every connection is a new opportunity™ Trigger updating X and Y columns Create TRIGGER [dbo].[trg_MYTABLE_AfterUpdate] ON [dbo].[MYTABLE] AFTER INSERT, UPDATE AS BEGIN UPDATE DBO.MYTABLE SET X = SP_GEOMETRY.STX, Y = SP_GEOMETRY.STY WHERE MI_PRINX IN (SELECT MI_PRINX FROM inserted) END
  • 108. Every connection is a new opportunity™ Creating triggers
  • 109. Every connection is a new opportunity™ Using MapBasic to access SQL Server
  • 110. Every connection is a new opportunity™ Process Create connection nConn = Server_Connect("ODBC“, "DSN=GIS") Do something Server Create Map Server Create Style Server Create Table Server Link Table Register Table Server Refresh Server Set Map Server_Execute Commit Table … Close Connection Server nConn Disconnect
  • 111. Every connection is a new opportunity™ Server_Execute You can use the Server_Execute function to send SQL statements to the SQL Server to be executed Make sure that you have an connection to the database open Print Server_Execute(1, ”Drop table dbo.PLACES”) Print Server_Execute(1, ”Delete From MapInfo.MapInfo_MapCatalog Where OWNERNAME = ’dbo’ and TABLENAME = ’PLACES’”) Do remember to replace the ” and ’ in the MapBasic window when copied from a PowerPoint
  • 112. Every connection is a new opportunity™ MapBasic applications - FindDBMS Find DBMS is a small utility showing how a search can be done using a spatial database on the back end The tool searches a predefined table in the database using the connection #1. This could be changed to be a specific data source. The tool lets you enter some value to search for. When you hit Enter, the SQL Select is sent to the database and the matching values are returned and shown in a listbox. When you click on any of the returned values, the matching record is highlighted in the map and the map is zoomed to the record Note that you should have the table searched open in a map. The name of this table is specified in the config file: FIND DBMS.ini
  • 113. Every connection is a new opportunity™ Find DBMS
  • 114. Every connection is a new opportunity™ Find DBMS
  • 115. Every connection is a new opportunity™ MapBasic applications - TableRefresh TableRefresh is a small utility that will search a file structure for tables The tables found will be opened and if they are either a Linked or a WFS table, the application can refresh them if this has been specified The tool is controlled by the configuration file
  • 116. Every connection is a new opportunity™ Table Refresh
  • 117. Every connection is a new opportunity™ Partner offerings A number of our partners has seen a need for helping customers take advantage of spatial databases This has resulted in a number of applications for this area. Here are two examples, but there are more out there
  • 118. Every connection is a new opportunity™ LE34 – GIS34 Manager
  • 119. Every connection is a new opportunity™ Aligned Assets - GeoStore
  • 120. Every connection is a new opportunity™ Final Words We have now looked at how to • prepare a database to be used by MapInfo Professional • access a spatial database from MapInfo Professional • upload data to the spatial database using EasyLoader • open tables from a spatial database from MapInfo Professional • create views in a spatial database • implement some triggers in the spatial database • take advantage of the spatial database from MapBasic
  • 121. Every connection is a new opportunity™ Questions  Peter Horsbøll Møller  peter.moller@pb.com  www.mapinfo.com
  • 122. Every connection is a new opportunity™ Every connection is a new opportunity ™