The general method for creating a snapshot 'view' for a specified SnapshotTime is as follows:

  1. Exclude all versions with an effectiveTime greater than the SnapshotTime.

Note: In theory the most recent step could be omitted. However, a release will often be distributed before its effectiveTime . Therefore, this approach is not recommended as a general approach in a live system.

  1. From each set of versions with the same id select the version with the highest (most recent) effectiveTime .

The most flexible approach is to apply this method dynamically so that a different snapshot time can be configured as needed to meet new requirements. The following example code illustrates an implementable approach to this.

SELECT `c`.* FROM `sct2_concept` AS `c`

WHERE `c`.`effectiveTime` = (SELECT MAX(`c2`.`effectiveTime`)

FROM `sct2_concept` `c2`

WHERE `c2`.`id` = `c`.`id`

AND `c2`.`effectiveTime` <= `snapshotTime`())

Figure 24. General form of SQL to create a snapshot view

In this sample code `snapshotTime()` is a function that returns the time to be applied to this snapshot. For the most recent this can be omitted as shown below:

SELECT `c`.* FROM `sct2_concept` AS `c`

WHERE `c`.`effectiveTime` = (SELECT MAX(`c2`.`effectiveTime`)

FROM `sct2_concept` `c2`

WHERE `c2`.`id` = `c`.`id`)

Figure 25. SQL to create the latest snapshot view

Similar views can be created for each of the tables by simply replacing the table name in both the outer and nested queries.

Note: The SQL queries in this and the following section assume applicability of a common versioning view for all . In some case, where a that is being used depends on an earlier version of another , more complex queries and optimizations may be needed. For further information about how dependencies between are represented see details of the Module dependency reference set .