1

Re: Creating a live link into Recorder using a SQL Server View

Hi

We have recently installed Recorder 6 and are now looking for the best way to link to ArcGIS. We have some experienced SQL developers here and have decided to go with the live link into Recorder using a SQL Server View. We understand the concerns regarding security and performance.

Does anyone know how I can get hold of the full NBN Data model? Ideally it would be great if I could get a sample view from someone that simply included all conceivable fields relating to taxon occurrences, and we could work from there. It would be fantastic if someone had this already and could share?

Best Regards

Simon

2

Re: Creating a live link into Recorder using a SQL Server View

I've been meaning to get round to this for a while, are you thinking of sites, or records or both?

I have a simple view for site information (name, filecode, spatial ref etc)  but haven't yet tackled the taxon occurrences. I would have thought a decent SQL developer then it shouldn't be that hard for them to fathom it as the naming convention for the tables and fields is pretty straightforward.

I think the following FROM clause contains most of the major links necessary. They will need to select the preferred determination, and preferred locationname (where the occurrence is at a site - if not there will be no Location key in the sample table. Items like recorders and statuses are more complex and will branch off this structure. Ideally the view would also make use of the built in queries which convert dates into a more friendly format.

As I said, the following is just the start of the process, if you get a view that works as you wish, please share it, & save the rest of us the time.

FROM         dbo.TAXON_OCCURRENCE INNER JOIN
                      dbo.TAXON_DETERMINATION ON
                      dbo.TAXON_OCCURRENCE.TAXON_OCCURRENCE_KEY = dbo.TAXON_DETERMINATION.TAXON_OCCURRENCE_KEY INNER JOIN
                      dbo.INDEX_TAXON_NAME ON dbo.TAXON_DETERMINATION.TAXON_LIST_ITEM_KEY = dbo.INDEX_TAXON_NAME.TAXON_LIST_ITEM_KEY INNER JOIN
                      dbo.SAMPLE ON dbo.TAXON_OCCURRENCE.SAMPLE_KEY = dbo.SAMPLE.SAMPLE_KEY INNER JOIN
                      dbo.LOCATION ON dbo.SAMPLE.LOCATION_KEY = dbo.LOCATION.LOCATION_KEY INNER JOIN
                      dbo.LOCATION_NAME ON dbo.LOCATION.LOCATION_KEY = dbo.LOCATION_NAME.LOCATION_KEY

Rob Large
Wildlife Sites Officer
Wiltshire & Swindon Biological Records Centre

3

Re: Creating a live link into Recorder using a SQL Server View

Simon,

Main stuff on NBN data moded is here http://forums.nbn.org.uk/wiki/index.php/NBN_DM_Contents and here http://forums.nbn.org.uk/wiki/index.php/ExNBN_DM_Part_1

Gordon

Gordon Barker
Biological Survey Data Manager
National Trust

4

Re: Creating a live link into Recorder using a SQL Server View

Worth mentioning again there are some useful SQL scalar-valued functions built into recorder which you will need for this process including

dbo.FormatEventRecorders
dbo.LCReturnVagueDateShort
dbo.LCFormatTaxonDesKind

I've almost done the job for you now.

Rob Large
Wildlife Sites Officer
Wiltshire & Swindon Biological Records Centre

5

Re: Creating a live link into Recorder using a SQL Server View

Try this (without the statuses)

SELECT     dbo.INDEX_TAXON_NAME.PREFERRED_NAME AS [Scientific name], dbo.INDEX_TAXON_NAME.COMMON_NAME AS [Common name],
                      dbo.TAXON_GROUP.TAXON_GROUP_NAME AS [Taxon group name], dbo.TAXON_OCCURRENCE.CONFIDENTIAL,
                      dbo.SAMPLE.SPATIAL_REF AS [Sample spatial reference], dbo.LCReturnVagueDateShort(dbo.SAMPLE.VAGUE_DATE_START,
                      dbo.SAMPLE.VAGUE_DATE_END, dbo.SAMPLE.VAGUE_DATE_TYPE) AS Date, dbo.FormatEventRecorders(dbo.SAMPLE.SAMPLE_KEY) AS Recorders,
                      dbo.ufn_GetFormattedName(dbo.TAXON_DETERMINATION.DETERMINER) AS Determiner,
                      dbo.TAXON_OCCURRENCE.TAXON_OCCURRENCE_KEY AS [Observation key], dbo.ufn_RtfToPlaintext(dbo.TAXON_OCCURRENCE.COMMENT)
                      AS Comment, dbo.SAMPLE.LOCATION_NAME AS Location, dbo.LOCATION_NAME.ITEM_NAME AS [Site name], dbo.TAXON_OCCURRENCE.VERIFIED,
                      dbo.INDEX_TAXON_NAME.SORT_ORDER AS [Sort order], dbo.SAMPLE.LOCATION_KEY AS [Site key]
FROM         dbo.LOCATION_NAME RIGHT OUTER JOIN
                      dbo.SAMPLE ON dbo.LOCATION_NAME.LOCATION_KEY = dbo.SAMPLE.LOCATION_KEY FULL OUTER JOIN
                      dbo.TAXON_OCCURRENCE INNER JOIN
                      dbo.TAXON_DETERMINATION ON
                      dbo.TAXON_OCCURRENCE.TAXON_OCCURRENCE_KEY = dbo.TAXON_DETERMINATION.TAXON_OCCURRENCE_KEY INNER JOIN
                      dbo.INDEX_TAXON_NAME ON dbo.TAXON_DETERMINATION.TAXON_LIST_ITEM_KEY = dbo.INDEX_TAXON_NAME.TAXON_LIST_ITEM_KEY INNER JOIN
                      dbo.TAXON_LIST_ITEM ON
                      dbo.INDEX_TAXON_NAME.RECOMMENDED_TAXON_LIST_ITEM_KEY = dbo.TAXON_LIST_ITEM.TAXON_LIST_ITEM_KEY INNER JOIN
                      dbo.TAXON_VERSION ON dbo.TAXON_LIST_ITEM.TAXON_VERSION_KEY = dbo.TAXON_VERSION.TAXON_VERSION_KEY INNER JOIN
                      dbo.TAXON_GROUP ON dbo.TAXON_VERSION.OUTPUT_GROUP_KEY = dbo.TAXON_GROUP.TAXON_GROUP_KEY ON
                      dbo.SAMPLE.SAMPLE_KEY = dbo.TAXON_OCCURRENCE.SAMPLE_KEY
WHERE     (dbo.TAXON_OCCURRENCE.CHECKED = 1) AND (dbo.TAXON_DETERMINATION.PREFERRED = 1) AND (dbo.LOCATION_NAME.PREFERRED = 1)

Rob Large
Wildlife Sites Officer
Wiltshire & Swindon Biological Records Centre

6

Re: Creating a live link into Recorder using a SQL Server View

I have tested the above view and it seems to work, but the fact that I had to leave the status field out in order to get the speed up is rather disappointing.

I was hoping to use a rather more complex version of this to produce a view of our records with statuses, in order to produce a GIS layer of notable records, but now that I have seen how slow the query is, I think I am going to stick with the report wizard version I have already used and which is much faster.

I realise I am therefore sacrificing the ability to have an up to date view, but if the view takes an hour or more to populate, that's hardly real-time.

Waiting for the wizard to do its stuff it sometimes feels like an eternity, but after today I am quite impressed with the Rec 6 wizard optimization

Rob Large
Wildlife Sites Officer
Wiltshire & Swindon Biological Records Centre

7

Re: Creating a live link into Recorder using a SQL Server View

Hi

Apologies for delay in replying.

That is fantastic help. I'll pass onto our IT chaps and see how they get on. I'll let you know. I'll certainly post any additional progress we make on this (At this stage were only interested in Taxon Occurrances as we have some problems with sites). Thanks again, a real life saver.

Simon