CREATE VIEW UMLParts AS 
  SELECT
    a.*,
    e.baseName as id,
    b.umlName,
    b.umlType
  FROM
    OIDOVers a
    INNER JOIN UMLPart_version b ON a.OID=b.OID AND a.OVer=b.OVer
    INNER JOIN TCVersionClass c ON c.OID=b.OID AND c.OVer=b.OVer
    LEFT OUTER JOIN TCSourceObject d ON d.OID=c.osrelTCSourceObjct
    LEFT OUTER JOIN FHCPath e ON e.OID=d.osrelNuPathId;

CREATE VIEW UMLPartData AS 
  SELECT
    a.*,
    e.baseName as id,
    b.umlName,
    b.umlType
  FROM
    OIDOVers a
    INNER JOIN UMLPart_version b ON a.OID=b.OID AND a.OVer=b.OVer
    INNER JOIN TCVersionClass c ON c.OID=b.OID AND c.OVer=b.OVer
    LEFT OUTER JOIN TCSourceObject d ON d.OID=c.osrelTCSourceObjct
    LEFT OUTER JOIN ManyPtrTable g ON g.classAttrib='UMLPart_version.umlOwns' AND
      g.SourceOID=b.OID AND g.SourceOVer=b.OVer
    LEFT OUTER JOIN FHCPath e ON e.OID=d.osrelNuPathId;

CREATE VIEW UMLPartData0 AS 
  SELECT
    a.*,
    e.baseName as id,
    b.umlName,
    b.umlType
  FROM
    OIDOVers a
    INNER JOIN UMLPart_version b ON a.OID=b.OID AND a.OVer=b.OVer
    INNER JOIN TCVersionClass c ON c.OID=b.OID AND c.OVer=b.OVer
    LEFT OUTER JOIN TCSourceObject d ON d.OID=c.osrelTCSourceObjct
    LEFT OUTER JOIN FHCPath e ON e.OID=d.osrelNuPathId;

CREATE VIEW UMLPartData1 AS 
  SELECT
    a.*,
    e.baseName as id,
    b.umlName,
    b.umlType,
    k.baseName as childid,
    h.umlName as childUmlName,
    h.umlType as childUmlType
  FROM
    OIDOVers a
    INNER JOIN UMLPart_version b ON a.OID=b.OID AND a.OVer=b.OVer
    INNER JOIN TCVersionClass c ON c.OID=b.OID AND c.OVer=b.OVer
    LEFT OUTER JOIN TCSourceObject d ON d.OID=c.osrelTCSourceObjct
    LEFT OUTER JOIN OIDOVers g ON g.OID=a.OID AND  g.contextOID=a.contextOID
    LEFT OUTER JOIN UMLPart_version h ON h.umlOwnedBy=b.OID AND h.OVer=g.OVer
    LEFT OUTER JOIN TCVersionClass i ON i.OID=h.OID AND i.OVer=h.OVer
    LEFT OUTER JOIN FHCPath e ON e.OID=d.osrelNuPathId
    LEFT OUTER JOIN TCSourceObject j ON j.OID=b.OID
    LEFT OUTER JOIN FHCPath k ON k.OID=j.osrelNuPathId;

CREATE VIEW UMLUsesView AS 
  SELECT
    a.*,
    e.baseName as id,
    b.umlName,
    b.umlType,
    h.umlRelType
  FROM
    OIDOVers a
    INNER JOIN UMLPart_version b ON a.OID=b.OID AND a.OVer=b.OVer
    INNER JOIN TCVersionClass c ON c.OID=b.OID AND c.OVer=b.OVer
    LEFT OUTER JOIN TCSourceObject d ON d.OID=c.osrelTCSourceObjct
    LEFT OUTER JOIN ADLink_source f ON f.classAttr='UMLPart_version.umlUsedBy' AND
      f.sourceOID=b.OID AND f.sourceOVer=b.OVer
    LEFT OUTER JOIN adobjectFind g ON g.OID=f.relOID AND g.OVer=f.relOVer AND
       g.className='UMLRel' AND
       g.contextRelease=a.contextRelease AND g.contextName=a.contextName
    LEFT OUTER JOIN FHCPath e ON e.OID=d.osrelNuPathId
    LEFT OUTER JOIN UMLRel h ON h.OID=g.OID AND h.OVer=g.OVer;

CREATE VIEW UMLUsesView1 AS 
  SELECT
    a.*,
    e.baseName as id,
    b.umlName,
    b.umlType,
    h.umlRelType,
    n.baseName as childid,
    k.umlName as childUmlName,
    k.umlType as childUmlType
  FROM
    OIDOVers a
    INNER JOIN UMLPart_version b ON a.OID=b.OID AND a.OVer=b.OVer
    INNER JOIN TCVersionClass c ON c.OID=b.OID AND c.OVer=b.OVer
    LEFT OUTER JOIN TCSourceObject d ON d.OID=c.osrelTCSourceObjct
    LEFT OUTER JOIN ADLink_source f ON f.classAttr='UMLPart_version.umlUsedBy' AND
      f.sourceOID=b.OID AND f.sourceOVer=b.OVer
    LEFT OUTER JOIN adobjectFind g ON g.OID=f.relOID AND g.OVer=f.relOVer AND
       g.className='UMLRel' AND
       g.contextRelease=a.contextRelease AND g.contextName=a.contextName
    LEFT OUTER JOIN FHCPath e ON e.OID=d.osrelNuPathId
    LEFT OUTER JOIN UMLRel h ON h.OID=g.OID AND h.OVer=g.OVer
    LEFT OUTER JOIN ADLink i ON i.OID=h.OID AND i.OVer=h.OVer
    LEFT OUTER JOIN OIDOVers j ON j.OID=i.adTarget AND  j.contextOID=a.contextOID
    LEFT OUTER JOIN UMLPart_version k ON k.OID=i.adTarget AND k.OVer=j.OVer
    LEFT OUTER JOIN TCVersionClass l ON l.OID=k.OID AND l.OVer=k.OVer
    LEFT OUTER JOIN TCSourceObject m ON m.OID=l.osrelTCSourceObjct
    LEFT OUTER JOIN FHCPath n ON n.OID=m.osrelNuPathId;

