CREATE VIEW AccessTable AS 
  SELECT
    a.OVer,
    a.OID,
    a.osrelCompId as compId,
    a.osrelUserId as userId,
    a.authorityName,
    a.authorityType
  FROM
    FHCAccess a;

CREATE VIEW AccessView AS 
  SELECT
    a.OVer,
    a.OID,
    a.osrelCompId as compId,
    b.name as compName,
    a.osrelUserId as userId,
    c.login as userLogin,
    c.name as userName,
    c.area as userArea,
    a.authorityName,
    a.authorityType
  FROM
    FHCAccess a
    INNER JOIN FHCComp b ON b.OID=a.osrelCompId
    INNER JOIN FHCUser c ON c.OID=a.osrelUserId;

CREATE VIEW AccessDownView AS 
  SELECT DISTINCT
    a.OVer,
    a.OID,
    a.authorityName,
    a.authorityType,
    a.osrelCompId as compId,
    b.oid as parentCompId,
    c.osrelParentId as parentId,
    d.name as compName,
    b.name as childCompName,
    a.osrelUserId as userId,
    e.login as userLogin,
    e.name as userName,
    e.area as userArea
  FROM
    FHCAccess a
    INNER JOIN FHCComp b ON b.OID=a.osrelCompId
    INNER JOIN FHCCompMember c ON c.osrelChildId=b.oid
    INNER JOIN FHCComp d ON d.OID=c.osrelParentId
    INNER JOIN FHCUser e ON e.OID=a.osrelUserId;

CREATE VIEW AccessUpView AS 
  SELECT
    a.OVer,
    a.OID,
    a.authorityName,
    a.authorityType,
    a.osrelCompId as compId,
    b.oid as childCompId,
    c.osrelChildId as childId,
    d.name as compName,
    b.name as parentName,
    a.osrelUserId as userId,
    e.login as userLogin,
    e.name as userName,
    e.area as userArea
  FROM
    FHCAccess a
    INNER JOIN FHCComp b ON b.OID=a.osrelCompId
    INNER JOIN FHCCompMember c ON c.osrelParentId=b.oid
    INNER JOIN FHCComp d ON d.OID=c.osrelChildId
    INNER JOIN FHCUser e ON e.OID=a.osrelUserId;

CREATE VIEW AccessNInheritView AS 
  SELECT
    a.OVer,
    a.OID,
    a.osrelUserId as userId,
    a.osrelCompId as compId,
    a.authorityType,
    a.authorityName,
    b.action
  FROM
    FHCAccess a
    INNER JOIN FHCAuthority b ON b.name=a.authorityName;

CREATE VIEW AccessFastView AS 
  SELECT
    a.OVer,
    a.OID,
    a.osrelUserId as userId,
    a.authorityType,
    a.authorityName,
    b.action,
    c.osrelChildId as compId
  FROM
    FHCAccess a
    INNER JOIN FHCAuthority b ON b.name=a.authorityName
    INNER JOIN FHCCompMember c ON c.osrelParentId=a.osrelCompId;

CREATE VIEW Approvals AS 
  SELECT
    a.OVer,
    a.OID,
    a.osrelTrackId as trackId,
    b.osrelWorkAreaId as workAreaId,
    a.osrelUserId as attribute,
    a.state,
    a.addDate,
    a.lastUpdate
  FROM
    FHCApproval a
    INNER JOIN FHCTrack b ON b.OID=a.osrelTrackId;

CREATE VIEW ApprovalView AS 
  SELECT
    a.OVer,
    a.OID,
    a.osrelTrackId as trackId,
    b.osrelWorkAreaId as workAreaId,
    c.name as workAreaName,
    b.osrelReleaseId as releaseId,
    d.name as releaseName,
    b.osrelDefectId as defectId,
    e.prefix as defectPrefix,
    e.name as defectName,
    e.reference as defectReference,
    e.abstract as defectAbstract,
    e.type as defectType,
    a.osrelUserId as userId,
    f.name as userName,
    f.login as userLogin,
    f.area as userArea,
    a.state,
    a.addDate,
    a.lastUpdate
  FROM
    FHCApproval a
    INNER JOIN FHCTrack b ON b.OID=a.osrelTrackId
    INNER JOIN FHCWorkArea c ON c.OID=b.osrelWorkAreaId
    INNER JOIN FHCRelease d ON d.OID=b.osrelReleaseId
    INNER JOIN FHCUser f ON f.OID=a.osrelUserId
    LEFT OUTER JOIN FHCDefect e ON e.OID=b.osrelDefectId;

CREATE VIEW Approvers AS 
  SELECT
    a.OVer,
    a.OID,
    a.osrelReleaseId as releaseId,
    a.osrelUserId as userId
  FROM
    FHCApprover a;

CREATE VIEW ApproverView AS 
  SELECT
    a.OVer,
    a.OID,
    a.osrelReleaseId as releaseId,
    b.name as releaseName,
    a.osrelUserId as userId,
    c.login as userLogin,
    c.name as userName,
    c.area as userArea
  FROM
    FHCApprover a
    INNER JOIN FHCRelease b ON b.OID=a.osrelReleaseId
    INNER JOIN FHCUser c ON c.OID=a.osrelUserId;

CREATE VIEW Authority AS 
  SELECT
    a.OVer,
    a.OID,
    a.name,
    a.action
  FROM
    FHCAuthority a;

CREATE VIEW Becomes AS 
  SELECT
    a.OVer,
    a.OID,
    a.osrelUserId as userId,
    a.osrelBecomeUserId as becomeUserId,
    a.addDate
  FROM
    FHCBecome a;

CREATE VIEW BecomeView AS 
  SELECT
    a.OVer,
    a.OID,
    a.osrelUserId as userId,
    b.login as userLogin,
    a.osrelBecomeUserId as becomeUserId,
    c.addDate,
    c.login as becomeUserLogin,
    c.name as becomeUserName,
    c.area as becomeUserArea
  FROM
    FHCBecome a
    LEFT OUTER JOIN FHCUser b ON b.OID=a.osrelUserId
    LEFT OUTER JOIN FHCUser c ON c.OID=a.osrelBecomeUserId;

CREATE VIEW Builders AS 
  SELECT
    a.OVer,
    a.OID,
    a.oid as id,
    a.sequenceId,
    a.osrelReleaseId as releaseId,
    a.description as name,
    a.parameters,
    a.rebuildTimeStamp,
    a.addDate,
    a.dropDate,
    a.lastUpdate,
    a.buildScript,
    a.goodRCEvaluator,
    a.goodRCEvaluator as RCCondition,
    a.rcValue,
    a.bulkTypeText as bulkType,
    a.bulkType as bulkTypeNum,
    a.environment,
    a.timeout,
    a.billOfMaterials,
    a.processorOptions as setupOptions,
    a.sqlText
  FROM
    FHCBuilder a;

CREATE VIEW BuilderView AS 
  SELECT
    a.OVer,
    a.OID,
    a.oid as id,
    a.osrelReleaseId as releaseId,
    b.name as releaseName,
    a.description as name,
    a.parameters,
    a.rebuildTimeStamp,
    a.addDate,
    a.dropDate,
    a.lastUpdate,
    a.buildScript,
    a.goodRCEvaluator as RCCondition,
    a.rcValue,
    a.bulkTypeText as bulkType,
    a.bulkType as bulkTypeNum,
    a.environment,
    a.timeout,
    a.billOfMaterials,
    a.processorOptions as setupOptions,
    a.sqlText
  FROM
    FHCBuilder a
    INNER JOIN FHCRelease b ON b.OID=a.osrelReleaseId;

CREATE VIEW Changes AS 
  SELECT
    a.OVer,
    a.OID,
    a.osrelPathId as pathId,
    a.osrelTrackId as trackId,
    b.osrelWorkAreaId as workAreaId,
    b.state as workAreaState,
    a.osrelFileId as fileId,
    c.osrelCollectorId as partId,
    d.typeName as partType,
    e.versionId,
    e.osrelTCSourceObjct as sourceId,
    f.changeDate,
    a.osrelLevelId as driverId,
    a.type as changeType,
    a.osrelUserId as userId
  FROM
    FHCChange a
    INNER JOIN FHCFile c ON c.OID=a.osrelFileId
    INNER JOIN TCCollectorClass d ON d.OID=c.osrelCollectorId
    INNER JOIN TCVersionClass e ON e.OIDC=a.osrelVersionId
    INNER JOIN TCSourceObject f ON f.OID=e.osrelTCSourceObjct
    LEFT OUTER JOIN FHCTrack b ON b.OID=a.osrelTrackId;

CREATE VIEW ChangeView AS 
  SELECT
    a.OVer,
    a.OID,
    a.osrelPathId as pathId,
    b.name as pathName,
    a.osrelTrackId as trackId,
    c.osrelWorkAreaId as workAreaId,
    d.name as workAreaName,
    c.osrelDefectId as defectId,
    e.prefix as defectPrefix,
    e.name as defectName,
    e.reference as defectReference,
    e.abstract as defectAbstract,
    e.type as defectType,
    c.state as workAreaState,
    a.osrelFileId as fileId,
    f.osrelCollectorId as partId,
    g.typeName as partType,
    f.osrelReleaseId as releaseId,
    h.name as releaseName,
    i.osrelOVersionId as tipOVerId,
    j.SID as committedVersion,
    k.versionId,
    k.osrelOVersionId as oVersionId,
    l.SID as versionSID,
    k.osrelTCSourceObjct as sourceId,
    m.changeDate,
    a.osrelLevelId as driverId,
    n.name as driverName,
    a.type as changeType,
    a.osrelUserId as userId,
    o.login as userLogin,
    o.name as userName,
    o.area as userArea
  FROM
    FHCChange a
    LEFT OUTER JOIN FHCTrack c ON c.OID=a.osrelTrackId
    LEFT OUTER JOIN FHCWorkArea d ON d.OID=c.osrelWorkAreaId
    LEFT OUTER JOIN FHCLevel n ON n.OID=a.osrelLevelId
    LEFT OUTER JOIN FHCDefect e ON e.OID=c.osrelDefectId
    INNER JOIN FHCFile f ON f.OID=a.osrelFileId
    INNER JOIN FHCRelease h ON h.OID=f.osrelReleaseId
    LEFT OUTER JOIN FHCPath b ON b.OID=a.osrelPathId
    INNER JOIN TCCollectorClass g ON g.OID=f.osrelCollectorId
    INNER JOIN TCVersionClass k ON k.OIDC=a.osrelVersionId
    INNER JOIN FHCOVersion l ON l.OID=k.osrelOVersionId
    INNER JOIN TCSourceObject m ON m.OID=k.osrelTCSourceObjct
    LEFT OUTER JOIN TCVersionClass i ON i.OIDC=f.osrelTipVersionId
    LEFT OUTER JOIN FHCUser o ON o.OID=a.osrelUserId
    LEFT OUTER JOIN FHCOVersion j ON j.OID=i.osrelOVersionId;

CREATE VIEW BchangeView AS 
  SELECT
    a.OVer,
    a.OID,
    a.osrelPathId as pathId,
    b.name as pathName,
    a.osrelTrackId as trackId,
    c.osrelWorkAreaId as workAreaId,
    d.name as workAreaName,
    c.osrelDefectId as defectId,
    e.prefix as defectPrefix,
    e.name as defectName,
    e.reference as defectReference,
    e.abstract as defectAbstract,
    e.type as defectType,
    a.osrelFileId as fileId,
    f.osrelCollectorId as partId,
    g.typeName as partType,
    f.osrelReleaseId as releaseId,
    h.name as releaseName,
    i.osrelOVersionId as tipOVerId,
    j.SID as committedVersion,
    f.osrelCompId as compId,
    k.name as compName,
    l.versionId,
    m.SID as versionSID,
    a.osrelLevelId as driverId,
    n.name as driverName,
    a.type as changeType,
    a.osrelUserId as userId
  FROM
    FHCChange a
    LEFT OUTER JOIN FHCTrack c ON c.OID=a.osrelTrackId
    LEFT OUTER JOIN FHCWorkArea d ON d.OID=c.osrelWorkAreaId
    LEFT OUTER JOIN FHCDefect e ON e.OID=c.osrelDefectId
    LEFT OUTER JOIN FHCLevel n ON n.OID=a.osrelLevelId
    INNER JOIN FHCFile f ON f.OID=a.osrelFileId
    INNER JOIN FHCRelease h ON h.OID=f.osrelReleaseId
    INNER JOIN TCCollectorClass g ON g.OID=f.osrelCollectorId
    INNER JOIN FHCComp k ON k.OID=f.osrelCompId
    INNER JOIN TCVersionClass l ON l.OIDC=a.osrelVersionId
    INNER JOIN FHCOVersion m ON m.OID=l.osrelOVersionId
    LEFT OUTER JOIN FHCPath b ON b.OID=a.osrelPathId
    LEFT OUTER JOIN TCVersionClass i ON i.OIDC=f.osrelTipVersionId
    LEFT OUTER JOIN FHCOVersion j ON j.OID=i.osrelOVersionId;

CREATE VIEW ChangeExtractView AS 
  SELECT
    a.OVer,
    a.OID,
    a.osrelPathId as pathId,
    b.name as pathName,
    a.osrelTrackId as trackId,
    c.osrelWorkAreaId as workAreaId,
    c.state as workAreaState,
    a.osrelFileId as fileId,
    d.osrelCollectorId as partId,
    e.typeName as partType,
    d.osrelTipVersionId,
    g.versionId,
    g.osrelTCSourceObjct as partSourceId,
    g.osrelOVersionId as oVersionId,
    h.SID as versionSID,
    a.osrelLevelId as driverId,
    a.type as changeType
  FROM
    FHCChange a
    INNER JOIN FHCFile d ON d.OID=a.osrelFileId
    INNER JOIN TCCollectorClass e ON e.OID=d.osrelCollectorId
    INNER JOIN TCVersionClass g ON g.OIDC=a.osrelVersionId
    INNER JOIN FHCOVersion h ON h.OID=g.osrelOVersionId
    LEFT OUTER JOIN FHCPath b ON b.OID=a.osrelPathId
    LEFT OUTER JOIN FHCTrack c ON c.OID=a.osrelTrackId;

CREATE VIEW Collisions AS 
  SELECT
    a.OVer,
    a.OID,
    a.osrelFileId as fileId,
    b.osrelCollectorId as partId,
    c.typeName as partType,
    a.osrelWorkAreaId as workAreaId,
    a.osrelAltWorkAreaId as altWorkAreaId,
    a.state,
    a.addDate,
    a.lastUpdate,
    a.localPartVersionId,
    a.altPartVersionId,
    a.resolvedPartVrsnId
  FROM
    FHCCollision a
    INNER JOIN FHCFile b ON b.OID=a.osrelFileId
    INNER JOIN TCCollectorClass c ON c.OID=b.osrelCollectorId;

CREATE VIEW CollisionView AS 
  SELECT
    a.OVer,
    a.OID,
    a.osrelFileId as fileId,
    b.osrelPathId as pathId,
    c.name as pathName,
    b.osrelCollectorId as partId,
    d.typeName as partType,
    a.osrelWorkAreaId as workAreaId,
    e.name as workAreaName,
    e.osrelReleaseId as releaseId,
    f.name as releaseName,
    f.process as relProcess,
    a.osrelAltWorkAreaId as altWorkAreaId,
    a.state,
    a.addDate,
    a.lastUpdate,
    a.osrelLocalVersinId as localOVersionId,
    g.SID as localVersion,
    a.osrelAltVersionId as altOVersionId,
    h.SID as alternateVersion,
    j.changeType as localChangeType,
    j.osrelTCSourceObjct as localSourceId,
    l.changeType as altChangeType,
    l.osrelTCSourceObjct as altSourceId,
    n.changeType as resolvedChangeType,
    n.osrelTCSourceObjct as resolvedSourceId
  FROM
    FHCCollision a
    INNER JOIN FHCFile b ON b.OID=a.osrelFileId
    INNER JOIN FHCPath c ON c.OID=b.osrelPathId
    INNER JOIN TCCollectorClass d ON d.OID=b.osrelCollectorId
    INNER JOIN FHCOVersion g ON g.OID=a.osrelLocalVersinId
    INNER JOIN FHCOVersion h ON h.OID=a.osrelAltVersionId
    INNER JOIN TCVersionClass j ON j.OIDC=a.localPartVersionId
    INNER JOIN TCVersionClass l ON l.OIDC=a.altPartVersionId
    LEFT OUTER JOIN FHCWorkArea e ON e.OID=a.osrelWorkAreaId
    LEFT OUTER JOIN TCVersionClass n ON n.OIDC=a.resolvedPartVrsnId
    LEFT OUTER JOIN FHCRelease f ON f.OID=e.osrelReleaseId;

CREATE VIEW Components AS 
  SELECT
    a.OVer,
    a.OID,
    a.oid as id,
    a.name,
    a.osrelUserId as userId,
    a.featureDSR,
    a.featureVerify,
    a.defectDSR,
    a.defectVerify,
    a.description,
    a.addDate,
    a.dropDate,
    a.lastUpdate,
    a.process as compProcess
  FROM
    FHCComp a;

CREATE VIEW CompView AS 
  SELECT
    a.OVer,
    a.OID,
    a.oid as id,
    a.name,
    a.osrelUserId as userId,
    b.login as userLogin,
    b.name as userName,
    b.area as userArea,
    a.featureDSR,
    a.featureVerify,
    a.defectDSR,
    a.defectVerify,
    a.description,
    a.addDate,
    a.dropDate,
    a.lastUpdate,
    a.process as compProcess
  FROM
    FHCComp a
    INNER JOIN FHCUser b ON b.OID=a.osrelUserId;

CREATE VIEW CompMembers AS 
  SELECT
    a.OVer,
    a.OID,
    a.osrelParentId as parentId,
    a.osrelChildId as childId,
    a.rank,
    a.reference
  FROM
    FHCCompMember a;

CREATE VIEW CompMemberView AS 
  SELECT
    a.OVer,
    a.OID,
    a.osrelParentId as parentId,
    b.name as parentCompName,
    a.osrelChildId as childId,
    c.name as childCompName,
    a.rank,
    a.reference
  FROM
    FHCCompMember a
    INNER JOIN FHCComp b ON b.OID=a.osrelParentId
    INNER JOIN FHCComp c ON c.OID=a.osrelChildId;

CREATE VIEW CfgComProc AS 
  SELECT
    a.OVer,
    a.OID,
    a.name,
    a.config
  FROM
    FHCCfgComProc a;

CREATE VIEW Config AS 
  SELECT
    a.OVer,
    a.OID,
    a.type as configType,
    a.name,
    a.dflt,
    a.value1,
    a.value2,
    a.description,
    a.kind,
    a.driverId,
    a.driverSeq,
    a.dependent,
    a.dependSeq,
    a.choiceOrder,
    a.helpText
  FROM
    FHCConfig a;

CREATE VIEW Coreqs AS 
  SELECT
    a.OVer,
    a.OID,
    a.osrelTrackId as trackId,
    b.osrelWorkAreaId as workAreaId,
    a.groupId
  FROM
    FHCCoreq a
    INNER JOIN FHCTrack b ON b.OID=a.osrelTrackId;

CREATE VIEW CoreqView AS 
  SELECT
    a.OVer,
    a.OID,
    a.osrelTrackId as trackId,
    b.osrelWorkAreaId as workAreaId,
    c.name,
    b.osrelReleaseId as releaseId,
    d.name as releaseName,
    b.osrelDefectId as defectId,
    e.prefix as defectPrefix,
    e.name as defectName,
    e.type as defectType,
    b.state,
    a.groupId
  FROM
    FHCCoreq a
    INNER JOIN FHCTrack b ON b.OID=a.osrelTrackId
    INNER JOIN FHCWorkArea c ON c.OID=b.osrelWorkAreaId
    INNER JOIN FHCRelease d ON d.OID=b.osrelReleaseId
    LEFT OUTER JOIN FHCDefect e ON e.OID=b.osrelDefectId;

CREATE VIEW Defects AS 
  SELECT
    a.OVer,
    a.OID,
    a.oid as id,
    a.type as defectType,
    a.prefix,
    a.name,
    a.osrelCompId as compId,
    a.osrelReleaseId as releaseId,
    a.envName,
    a.state,
    a.severity,
    a.abstract,
    a.reference,
    a.answer,
    a.levelName as driverName,
    a.lastUpdate,
    a.addDate,
    a.assignDate,
    a.responseDate,
    a.endDate,
    a.osrelOriginId as originId,
    a.osrelOwnerId as ownerId,
    a.age,
    a.duplicate,
    a.notesDB,
    a.notesID
  FROM
    FHCDefect a;

CREATE VIEW DefectMiniView AS 
  SELECT
    a.OVer,
    a.OID,
    a.oid as id,
    a.type as defectType,
    a.prefix,
    a.name,
    a.osrelCompId as compId,
    b.name as compName,
    a.osrelReleaseId as releaseId,
    c.name as releaseName,
    a.envName,
    a.state,
    a.severity,
    a.abstract,
    a.reference,
    a.answer,
    a.levelName as driverName,
    a.lastUpdate,
    a.addDate,
    a.assignDate,
    a.responseDate,
    a.endDate,
    a.osrelOriginId as originId,
    d.login as originLogin,
    d.name as originName,
    d.area as originArea,
    a.osrelOwnerId as ownerId,
    e.login as ownerLogin,
    e.name as ownerName,
    e.area as ownerArea,
    a.age,
    a.duplicate,
    a.notesDB,
    a.notesID
  FROM
    FHCDefect a
    INNER JOIN FHCComp b ON b.OID=a.osrelCompId
    INNER JOIN FHCUser d ON d.OID=a.osrelOriginId
    INNER JOIN FHCUser e ON e.OID=a.osrelOwnerId
    LEFT OUTER JOIN FHCRelease c ON c.OID=a.osrelReleaseId
  WHERE
    a.type='defect';

CREATE VIEW DefectView AS 
  SELECT
    a.*
  FROM
    DefectMiniView a;

CREATE VIEW FeatureMiniView AS 
  SELECT
    a.OVer,
    a.OID,
    a.oid as id,
    a.type as defectType,
    a.prefix,
    a.name,
    a.osrelCompId as compId,
    b.name as compName,
    a.osrelReleaseId as releaseId,
    c.name as releaseName,
    a.envName,
    a.state,
    a.severity,
    a.abstract,
    a.reference,
    a.answer,
    a.levelName as driverName,
    a.lastUpdate,
    a.addDate,
    a.assignDate,
    a.responseDate,
    a.endDate,
    a.osrelOriginId as originId,
    d.login as originLogin,
    d.name as originName,
    d.area as originArea,
    a.osrelOwnerId as ownerId,
    e.login as ownerLogin,
    e.name as ownerName,
    e.area as ownerArea,
    a.age,
    a.duplicate,
    a.notesDB,
    a.notesID
  FROM
    FHCDefect a
    INNER JOIN FHCComp b ON b.OID=a.osrelCompId
    INNER JOIN FHCUser d ON d.OID=a.osrelOriginId
    INNER JOIN FHCUser e ON e.OID=a.osrelOwnerId
    LEFT OUTER JOIN FHCRelease c ON c.OID=a.osrelReleaseId
  WHERE
    a.type='feature';

CREATE VIEW FeatureView AS 
  SELECT
    a.*
  FROM
    FeatureMiniView a;

CREATE VIEW DefectDownMiniView AS 
  SELECT
    a.OVer,
    a.OID,
    a.oid as id,
    a.type as defectType,
    a.prefix,
    a.name,
    a.envName,
    a.state,
    a.severity,
    a.abstract,
    a.reference,
    a.answer,
    a.levelName as driverName,
    a.lastUpdate,
    a.addDate,
    a.assignDate,
    a.responseDate,
    a.endDate,
    a.osrelReleaseId as releaseId,
    b.name as releaseName,
    a.osrelCompId as compId,
    c.oid as parentCompId,
    d.osrelParentId as parentId,
    e.name as compName,
    c.name as childCompName,
    a.osrelOriginId as originId,
    f.login as originLogin,
    f.name as originName,
    f.area as originArea,
    a.osrelOwnerId as ownerId,
    g.login as ownerLogin,
    g.name as ownerName,
    g.area as ownerArea,
    a.age,
    a.duplicate,
    a.notesDB,
    a.notesID
  FROM
    FHCDefect a
    INNER JOIN FHCComp c ON c.OID=a.osrelCompId
    INNER JOIN FHCCompMember d ON d.osrelChildId=c.oid
    INNER JOIN FHCComp e ON e.OID=d.osrelParentId
    INNER JOIN FHCUser f ON f.OID=a.osrelOriginId
    INNER JOIN FHCUser g ON g.OID=a.osrelOwnerId
    LEFT OUTER JOIN FHCRelease b ON b.OID=a.osrelReleaseId
  WHERE
    a.type='defect';

CREATE VIEW DefectDownView AS 
  SELECT
    a.*
  FROM
    DefectDownMiniView a;

CREATE VIEW FeatureDwnMiniView AS 
  SELECT
    a.OVer,
    a.OID,
    a.oid as id,
    a.type as defectType,
    a.prefix,
    a.name,
    a.osrelCompId as compId,
    b.oid as parentCompId,
    c.osrelParentId as parentId,
    d.name as compName,
    b.name as childCompName,
    a.osrelReleaseId as releaseId,
    e.name as releaseName,
    a.envName,
    a.state,
    a.severity,
    a.abstract,
    a.reference,
    a.answer,
    a.levelName as driverName,
    a.lastUpdate,
    a.addDate,
    a.assignDate,
    a.responseDate,
    a.endDate,
    a.osrelOriginId as originId,
    f.login as originLogin,
    f.name as originName,
    f.area as originArea,
    a.osrelOwnerId as ownerId,
    g.login as ownerLogin,
    g.name as ownerName,
    g.area as ownerArea,
    a.age,
    a.duplicate,
    a.notesDB,
    a.notesID
  FROM
    FHCDefect a
    INNER JOIN FHCComp b ON b.OID=a.osrelCompId
    INNER JOIN FHCCompMember c ON c.osrelChildId=b.oid
    INNER JOIN FHCComp d ON d.OID=c.osrelParentId
    INNER JOIN FHCUser f ON f.OID=a.osrelOriginId
    INNER JOIN FHCUser g ON g.OID=a.osrelOwnerId
    LEFT OUTER JOIN FHCRelease e ON e.OID=a.osrelReleaseId
  WHERE
    a.type='feature';

CREATE VIEW FeatureDownView AS 
  SELECT
    a.*
  FROM
    FeatureDwnMiniView a;

CREATE VIEW Environmments AS 
  SELECT
    a.OVer,
    a.OID,
    a.name,
    a.osrelReleaseId as releaseId,
    a.osrelUserId as userId
  FROM
    FHCEnvironment a;

CREATE VIEW EnvView AS 
  SELECT
    a.OVer,
    a.OID,
    a.name,
    a.osrelReleaseId as releaseId,
    b.name as releaseName,
    a.osrelUserId as userId,
    c.login as userLogin,
    c.name as userName,
    c.area as userArea
  FROM
    FHCEnvironment a
    INNER JOIN FHCRelease b ON b.OID=a.osrelReleaseId
    INNER JOIN FHCUser c ON c.OID=a.osrelUserId;

CREATE VIEW Files AS 
  SELECT
    a.OVer,
    a.OID,
    a.oid as id,
    a.osrelCollectorId as partId,
    b.typeName as partType,
    a.osrelCompId as compId,
    c.name as compName,
    a.osrelPathId as pathId,
    d.name as pathName,
    d.baseName,
    a.addDate,
    a.dropDate,
    a.lastUpdate,
    a.osrelTipVersionId as versionId,
    a.osrelReleaseId as releaseId,
    a.translation,
    a.restricted
  FROM
    FHCFile a
    INNER JOIN TCCollectorClass b ON b.OID=a.osrelCollectorId
    INNER JOIN FHCComp c ON c.OID=a.osrelCompId
    INNER JOIN FHCPath d ON d.OID=a.osrelPathId;

CREATE VIEW FixView AS 
  SELECT
    a.OVer,
    a.OID,
    a.osrelTrackId as trackId,
    b.osrelWorkAreaId as workAreaId,
    c.name as workAreaName,
    b.osrelReleaseId as releaseId,
    d.name as releaseName,
    b.osrelDefectId as defectId,
    e.prefix as defectPrefix,
    e.name as defectName,
    e.abstract as defectAbstract,
    e.reference as defectReference,
    e.type as defectType,
    a.osrelUserId as userId,
    f.login as userLogin,
    f.name as userName,
    f.area as userArea,
    a.osrelCompId as compId,
    g.name as compName,
    a.state,
    a.addDate,
    a.lastUpdate
  FROM
    FHCFix a
    INNER JOIN FHCTrack b ON b.OID=a.osrelTrackId
    INNER JOIN FHCWorkArea c ON c.OID=b.osrelWorkAreaId
    INNER JOIN FHCRelease d ON d.OID=b.osrelReleaseId
    INNER JOIN FHCUser f ON f.OID=a.osrelUserId
    INNER JOIN FHCComp g ON g.OID=a.osrelCompId
    LEFT OUTER JOIN FHCDefect e ON e.OID=b.osrelDefectId;

CREATE VIEW FixDownView AS 
  SELECT DISTINCT
    a.OVer,
    a.OID,
    a.osrelTrackId as trackId,
    b.osrelWorkAreaId as workAreaId,
    c.name as workAreaName,
    b.osrelReleaseId as releaseId,
    d.name as releaseName,
    b.osrelDefectId as defectId,
    e.prefix as defectPrefix,
    e.name as defectName,
    e.abstract as defectAbstract,
    e.reference as defectReference,
    e.type as defectType,
    a.osrelUserId as userId,
    f.login as userLogin,
    f.name as userName,
    f.area as userArea,
    a.osrelCompId as compId,
    g.oid as parentCompId,
    h.osrelParentId as parentId,
    i.name as compName,
    g.name as childCompName,
    a.state,
    a.addDate,
    a.lastUpdate
  FROM
    FHCFix a
    INNER JOIN FHCTrack b ON b.OID=a.osrelTrackId
    INNER JOIN FHCWorkArea c ON c.OID=b.osrelWorkAreaId
    INNER JOIN FHCRelease d ON d.OID=b.osrelReleaseId
    INNER JOIN FHCUser f ON f.OID=a.osrelUserId
    INNER JOIN FHCComp g ON g.OID=a.osrelCompId
    INNER JOIN FHCCompMember h ON h.osrelChildId=g.oid
    INNER JOIN FHCComp i ON i.OID=h.osrelParentId
    LEFT OUTER JOIN FHCDefect e ON e.OID=b.osrelDefectId;

CREATE VIEW PartsOutView AS 
  SELECT
    a.OVer,
    a.OID,
    a.osrelFileId as fileId,
    b.osrelCollectorId as partId,
    b.osrelReleaseId as releaseId,
    c.name as releaseName,
    b.osrelPathId as pathId,
    d.name as partNuPath,
    b.osrelCompId as compId,
    a.osrelSeqFileId as seqPartId,
    a.osrelSeqFileId as seqFileId,
    a.osrelUserId as userId,
    e.login as userLogin,
    e.name as userName,
    e.area as userArea,
    a.osrelOVersionId as oVersionId,
    f.SID as checkOutVersion,
    f.osrelWorkAreaId as workAreaId,
    g.name as workAreaName,
    a.checkOutDate
  FROM
    FHCFilesOut a
    INNER JOIN FHCFile b ON b.OID=a.osrelFileId
    INNER JOIN FHCRelease c ON c.OID=b.osrelReleaseId
    INNER JOIN FHCPath d ON d.OID=b.osrelPathId
    INNER JOIN FHCUser e ON e.OID=a.osrelUserId
    INNER JOIN FHCOVersion f ON f.OID=a.osrelOVersionId
    LEFT OUTER JOIN FHCWorkArea g ON g.OID=f.osrelWorkAreaId;

CREATE VIEW HistoryView AS 
  SELECT
    a.OVer,
    a.OID,
    a.osrelDefectId as defectId,
    b.prefix as defectPrefix,
    b.name as defectName,
    b.reference as defectReference,
    a.osrelUserId as userId,
    c.login as userLogin,
    c.name as userName,
    c.area as userArea,
    a.action,
    a.addDate
  FROM
    FHCHistory a
    INNER JOIN FHCDefect b ON b.OID=a.osrelDefectId
    INNER JOIN FHCUser c ON c.OID=a.osrelUserId;

CREATE VIEW Hosts AS 
  SELECT
    a.OVer,
    a.OID,
    a.osrelUserId as userId,
    a.name,
    a.login,
    a.loginType
  FROM
    FHCHost a;

CREATE VIEW HostView AS 
  SELECT
    a.OVer,
    a.OID,
    a.name,
    a.login,
    a.loginType,
    a.osrelUserId as userId,
    b.login as userLogin,
    b.name as userName,
    b.area as userArea
  FROM
    FHCHost a
    INNER JOIN FHCUser b ON b.OID=a.osrelUserId;

CREATE VIEW Interest AS 
  SELECT
    a.OVer,
    a.OID,
    a.name,
    a.action
  FROM
    FHCInterest a;

CREATE VIEW Drivers AS 
  SELECT
    a.OVer,
    a.OID,
    b.oid as id,
    a.name,
    a.osrelReleaseId as releaseId,
    a.osrelUserId as userId,
    a.addDate,
    a.commitDate,
    a.lastUpdate,
    a.state,
    a.type as driverType
  FROM
    FHCLevel a
    INNER JOIN ADViewRoot b ON b.OID=a.OID;

CREATE VIEW DriverView AS 
  SELECT
    a.OVer,
    a.OID,
    b.oid as id,
    a.name,
    a.osrelReleaseId as releaseId,
    c.name as releaseName,
    a.osrelUserId as userId,
    d.login as userLogin,
    d.name as userName,
    d.area as userArea,
    a.addDate,
    a.commitDate,
    a.lastUpdate,
    a.state,
    a.type as driverType
  FROM
    FHCLevel a
    INNER JOIN ADViewRoot b ON b.OID=a.OID
    INNER JOIN FHCRelease c ON c.OID=a.osrelReleaseId
    INNER JOIN FHCUser d ON d.OID=a.osrelUserId;

CREATE VIEW DriverMembers AS 
  SELECT
    a.OVer,
    a.OID,
    a.osrelLevelId as driverId,
    b.state as driverState,
    a.osrelTrackId as trackId,
    c.osrelWorkAreaId as workAreaId,
    a.osrelOVersionId as committedOVersinId,
    d.SID as committedVersion,
    a.workAreaOVersionId
  FROM
    FHCLevelMember a
    INNER JOIN FHCLevel b ON b.OID=a.osrelLevelId
    INNER JOIN FHCTrack c ON c.OID=a.osrelTrackId
    LEFT OUTER JOIN FHCOVersion d ON d.OID=a.osrelOVersionId;

CREATE VIEW DriverMemberView AS 
  SELECT
    a.OVer,
    a.OID,
    a.osrelLevelId as driverId,
    b.name as driverName,
    b.state as driverState,
    a.osrelTrackId as trackId,
    c.osrelWorkAreaId as workAreaId,
    d.name as workAreaName,
    c.osrelReleaseId as releaseId,
    e.name as releaseName,
    c.osrelUserId as userId,
    f.login as trackUserLogin,
    f.name as trackUserName,
    f.area as trackUserArea,
    c.osrelDefectId as defectId,
    g.prefix as defectPrefix,
    g.name as defectName,
    g.reference as defectReference,
    g.abstract as defectAbstract,
    g.type as defectType,
    a.osrelOVersionId as committedOVersinId,
    h.SID as committedVersion,
    a.workAreaOVersionId,
    i.SID as workAreaVersion
  FROM
    FHCLevelMember a
    INNER JOIN FHCLevel b ON b.OID=a.osrelLevelId
    INNER JOIN FHCTrack c ON c.OID=a.osrelTrackId
    INNER JOIN FHCWorkArea d ON d.OID=c.osrelWorkAreaId
    INNER JOIN FHCRelease e ON e.OID=c.osrelReleaseId
    INNER JOIN FHCUser f ON f.OID=c.osrelUserId
    LEFT OUTER JOIN FHCDefect g ON g.OID=c.osrelDefectId
    LEFT OUTER JOIN FHCOVersion h ON h.OID=a.osrelOVersionId
    LEFT OUTER JOIN FHCOVersion i ON i.OID=a.workAreaOVersionId;

CREATE VIEW Notes AS 
  SELECT
    a.OVer,
    a.OID,
    a.osrelDefectId as defectId,
    a.osrelUserId as userId,
    a.action,
    a.remarks,
    a.addDate
  FROM
    FHCNote a;

CREATE VIEW NoteView AS 
  SELECT
    a.OVer,
    a.OID,
    a.osrelDefectId as defectId,
    b.prefix as defectPrefix,
    b.name as defectName,
    b.reference as defectReference,
    a.osrelUserId as userId,
    c.login as userLogin,
    c.name as userName,
    c.area as userArea,
    a.action,
    a.remarks,
    a.addDate
  FROM
    FHCNote a
    INNER JOIN FHCDefect b ON b.OID=a.osrelDefectId
    INNER JOIN FHCUser c ON c.OID=a.osrelUserId;

CREATE VIEW Notification AS 
  SELECT
    a.OVer,
    a.OID,
    a.osrelCompId as compId,
    a.osrelUserId as userId,
    a.interestName
  FROM
    FHCNotify a;

CREATE VIEW NotifyView AS 
  SELECT
    a.OVer,
    a.OID,
    a.osrelCompId as compId,
    b.name as compName,
    a.osrelUserId as userId,
    c.address as userAddress,
    c.login as userLogin,
    c.name as userName,
    c.area as userArea,
    a.interestName
  FROM
    FHCNotify a
    INNER JOIN FHCComp b ON b.OID=a.osrelCompId
    INNER JOIN FHCUser c ON c.OID=a.osrelUserId;

CREATE VIEW NotifyDownView AS 
  SELECT DISTINCT
    a.OVer,
    a.OID,
    a.osrelCompId as compId,
    b.oid as parentCompId,
    c.osrelParentId as parentId,
    d.name as compName,
    b.name as childCompName,
    a.osrelUserId as userId,
    e.address as userAddress,
    e.login as userLogin,
    e.name as userName,
    e.area as userArea,
    a.interestName
  FROM
    FHCNotify a
    INNER JOIN FHCComp b ON b.OID=a.osrelCompId
    INNER JOIN FHCCompMember c ON c.osrelChildId=b.oid
    INNER JOIN FHCComp d ON d.OID=c.osrelParentId
    INNER JOIN FHCUser e ON e.OID=a.osrelUserId;

CREATE VIEW NotifyUpView AS 
  SELECT DISTINCT
    a.OVer,
    a.OID,
    a.osrelCompId as compId,
    b.oid as childCompId,
    c.osrelChildId as childId,
    d.name as compName,
    b.name as parentName,
    a.osrelUserId as userId,
    e.address as userAddress,
    e.login as userLogin,
    e.name as userName,
    e.area as userArea,
    a.interestName
  FROM
    FHCNotify a
    INNER JOIN FHCComp b ON b.OID=a.osrelCompId
    INNER JOIN FHCCompMember c ON c.osrelParentId=b.oid
    INNER JOIN FHCComp d ON d.OID=c.osrelChildId
    INNER JOIN FHCUser e ON e.OID=a.osrelUserId;

CREATE VIEW NotifyFastView AS 
  SELECT
    a.OVer,
    a.OID,
    a.osrelUserId as userId,
    b.address as userAddress,
    c.osrelChildId as compId,
    a.interestName,
    d.action
  FROM
    FHCNotify a
    INNER JOIN FHCUser b ON b.OID=a.osrelUserId
    INNER JOIN FHCCompMember c ON c.osrelParentId=a.osrelCompId
    INNER JOIN FHCInterest d ON d.name=a.interestName;

CREATE VIEW Parsers AS 
  SELECT
    a.OVer,
    a.OID,
    a.oid as id,
    a.sequenceId,
    a.addDate,
    a.dropDate,
    a.lastUpdate,
    a.osrelReleaseId as releaseId,
    a.description as name,
    a.parserCommand as commandName,
    a.parserIncludes as includePaths
  FROM
    FHCParser a;

CREATE VIEW ParserView AS 
  SELECT
    a.OVer,
    a.OID,
    a.oid as id,
    a.sequenceId,
    a.addDate,
    a.dropDate,
    a.lastUpdate,
    a.osrelReleaseId as releaseId,
    b.name as releaseName,
    a.description as name,
    a.parserCommand as commandName,
    a.parserIncludes as includePaths
  FROM
    FHCParser a
    INNER JOIN FHCRelease b ON b.OID=a.osrelReleaseId;

CREATE VIEW Path AS 
  SELECT
    a.OVer,
    a.OID,
    a.oid as id,
    a.name,
    a.baseName
  FROM
    FHCPath a;

CREATE VIEW Prereqs AS 
  SELECT
    a.OVer,
    a.OID,
    a.osrelTrackId as trackId,
    b.osrelWorkAreaId as workAreaId,
    a.osrelPrereqId as prereqId,
    c.osrelWorkAreaId as prereqWorkAreaId
  FROM
    FHCPrereq a
    INNER JOIN FHCTrack b ON b.OID=a.osrelTrackId
    INNER JOIN FHCTrack c ON c.OID=a.osrelPrereqId;

CREATE VIEW PrereqView AS 
  SELECT
    a.OVer,
    a.OID,
    a.osrelTrackId as trackId,
    b.osrelWorkAreaId as workAreaId,
    c.name,
    b.osrelReleaseId as releaseId,
    d.name as releaseName,
    b.osrelDefectId as trackDefectId,
    e.prefix as defectPrefix,
    e.name as defectName,
    e.type as defectType,
    a.osrelPrereqId as prereqId,
    f.osrelWorkAreaId as prereqWorkAreaId,
    g.name as prereqName,
    f.osrelDefectId as prereqDefectId,
    h.prefix as prereqPrefix,
    h.name as prereqDefect,
    h.type as prereqType,
    f.state
  FROM
    FHCPrereq a
    INNER JOIN FHCTrack b ON b.OID=a.osrelTrackId
    INNER JOIN FHCWorkArea c ON c.OID=b.osrelWorkAreaId
    INNER JOIN FHCRelease d ON d.OID=b.osrelReleaseId
    INNER JOIN FHCTrack f ON f.OID=a.osrelPrereqId
    INNER JOIN FHCWorkArea g ON g.OID=f.osrelWorkAreaId
    LEFT OUTER JOIN FHCDefect e ON e.OID=b.osrelDefectId
    LEFT OUTER JOIN FHCDefect h ON h.OID=f.osrelDefectId;

CREATE VIEW Releases AS 
  SELECT
    a.OVer,
    a.OID,
    a.oid as id,
    a.name,
    a.osrelCompId as compId,
    a.binding,
    a.approve,
    a.fix,
    a.lvl,
    a.test,
    a.description,
    a.osrelUserId as userId,
    a.addDate,
    a.dropDate,
    a.lastUpdate,
    a.track,
    a.process as relProcess,
    a.developmentMode,
    a.autoPrune,
    a.coupling,
    a.outputVersions
  FROM
    FHCRelease a;

CREATE VIEW ReleaseMiniView AS 
  SELECT
    a.OVer,
    a.OID,
    a.oid as id,
    a.name,
    a.osrelCompId as compId,
    b.name as compName,
    a.binding,
    a.approve,
    a.fix,
    a.lvl,
    a.test,
    a.description,
    a.osrelUserId as userId,
    c.login as userLogin,
    c.name as userName,
    c.area as userArea,
    a.addDate,
    a.dropDate,
    a.lastUpdate,
    a.track,
    a.process as relProcess,
    a.developmentMode,
    a.autoPrune,
    a.coupling,
    a.outputVersions,
    a.pTipOVer as tipVersionId,
    d.SID as tipVersion
  FROM
    FHCRelease a
    INNER JOIN FHCComp b ON b.OID=a.osrelCompId
    INNER JOIN FHCUser c ON c.OID=a.osrelUserId
    LEFT OUTER JOIN FHCOVersion d ON d.OID=a.pTipOVer;

CREATE VIEW ReleaseView AS 
  SELECT
    a.*
  FROM
    ReleaseMiniView a;

CREATE VIEW CfgRelProc AS 
  SELECT
    a.OVer,
    a.OID,
    a.name,
    a.config
  FROM
    FHCCfgRelProc a;

CREATE VIEW Sequence AS 
  SELECT
    a.OVer,
    a.OID,
    a.name,
    a.lastSerial
  FROM
    FHCSequence a;

CREATE VIEW Shadows AS 
  SELECT
    a.OVer,
    a.OID,
    a.oid as id,
    a.name,
    a.osrelReleaseId as releaseId,
    a.osrelShadowTypeId as shadowTypeId,
    a.mode,
    a.priority,
    a.state,
    a.location,
    a.drivers,
    a.workareas,
    a.release,
    a.crlf,
    a.keys,
    a.timestamp,
    a.parameters
  FROM
    FHCShadow a;

CREATE VIEW ShadowView AS 
  SELECT
    a.OVer,
    a.OID,
    a.oid as id,
    a.name,
    a.osrelReleaseId as releaseId,
    b.name as releaseName,
    a.osrelShadowTypeId as typeId,
    c.name as shadowType,
    a.mode,
    a.priority,
    a.state,
    a.location,
    a.drivers,
    a.workareas,
    a.release,
    a.crlf,
    a.keys,
    a.timestamp,
    a.parameters
  FROM
    FHCShadow a
    INNER JOIN FHCRelease b ON b.OID=a.osrelReleaseId
    INNER JOIN FHCShadowType c ON c.OID=a.osrelShadowTypeId;

CREATE VIEW ShadowParts AS 
  SELECT
    a.OVer,
    a.OID,
    a.oid as id,
    a.osrelShadowId as shadowId,
    a.osrelCollectorId as partId,
    a.osrelWorkAreaId as workAreaId,
    a.osrelPathId as pathId,
    a.pBulk,
    a.SID,
    a.shadowTimeStamp,
    a.fmode,
    a.lastUpdate
  FROM
    FHCShadowPart a;

CREATE VIEW ShadowPartView AS 
  SELECT
    a.OVer,
    a.OID,
    a.oid as id,
    a.osrelShadowId as shadowId,
    b.name as shadowName,
    b.osrelReleaseId as releaseId,
    c.name as releaseName,
    a.osrelCollectorId as partId,
    a.osrelWorkAreaId as workAreaId,
    d.name as workAreaName,
    a.osrelPathId as pathId,
    e.name as pathName,
    a.SID,
    a.shadowTimeStamp,
    a.fmode,
    a.lastUpdate
  FROM
    FHCShadowPart a
    INNER JOIN FHCShadow b ON b.OID=a.osrelShadowId
    INNER JOIN FHCRelease c ON c.OID=b.osrelReleaseId
    INNER JOIN FHCPath e ON e.OID=a.osrelPathId
    LEFT OUTER JOIN FHCWorkArea d ON d.OID=a.osrelWorkAreaId;

CREATE VIEW ShadowTypes AS 
  SELECT
    a.OVer,
    a.OID,
    a.oid as id,
    a.name,
    a.description,
    a.program
  FROM
    FHCShadowType a;

CREATE VIEW Sizes AS 
  SELECT
    a.OVer,
    a.OID,
    a.osrelDefectId as defectId,
    a.osrelCompId as compId,
    a.osrelUserId as userId,
    a.addDate,
    a.lastUpdate,
    a.state,
    a.sizing,
    a.osrelReleaseId as releaseId
  FROM
    FHCSize a;

CREATE VIEW SizeView AS 
  SELECT
    a.OVer,
    a.OID,
    a.osrelDefectId as defectId,
    b.prefix as featurePrefix,
    b.name as featureName,
    b.abstract as featureAbstract,
    b.reference as featureReference,
    a.osrelCompId as compId,
    c.name as compName,
    a.osrelUserId as userId,
    d.login as userLogin,
    d.name as userName,
    d.area as userArea,
    a.addDate,
    a.lastUpdate,
    a.state,
    a.sizing,
    a.osrelReleaseId as releaseId,
    e.name as releaseName
  FROM
    FHCSize a
    INNER JOIN FHCDefect b ON b.OID=a.osrelDefectId
    INNER JOIN FHCComp c ON c.OID=a.osrelCompId
    INNER JOIN FHCUser d ON d.OID=a.osrelUserId
    INNER JOIN FHCRelease e ON e.OID=a.osrelReleaseId;

CREATE VIEW Tests AS 
  SELECT
    a.OVer,
    a.OID,
    a.osrelTrackId as trackId,
    b.osrelWorkAreaId as workAreaId,
    a.envName,
    a.osrelUserId as userId,
    a.state,
    a.addDate,
    a.lastUpdate
  FROM
    FHCTest a
    INNER JOIN FHCTrack b ON b.OID=a.osrelTrackId;

CREATE VIEW TestView AS 
  SELECT
    a.OVer,
    a.OID,
    a.osrelTrackId as trackId,
    b.osrelWorkAreaId as workAreaId,
    c.name as workAreaName,
    b.osrelDefectId as defectId,
    d.prefix as defectPrefix,
    d.name as defectName,
    d.reference as defectReference,
    d.abstract as defectAbstract,
    d.type as defectType,
    b.osrelReleaseId as releaseId,
    e.name as releaseName,
    a.envName,
    a.state,
    a.addDate,
    a.lastUpdate,
    a.osrelUserId as userId,
    f.login as userLogin,
    f.name as userName,
    f.area as userArea
  FROM
    FHCTest a
    INNER JOIN FHCTrack b ON b.OID=a.osrelTrackId
    INNER JOIN FHCWorkArea c ON c.OID=b.osrelWorkAreaId
    INNER JOIN FHCRelease e ON e.OID=b.osrelReleaseId
    INNER JOIN FHCUser f ON f.OID=a.osrelUserId
    LEFT OUTER JOIN FHCDefect d ON d.OID=b.osrelDefectId;

CREATE VIEW Tracks AS 
  SELECT
    a.OVer,
    a.OID,
    a.oid as id,
    a.osrelReleaseId as releaseId,
    a.osrelDefectId as defectId,
    a.osrelUserId as userId,
    a.osrelWorkAreaId as workAreaId,
    b.name,
    a.state,
    a.target,
    a.actual,
    a.addDate,
    a.lastUpdate
  FROM
    FHCTrack a
    INNER JOIN FHCWorkArea b ON b.OID=a.osrelWorkAreaId;

CREATE VIEW WorkAreaMiniView AS 
  SELECT
    a.OVer,
    a.OID,
    a.osrelWorkAreaId as id,
    a.osrelWorkAreaId as workAreaId,
    b.name,
    b.osrelBranchPointId as branchPointId,
    c.SID as branchPoint,
    b.osrelLevelId as driverId,
    d.name as driverName,
    b.pTipOVer as tipVersionId,
    e.SID as tipVersion,
    a.oid as trackId,
    a.osrelReleaseId as releaseId,
    f.name as releaseName,
    f.developmentMode,
    f.process as relProcess,
    a.osrelDefectId as defectId,
    g.prefix as defectPrefix,
    g.name as defectName,
    g.reference as defectReference,
    g.abstract as defectAbstract,
    g.type as defectType,
    a.osrelUserId as userId,
    h.login as userLogin,
    h.name as userName,
    h.area as userArea,
    a.state,
    a.target,
    a.actual,
    a.addDate,
    a.lastUpdate
  FROM
    FHCTrack a
    INNER JOIN FHCWorkArea b ON b.OID=a.osrelWorkAreaId
    INNER JOIN FHCOVersion c ON c.OID=b.osrelBranchPointId
    INNER JOIN FHCRelease f ON f.OID=a.osrelReleaseId
    INNER JOIN FHCUser h ON h.OID=a.osrelUserId
    LEFT OUTER JOIN FHCLevel d ON d.OID=b.osrelLevelId
    LEFT OUTER JOIN FHCOVersion e ON e.OID=b.pTipOVer
    LEFT OUTER JOIN FHCDefect g ON g.OID=a.osrelDefectId;

CREATE VIEW WorkAreaView AS 
  SELECT
    a.*
  FROM
    WorkAreaMiniView a;

CREATE VIEW UsersMini AS 
  SELECT
    a.OVer,
    a.OID,
    a.oid as id,
    a.login,
    a.name,
    a.superUser,
    a.area,
    a.address,
    a.addressType,
    a.addDate,
    a.dropDate,
    a.lastUpdate,
    a.AuthType,
    a.pswStatus,
    a.pswModifyTime,
    a.pswCreateTime,
    a.pswFailCount,
    a.pswBlock
  FROM
    FHCUser a;

CREATE VIEW Users AS 
  SELECT
    a.*
  FROM
    UsersMini a;

CREATE VIEW UserData AS 
  SELECT
    a.OVer,
    a.OID,
    b.guid,
    a.login,
    e.label,
    e.contents
  FROM
    FHCUser a
    INNER JOIN ADObject b ON b.OID=a.OID AND b.OVer=a.OVer
    LEFT OUTER JOIN ADLink_source c ON c.classAttr='ADAnnotatedObject.pAnnotationText' AND
      c.sourceOID=a.OID AND c.sourceOVer=a.OVer
    LEFT OUTER JOIN ADLink d ON d.OID=c.relOID
    LEFT OUTER JOIN ADAnnotationText e ON e.OID=d.adTarget;

CREATE VIEW VerifyView AS 
  SELECT
    a.OVer,
    a.OID,
    a.osrelDefectId as defectId,
    b.prefix as defectPrefix,
    b.name as defectName,
    b.reference as defectReference,
    b.abstract as defectAbstract,
    b.osrelCompId as compId,
    c.name as compName,
    b.type as defectType,
    a.osrelUserId as userId,
    d.login as userLogin,
    d.name as userName,
    d.area as userArea,
    a.type as verifyType,
    a.state,
    a.addDate,
    a.lastUpdate
  FROM
    FHCVerify a
    INNER JOIN FHCDefect b ON b.OID=a.osrelDefectId
    INNER JOIN FHCComp c ON c.OID=b.osrelCompId
    INNER JOIN FHCUser d ON d.OID=a.osrelUserId;

CREATE VIEW WorkAreas AS 
  SELECT
    a.OVer,
    a.OID,
    a.oid as id,
    a.osrelReleaseId as releaseId,
    b.name as releaseName,
    a.osrelTrackId as trackId,
    a.name,
    a.pTipOVer as tipOVerId,
    a.osrelBranchPointId as branchPointId,
    c.SID as branchPoint
  FROM
    FHCWorkArea a
    INNER JOIN FHCRelease b ON b.OID=a.osrelReleaseId
    INNER JOIN FHCOVersion c ON c.OID=a.osrelBranchPointId;

CREATE VIEW FileOverrideR AS 
  SELECT
    a.OVer,
    a.OID,
    a.oid as id,
    a.osrelFileId as fileId,
    a.osrelReleaseId as releaseId,
    a.osrelWorkAreaId as workareaId,
    a.osrelUserId as userId
  FROM
    FHCFileOverrideR a;

CREATE VIEW PartOverrideRView AS 
  SELECT
    a.OVer,
    a.OID,
    a.osrelFileId as fileId,
    b.osrelPathId as pathId,
    c.name as pathName,
    c.baseName,
    a.osrelWorkAreaId as workAreaId,
    d.name as workAreaName,
    a.osrelUserId as userId,
    e.login as userLogin,
    a.osrelReleaseId as releaseId,
    f.name as releaseName
  FROM
    FHCFileOverrideR a
    INNER JOIN FHCFile b ON b.OID=a.osrelFileId
    INNER JOIN FHCPath c ON c.OID=b.osrelPathId
    INNER JOIN FHCWorkArea d ON d.OID=a.osrelWorkAreaId
    INNER JOIN FHCRelease f ON f.OID=a.osrelReleaseId
    LEFT OUTER JOIN FHCUser e ON e.OID=a.osrelUserId;

CREATE VIEW TEACNETOMPNR AS   -- TEAMCONNECTIONMAPENTRY
  SELECT
    a.OVer,
    a.OID,
    a.aName,
    a.aOIDPattern
  FROM
    fdcOIDMapEntry a;

CREATE VIEW Security AS 
  SELECT
    a.OVer,
    a.OID,
    a.osrelUserId
  FROM
    FHCSecurity a;

CREATE VIEW TargetMiniView AS 
  SELECT
    a.OVer,
    a.OID,
    a.oid as id,
    a.targetName,
    a.status,
    a.active,
    a.targetDate,
    a.osrelSourceObjctId as sourceId,
    b.osrelNuPathId as nuPathId,
    c.name as partName
  FROM
    TCTarget a
    INNER JOIN TCSourceObject b ON b.OID=a.osrelSourceObjctId
    INNER JOIN FHCPath c ON c.OID=b.osrelNuPathId;

CREATE VIEW TargetView AS 
  SELECT
    a.*
  FROM
    TargetMiniView a;

