space
Previous Page | Next Page

Model Usage

Usage Scenario: Creating Metadata for a SAS Library


Purpose

This usage scenario describes how to define a SAS library. An XML representation is included to show how the metadata objects are created.


Requirements

This usage scenario assumes that the user has a general understanding of the Resource Submodel, Software Deployment Submodel, and Relational Submodel of the SAS Metadata Model.


Defining a Library

The primary metadata type used to describe a SAS library is the SASLibrary metadata type. SASLibrary has the attributes Engine=, Libref=, and IsPreAssigned= to specify whether the library is pre-assigned in the SAS session. A library that has the IsPreassigned= attribute set to true (1) is assigned during initialization of the SAS session. SASLibrary is a subtype of the RelationalSchema metadata type because like a schema, it groups tables (or data sets). RelationalSchema is a subtype of the DeployedDataPackage metadata type because it contains data items.

In most situations, SASLibrary is associated with another DeployedDataPackage subtype to describe the physical location of its tables. Two DeployedDataPackage subtypes are associated with the UsingPackages association. The associated DeployedDataPackage can be a Directory, DatabaseSchema, or another SASLibrary object. Directory has a DirectoryName= attribute, which stores the name of the directory in the file system. If the Directory object's IsRelative= attribute is set to false (0), then it is assumed that the file system name is complete. If it is set to true (1), then there should be other associated Directory objects. The DirectoryName= value of these associated Directory objects should be prepended to the DirectoryName= value of the base Directory object. When creating multiple levels of a relative directory, the relative names must be stored so that simply prepending the relative name creates a valid directory name. This includes any required delimiters.

The SAS Metadata Model allows table objects to be associated with a single RelationalSchema subtype. To describe tables that reside in a DBMS, associate the table objects with a DatabaseSchema object, which, in turn, is associated with a SASLibrary object. Objects that describe tables that reside in a directory should be associated directly with the SASLibrary object. Each of these scenarios is described in the examples that follow.


Defining a Library with Tables in a Directory

Figure 1 shows the metadata objects that describe a SAS library, directory, and data sets. The library is represented by the SASLibrary metadata type, the directory is represented by the Directory metadata type, and the data set is represented by the PhysicalTable metadata type. In addition, a ServerContext object describes which SAS software can use this library definition.

The metadata objects used to describe a SAS library, directory, and data sets.

Figure 1. The metadata objects used to describe a SAS library, directory, and data sets.

The ServerContext object is associated to the SASLibrary object with the DeployedComponents association (numbered 1 in Figure 1). The Directory object is associated to SASLibrary with the UsingPackages association (numbered 2). This association is used to identify the library's physical location. The DirectoryName= attribute of the Directory object contains the pathname. This attribute value must end with the proper directory delimiter, in this case, a /. The PhysicalTable object is associated to SASLibrary with the Tables association (numbered 3). If a library has tables, then it is the primary or owning library.

The following is an XML representation of the metadata objects in Figure 1. SASLibrary object A1234567.A1000001 describes a library that was created with the default Base engine. It is not a pre-assigned library. The library is located in a directory named /data/sales/ and contains one table named Invoice. The library is used by a SAS Application Server.

<SASLibrary Id="A1234567.A1000001" Name="Sales Library"  Desc="Sales Library"
  Engine="base" IsDBMSLibname="0" Libref="SALES" IsPreassigned="0"  PublicType="Library" 
  UsageVersion="1000000">
  <DeployedComponents>
    <ServerContext Id="A1234567.A4000001" Name="AppServer" ProductName="SAS"
      ClassIdentifier="SAS Application Server" Vendor="SAS Institute" PublicType="ApplicationServer" 
      UsageVersion="1000000"/>
   </DeployedComponents>
   <UsingPackages>
    <Directory Name="Path" Id="A1234567.A2000001" Desc="Directory for Sales Data"
      DirectoryName="/data/sales/" DirectoryRole="LibraryPath" UsageVersion="1000000"/>
  </UsingPackages>
  <Tables>
    <PhysicalTable Id="A1234567.A3000001" Name="Invoice" Desc="Invoice Demo Table" 
    SASTableName="Invoice" TableName="INVOICE" MemberType="DATA"/>
  </Tables>
</SASLibrary>


Defining a Library with Tables in Concatenated Directories

Figure 2 shows the metadata objects used to describe a SAS library that uses concatenated directories. In addition to a SASLibrary metadata object, two Directory objects are defined that describe the physical location of the data, a PhysicalTable metadata object describes the data set, and a ServerContext object describes the SAS software that can use this library definition.

The metadata objects used to describe a SAS library that uses concatentated directories.

Figure 2. The metadata objects used to describe a SAS library that uses concatentated directories.

The Directory objects are associated to the SASLibrary with a UsingPackages association (numbered 2 in Figure 2). For a concatenated library, the order of the directories should be maintained. Associations that are created in the same SAS Metadata Repository are stored in the order in which the associations are defined. If an association list needs to be updated, the order of the associations in the association list can be managed by using the UpdateMetadata Function= directive. For information about the Function= directive, see Using the UpdateMetadata Method in SAS 9.2 Open Metadata Interface: Reference and Usage. The SAS Metadata Server does not guarantee the order of associations in cross-repository references, with a few exceptions. The UsingPackages association is not one of the exceptions.

The following is an XML representation of the metadata objects in Figure 2. The SASLibrary object has a UsingPackages association to two Directory objects. The Directory objects each have a DirectoryName= attribute that specifies the locations of the libraries. The associations are stored in the same SAS Metadata Repository so that they will be stored and retrieved in the order in which they were defined.

 
<SASLibrary Id="A1234567.A1000002" Name="Sales Library"  Desc="Sales Library"
  Engine="base" IsDBMSLibname="0" Libref="SALES" IsPreassigned="0" PublicType="Library" 
  UsageVersion="1000000">
  <UsingPackages>
    <Directory Name="2000 Sales Data Directory" Id="A1234567.A2000001" Desc="Directory for Sales Data"
      DirectoryName="/data/sales/2000/" DirectoryRole="LibraryPath" UsageVersion="1000000"/>
    <Directory Name="2001 Sales Data Directory" Id="A1234567.A2000001" Desc="Directory for Sales Data"
      DirectoryName="/data/sas/2001/" DirectoryRole="LibraryPath" UsageVersion="1000000"/>
  </UsingPackages>
  <Tables>
    <PhysicalTable Id="A1234567.A3000001" Name="Invoice" Desc="Invoice Demo Table" 
    SASTableName="Invoice" TableName="INVOICE" MemberType="DATA"/>
  </Tables>
  <DeployedComponents>
     <ServerContext Id="A1234567.A4000001" Name="AppServer" ProductName="SAS"
      ClassIdentifier="SAS Application Server" Vendor="SAS Institute" 
      PublicType="ApplicationServer" UsageVersion="1000000" />
  </DeployedComponents>
</SASLibrary>


Defining a Library with Tables in a Foreign Database

Figure 3 shows the metadata objects used to describe a SAS library in a foreign database. The database is represented by the DeployedComponent metadata type, the location of the data in the database is represented by the DatabaseSchema metadata type, and the database tables are represented by the PhysicalTable metadata type. The SASClientConnection metadata type describes the connection from the library to the database. The ServerContext metadata type describes which SAS software can use this library definition.

The metadata objects used to describe a SAS library with tables in a foreign database.

Figure 3. The metadata objects used to describe a SAS library with tables in a foreign database.

The database is a ServerComponent (ServerComponent is a subtype of DeployedComponent). It has connection information used by SAS software in the SASClientConnection object. The connection information is found with the SourceConnections association (numbered 1 in Figure 3). The DatabaseSchema is associated to DeployedComponent with the DeployedComponents association (numbered 2) and is an owning package. It has tables associated to it with the Tables association (numbered 3). SASLibrary is associated with DatabaseSchema with the UsingPackages association (numbered 4) and to the SAS Software that uses it with the DeployedComponents association (numbered 2). SASLibrary has a LibraryConnection association (numbered 5) to SASClientConnection to get the connection information for the library.

The following is an XML representation of the metadata objects in Figure 3.

<SASLibrary Id="A34OVRO3.AO00002T" Engine="DB2UNXPC" IsDBMSLibname="1" IsPreassigned="0" 
   Libref="CWM" Name="CWM Library" PublicType="Library" UsageVersion="1000000">
   <DeployedComponents>
       <ServerContext Id="A34OVRO3.AP000001" ClassIdentifier="SAS Application Server" 
         IsLicensed="0" Major="9"  Minor="0" Name="AppServer" ProductName="SAS" 
         SoftwareVersion="9.0" Vendor="SAS Institute" PublicType="ApplicationServer" 
         UsageVersion="1000000"/>
   </DeployedComponents>
   <LibraryConnection>
       <SASClientConnection Objref="A34OVRO3.AK00002T"/>
   </LibraryConnection>
   <UsingPackages>
       <DatabaseSchema Id="A34OVRO3.AN00002T" Name="DB2Schema">
          <Tables>
              <PhysicalTable Id="A34OVRO3.AS000001" DBMSType="DB2UNXPC" 
                IsCompressed="0" IsEncrypted="0" MemberType="DATA" Name="PERIOD" 
                NumRows="-1" SASTableName="PERIOD" TableName="PERIOD"/>
              <PhysicalTable Id="A34OVRO3.AS000002" DBMSType="DB2UNXPC" 
                IsCompressed="0" IsEncrypted="0" MemberType="DATA" 
                MetadataCreated="14May2002:18:08:21" MetadataUpdated="14May2002:18:08:21" 
                Name="PRODUCT" NumRows="-1" SASTableName="PRODUCT" TableName="PRODUCT"/>
           </Tables>
           <DeployedComponents>
               <ServerComponent Id="A34OVRO3.AI00002U" ClassIdentifier="DB2UNXPC" IsLicensed="0" 
               Major="7" Minor="2" Name="My Server" ProductName="DB2UNXPC" SoftwareVersion="7.2" 
               Vendor="International Business Machines Corporation">
                   <SourceConnections>
                      <SASClientConnection Id="A34OVRO3.AK00002T" ApplicationProtocol="DB2UDBPROTOCOL" 
                      AuthenticationType="user/password" CommunicationProtocol="TCP" 
                      Name="Connection: My Server" Port="0"/>
                    </SourceConnections>
               </ServerComponent>
           </DeployedComponents>
       </DatabaseSchema>
    </UsingPackages>
</SASLibrary>

The XML defines a SASLibrary object with a DeployedComponents association to a ServerContext object, a LibraryConnection association to a SASClientConnection object, and a UsingPackages association to a DatabaseSchema object. The definition of the DatabaseSchema object defines a Tables association to the two PhysicalTable objects, a DeployedComponents association to the ServerComponent object describing the database server, and a SourceConnections association between the ServerComponent object and the SASClientConnection object.

space
Previous Page | Next Page | Top of Page