Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

view: cs_fieldcollectiondates (refreshed 2012-03-12)

Code Block
sql
sql
SELECT
 CAST(o.objectID AS VARCHAR) objectID,
 d.dateText fieldCollectionDate_dateDisplayDate,
 (CASE WHEN d.dateBegSearch != '0' THEN d.dateBegSearch END) fieldCollectionDate_dateEarliestSingleYear,
 (CASE WHEN d.dateEndSearch != '0' THEN d.dateEndSearch END) fieldCollectionDate_dateLatestYear,
 d.dayBegSearch fieldCollectionDate_dateEarliestSingleDay,
 d.dayEndSearch fieldCollectionDate_dateLatestDay,
 d.monthBegSearch fieldCollectionDate_dateEarliestSingleMonth,
 d.monthEndSearch fieldCollectionDate_dateLatestMonth
FROM
 ObjDates d
 JOIN Objects o on d.objectID = o.objectID
WHERE
 o.IsVirtual = 0 AND o.IsTemplate = 0
 AND lower(d.eventType) in ('date collected', 'secondary collection date', 'tertiary collection date')
UNION ALL
SELECT
 CAST(o.objectID AS VARCHAR) objectID,
 o.dated fieldCollectionDate_dateDisplayDate,
 (CASE WHEN o.dateBegin != '0' THEN o.dateBegin END) fieldCollectionDate_dateEarliestSingleYear,
 (CASE WHEN o.dateEnd != '0' THEN o.dateEnd END) fieldCollectionDate_dateLatestYear,
 null fieldCollectionDate_dateEarliestSingleDay,
 null fieldCollectionDate_dateLatestDay,
 null fieldCollectionDate_dateEarliestSingleMonth,
 null fieldCollectionDate_dateLatestMonth
FROM
 Objects o
WHERE
 o.IsVirtual = 0 AND o.IsTemplate = 0
 AND o.dated IS NOT NULL OR o.dateBegin != '0' OR o.dateEnd != '0'
UNION ALL
SELECT
 CAST(o.objectID AS VARCHAR) objectID,
 (CASE WHEN LEN(x.displayDate) > 0 THEN x.displayDate END) fieldCollectionDate_dateDisplayDate,
 (CASE WHEN x.dateBegin != '0' THEN x.dateBegin END) fieldCollectionDate_dateEarliestSingleYear,
 (CASE WHEN x.dateEnd != '0' THEN x.dateEnd END) fieldCollectionDate_dateLatestYear,
 NULL fieldCollectionDate_dateEarliestSingleDay,
 NULL fieldCollectionDate_dateLatestDay,
 NULL fieldCollectionDate_dateEarliestSingleMonth,
 NULL fieldCollectionDate_dateLatestMonth
FROM
 ConXrefs x
 JOIN roles r ON x.roleID = r.roleID
 JOIN objects o ON x.ID = o.objectID
WHERE
 x.tableID = 108
 AND x.active = 1
 AND o.IsVirtual = 0 AND o.IsTemplate = 0
 AND lower(r.ROLE) IN ('collector', 'secondary collector', 'tertiary collector')
 AND (x.dateBegin != 0 OR (x.displayDate IS NOT NULL AND len(x.displayDate) > 0))
;

...

TMS table name

TMS field name

CSpace field name

notes

Objects

MTB_PlaceTermID

fieldCollectionPlace

reference to Place Authority

Objects

Provenance

fieldLocVerbatim

 

SiteObjXrefs

SiteID

fieldCollectionPlace

FK to Sites table to get MTB_PlaceTermID1; reference to Place Authority

SiteObjXrefs

Subsite1/Subsite2/Subsite3

fieldLocVerbatim

 

ObjGeography

MTB_PlaceTermID

fieldCollectionPlace

reference to Place Authority

ThesXrefs

TermID

fieldCollectionPlace

reference to Place Authority

sql query

view:  cs_fieldcollectionplaces (refreshed 2012-03-12)

Code Block
sql
sql
SELECT
 CAST(o.objectID AS VARCHAR) objectID,
 o.MTB_PlaceTermID fieldCollectionPlace,
 o.provenance fieldLocVerbatim
FROM
 Objects o
WHERE
 o.IsVirtual = 0 AND o.IsTemplate = 0
 AND (o.MTB_PlaceTermID IS NOT NULL OR o.provenance IS NOT NULL)
UNION ALL
SELECT
 CAST(o.objectID AS VARCHAR) objectID,
 s.MTB_PlaceTermID1 fieldCollectionPlace,
 COALESCE(x.subsite1, '') + (CASE WHEN x.subsite1 IS NOT NULL AND x.subsite2 IS NOT NULL THEN ', ' ELSE '' END) + COALESCE(x.subsite2, '') + (CASE WHEN x.subsite3 IS NOT NULL THEN ', ' + x.subsite3 ELSE '' END) fieldLocVerbatim
FROM
 SiteObjXrefs x
 JOIN Objects o ON x.objectID = o.objectID
 JOIN Sites s ON x.siteID = s.siteID
WHERE
 o.IsVirtual = 0 AND o.IsTemplate = 0
 AND s.MTB_PlaceTermID1 IS NOT NULL
UNION ALL
SELECT
 CAST(o.objectID AS VARCHAR) objectID,
 g.MTB_PlaceTermID fieldCollectionPlace,
 NULL fieldLocVerbatim
FROM
 ObjGeography g
 JOIN Objects o ON g.objectID = o.objectID
WHERE
 o.IsVirtual = 0 AND o.IsTemplate = 0
 AND g.MTB_PlaceTermID IS NOT NULL
UNION ALL
SELECT
 CAST(o.objectID AS VARCHAR) objectID,
 x.termID fieldCollectionPlace,
 NULL fieldLocVerbatim
FROM
 ThesXrefs x
 JOIN ThesXrefTypes t ON x.thesXrefTypeID = t.thesXrefTypeID
 JOIN Objects o ON x.ID = o.objectID
WHERE
 x.tableID = 108
 AND x.active = 1
 AND o.IsVirtual = 0 AND o.IsTemplate = 0
 AND x.thesXrefTableID = 346
 AND lower(t.thesXrefType) IN ('archaeological site', 'card header', 'provenience')
;

...

TMS table name

TMS field name

CSpace field name

notes

ConXrefs

constituentID

fieldCollector

reference to Person or Organization

sql query

view: cs_fieldcollectorsfieldcollectors (refreshed 2012-03-12)

Code Block
sql
sql
SELECT
 CAST(o.objectID AS VARCHAR) objectID,
 x.constituentID fieldCollector
FROM
 ConXrefs x
 JOIN roles r ON x.roleID = r.roleID
 JOIN objects o ON x.ID = o.objectID
WHERE
 x.tableID = 108
 AND x.active = 1
 AND  o.IsVirtual = 0 AND o.IsTemplate = 0
 AND lower(r.ROLE) IN ('collector', 'secondary collector', 'tertiary collector')
;

...

TMS table name

TMS field name

CSpace field name

notes

ObjDates

Remarks

fieldCollectionNote

pertains to fieldCollectionDate

SiteObjXrefs

Remarks

fieldCollectionNote

pertains to fieldCollectionPlace

ThesXrefs

Remarks

fieldCollectionNote

pertains to fieldCollectionPlace

ConXrefs

Remarks

fieldCollectionNote

pertains to fieldCollector

sql query

view:  view not yet created

Code Block
sql
sql
SELECT
 CAST(o.objectID AS VARCHAR) objectID,
 'Field collection date: ' + d.remarks fieldCollectionNote
FROM
 ObjDates d
 JOIN Objects o on d.objectID = o.objectID
WHERE
 o.IsVirtual = 0 AND o.IsTemplate = 0
 AND lower(d.eventType) IN ('date collected', 'secondary collection date', 'tertiary collection date')
 AND d.remarks IS NOT NULL
UNION ALL
SELECT
 CAST(o.objectID AS VARCHAR) objectID,
 'Field collection place: ' + x.remarks fieldCollectionNote
FROM
 SiteObjXrefs x
 JOIN Objects o ON x.objectID = o.objectID
WHERE
 o.IsVirtual = 0 AND o.IsTemplate = 0
 AND x.remarks IS NOT NULL
UNION ALL
SELECT
  CAST(o.objectID AS VARCHAR) objectID,
 'Field collection place: ' + x.remarks fieldCollectionNote
FROM
  ThesXrefs x
 JOIN ThesXrefTypes t ON x.thesXrefTypeID = t.thesXrefTypeID
 JOIN Objects o ON x.ID = o.objectID
WHERE 
 x.tableID = 108 
 AND x.active = 1
 AND o.IsVirtual = 0 AND o.IsTemplate = 0
 AND x.thesXrefTableID = 346
 AND lower(t.thesXrefType) IN ('archaeological site', 'card header', 'provenience')
 AND x.remarks IS NOT NULL AND x.remarks != ''
UNION ALL
SELECT
 CAST(o.objectID AS VARCHAR) objectID,
 'Field collector: ' + x.remarks fieldCollectionNote
FROM
 ConXrefs x
 JOIN roles r ON x.roleID = r.roleID
 JOIN objects o ON x.ID = o.objectID
WHERE
 x.tableID = 108
 AND x.active = 1
 AND o.IsVirtual = 0 AND o.IsTemplate = 0
 AND lower(r.ROLE) IN ('collector', 'secondary collector', 'tertiary collector')
 AND x.remarks IS NOT NULL
ORDER BY objectID
; 

notes

  • NOTE: multiple notes per object should be concatenated into single (non-repeating) field fieldCollectionNote, separated by line breaks