Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
Checking mergeability… Don't worry, you can still create the pull request.
  • 12 commits
  • 18 files changed
  • 0 commit comments
  • 1 contributor
View
10 bin/afgen
@@ -8,16 +8,6 @@ $:.unshift File.dirname(File.expand_path(__FILE__))+"/../lib"
require 'rubygems'
-# Load the ruby debugger before everything else, if requested
-if d = ENV['DEBUG'] and d.split(/,/).include?('debug')
- begin
- require 'ruby-debug'
- Debugger.start # (:post_mortem => true) # Some Ruby versions crash on post-mortem debugging
- rescue LoadError
- # Ok, no debugger, tough luck.
- end
-end
-
require 'activefacts'
require 'activefacts/vocabulary'
View
1  bin/cql
@@ -1,4 +1,5 @@
#! /usr/bin/env ruby
+# encoding: UTF-8
#
# ActiveFacts: Interactive CQL command-line. Incomplete; only parses CQL and shows the parse trees
#
View
26 css/orm2.css
@@ -1,3 +1,11 @@
+ul {
+ margin: 0px 0px 0px 2em;
+ -webkit-margin-before: 0px;
+ -webkit-margin-after: 0px;
+ -webkit-padding-start: 0px;
+ padding: 0px;
+}
+
pre {
background-color: #000;
padding: 5px;
@@ -7,18 +15,30 @@ pre {
border-color: #BBB;
}
+span {
+ font-family: "Frutiger", sans-serif;
+}
+
.keyword {
Xcolor: #00F;
color: #66F;
}
-.concept {
+.term, .concept {
Xcolor: #808;
color: #E0E;
}
-.copula {
+.vocabulary, .object_type {
+ Xcolor: #808;
+ color: #E0E;
+}
+.linking, .copula {
Xcolor: #060;
color: #0C0;
}
-.value {
+.literal, .value {
color: #FF990E;
}
+
+dd {
+ margin-bottom: 0.5em;
+}
View
9 examples/CQL/MetamodelNext.cql
@@ -48,7 +48,7 @@ Concept is identified by GUID where
Concept has one GUID,
GUID is of at most one Concept;
-Constraint is a kind of Concept;
+Constraint is a kind of Concept [partitioned];
Name is of Constraint,
Constraint is called at most one Name;
@@ -73,7 +73,7 @@ Fact is identified by GUID where
Fact has one GUID,
GUID is of at most one Fact;
-Fact Type is a kind of Concept;
+Fact Type is a kind of Concept [partitioned];
Fact is of one Fact Type;
Implicit Fact Type is a kind of Fact Type;
@@ -99,7 +99,7 @@ Join Node has at most one role-Name,
Language is identified by its Code;
-Object Type is a kind of Concept;
+Object Type is a kind of Concept [partitioned];
Instance is of one Object Type;
Join Node is for one Object Type,
Object Type is referenced in Join Node;
@@ -126,7 +126,7 @@ Reading has one Text;
Ring Constraint is a kind of Constraint;
Ring Constraint is of one Ring Type;
-Role is a kind of Concept where
+Role is a kind of Concept [partitioned] where
Fact Type has at least one Ordinal role;
Implicit Fact Type is implied by one Role (as Implying Role),
Implying Role implies at most one Implicit Fact Type;
@@ -144,7 +144,6 @@ Role Sequence is identified by GUID where
Presence Constraint covers one Role Sequence;
Reading is in one Role Sequence,
Role Sequence is for Reading;
-Role Sequence has unused dependency to force table in norma;
Role Value is identified by Instance and Fact where
Instance plays Role Value,
View
440 examples/SQL/MetamodelNext.sql
@@ -1,5 +1,5 @@
CREATE TABLE AllowedRange (
- -- Allowed Range is where Value Constraint allows Value Range and Concept has GUID,
+ -- Allowed Range is where Value Constraint allows Value Range and Constraint is a kind of Concept and Concept has GUID,
ValueConstraintGUID varchar NOT NULL,
-- Allowed Range is where Value Constraint allows Value Range and maybe Value Range has maximum-Bound and Bound is inclusive,
ValueRangeMaximumBoundIsInclusive bit NULL,
@@ -21,148 +21,72 @@ CREATE TABLE AllowedRange (
)
GO
-CREATE TABLE Concept (
- -- maybe Constraint is a kind of Concept and maybe Constraint requires Enforcement and maybe Enforcement notifies Agent and Agent has Agent Name,
- ConstraintAgentName varchar NULL,
- -- maybe Constraint is a kind of Concept and maybe Constraint requires Enforcement and Enforcement has Enforcement Code,
- ConstraintEnforcementCode varchar(16) NULL,
- -- maybe Constraint is a kind of Concept and maybe Name is of Constraint,
- ConstraintName varchar(64) NULL,
- -- maybe Constraint is a kind of Concept and maybe Vocabulary contains Constraint and Vocabulary is where Topic is described in Language and Language has Language Code,
- ConstraintVocabularyLanguageCode char(3) NULL,
- -- maybe Constraint is a kind of Concept and maybe Vocabulary contains Constraint and Vocabulary is where Topic is described in Language and Topic has Name,
- ConstraintVocabularyTopicName varchar(64) NULL,
- -- maybe Object Type is a kind of Concept and maybe Entity Type is a kind of Object Type and Entity Type is implied by objectification,
- EntityTypeIsImpliedByObjectification bit NULL,
- -- maybe Fact Type is a kind of Concept and maybe Entity Type objectifies Fact Type and Concept has GUID,
- FactTypeEntityTypeGUID varchar NULL,
- -- Concept has GUID,
- GUID varchar NOT NULL,
- -- maybe Object Type is a kind of Concept and Object Type is independent,
- ObjectTypeIsIndependent bit NULL,
- -- maybe Object Type is a kind of Concept and maybe Object Type uses Pronoun,
- ObjectTypePronoun varchar(20) NULL CHECK(ObjectTypePronoun = 'feminine' OR ObjectTypePronoun = 'masculine' OR ObjectTypePronoun = 'neuter' OR ObjectTypePronoun = 'personal'),
- -- maybe Constraint is a kind of Concept and maybe Presence Constraint is a kind of Constraint and Presence Constraint is mandatory,
+CREATE TABLE [Constraint] (
+ -- Constraint is a kind of Concept and Concept has GUID,
+ ConceptGUID varchar NOT NULL,
+ -- maybe Constraint requires Enforcement and maybe Enforcement notifies Agent and Agent has Agent Name,
+ EnforcementAgentName varchar NULL,
+ -- maybe Constraint requires Enforcement and Enforcement has Enforcement Code,
+ EnforcementCode varchar(16) NULL,
+ -- maybe Name is of Constraint,
+ Name varchar(64) NULL,
+ -- maybe Presence Constraint is a kind of Constraint and Presence Constraint is mandatory,
PresenceConstraintIsMandatory bit NULL,
- -- maybe Constraint is a kind of Concept and maybe Presence Constraint is a kind of Constraint and Presence Constraint is preferred identifier,
+ -- maybe Presence Constraint is a kind of Constraint and Presence Constraint is preferred identifier,
PresenceConstraintIsPreferredIdentifier bit NULL,
- -- maybe Constraint is a kind of Concept and maybe Presence Constraint is a kind of Constraint and maybe Presence Constraint has max-Frequency,
+ -- maybe Presence Constraint is a kind of Constraint and maybe Presence Constraint has max-Frequency,
PresenceConstraintMaxFrequency int NULL CHECK(PresenceConstraintMaxFrequency >= 1),
- -- maybe Constraint is a kind of Concept and maybe Presence Constraint is a kind of Constraint and maybe Presence Constraint has min-Frequency,
+ -- maybe Presence Constraint is a kind of Constraint and maybe Presence Constraint has min-Frequency,
PresenceConstraintMinFrequency int NULL CHECK(PresenceConstraintMinFrequency >= 2),
- -- maybe Constraint is a kind of Concept and maybe Presence Constraint is a kind of Constraint and Presence Constraint covers Role Sequence and Role Sequence has GUID,
+ -- maybe Presence Constraint is a kind of Constraint and Presence Constraint covers Role Sequence and Role Sequence has GUID,
PresenceConstraintRoleSequenceGUID varchar NULL,
- -- maybe Constraint is a kind of Concept and maybe Ring Constraint is a kind of Constraint and maybe Ring Constraint has other-Role and Concept has GUID,
+ -- maybe Ring Constraint is a kind of Constraint and maybe Ring Constraint has other-Role and Role is a kind of Concept and Concept has GUID,
RingConstraintOtherRoleGUID varchar NULL,
- -- maybe Constraint is a kind of Concept and maybe Ring Constraint is a kind of Constraint and Ring Constraint is of Ring Type,
+ -- maybe Ring Constraint is a kind of Constraint and Ring Constraint is of Ring Type,
RingConstraintRingType varchar NULL,
- -- maybe Constraint is a kind of Concept and maybe Ring Constraint is a kind of Constraint and maybe Role is of Ring Constraint and Concept has GUID,
+ -- maybe Ring Constraint is a kind of Constraint and maybe Role is of Ring Constraint and Role is a kind of Concept and Concept has GUID,
RingConstraintRoleGUID varchar NULL,
- -- maybe Role is a kind of Concept and Role is where Fact Type has Ordinal role and Concept has GUID,
- RoleFactTypeGUID varchar NULL,
- -- maybe Role is a kind of Concept and maybe Implicit Fact Type is implied by Role and Concept has GUID,
- RoleImplicitFactTypeGUID varchar NULL,
- -- maybe Role is a kind of Concept and maybe Term is name of Role and Term is where Vocabulary uses Name for Object Type,
- RoleName varchar(64) NULL,
- -- maybe Role is a kind of Concept and maybe Term is name of Role and Term is where Vocabulary uses Name for Object Type and Vocabulary is where Topic is described in Language and Language has Language Code,
- RoleNameVocabularyLanguageCode char(3) NULL,
- -- maybe Role is a kind of Concept and maybe Term is name of Role and Term is where Vocabulary uses Name for Object Type and Vocabulary is where Topic is described in Language and Topic has Name,
- RoleNameVocabularyTopicName varchar(64) NULL,
- -- maybe Role is a kind of Concept and Object Type plays Role and Concept has GUID,
- RoleObjectTypeGUID varchar NULL,
- -- maybe Role is a kind of Concept and Role is where Fact Type has Ordinal role,
- RoleOrdinal shortint NULL,
- -- maybe Constraint is a kind of Concept and maybe Set Constraint is a kind of Constraint and maybe Set Comparison Constraint is a kind of Set Constraint and maybe Set Exclusion Constraint is a kind of Set Comparison Constraint and Set Exclusion Constraint is mandatory,
+ -- maybe Set Constraint is a kind of Constraint and maybe Set Comparison Constraint is a kind of Set Constraint and maybe Set Exclusion Constraint is a kind of Set Comparison Constraint and Set Exclusion Constraint is mandatory,
SetExclusionConstraintIsMandatory bit NULL,
- -- maybe Constraint is a kind of Concept and maybe Set Constraint is a kind of Constraint and maybe Subset Constraint is a kind of Set Constraint and Subset Constraint covers subset-Role Sequence and Role Sequence has GUID,
+ -- maybe Set Constraint is a kind of Constraint and maybe Subset Constraint is a kind of Set Constraint and Subset Constraint covers subset-Role Sequence and Role Sequence has GUID,
SubsetConstraintSubsetRoleSequenceGUID varchar NULL,
- -- maybe Constraint is a kind of Concept and maybe Set Constraint is a kind of Constraint and maybe Subset Constraint is a kind of Set Constraint and Subset Constraint covers superset-Role Sequence and Role Sequence has GUID,
+ -- maybe Set Constraint is a kind of Constraint and maybe Subset Constraint is a kind of Set Constraint and Subset Constraint covers superset-Role Sequence and Role Sequence has GUID,
SubsetConstraintSupersetRoleSequenceGUID varchar NULL,
- -- maybe Constraint is a kind of Concept and maybe Value Constraint is a kind of Constraint and maybe Role has role-Value Constraint and Concept has GUID,
+ -- maybe Value Constraint is a kind of Constraint and maybe Role has role-Value Constraint and Role is a kind of Concept and Concept has GUID,
ValueConstraintRoleGUID varchar NULL,
- -- maybe Object Type is a kind of Concept and maybe Value Type is a kind of Object Type and maybe Value Type has auto- assigned Transaction Timing,
- ValueTypeAutoAssignedTransactionTiming varchar NULL CHECK(ValueTypeAutoAssignedTransactionTiming = 'assert' OR ValueTypeAutoAssignedTransactionTiming = 'commit'),
- -- maybe Object Type is a kind of Concept and maybe Value Type is a kind of Object Type and maybe Value Type has Length,
- ValueTypeLength int NULL,
- -- maybe Object Type is a kind of Concept and maybe Value Type is a kind of Object Type and maybe Value Type has Scale,
- ValueTypeScale int NULL,
- -- maybe Object Type is a kind of Concept and maybe Value Type is a kind of Object Type and maybe Value Type is subtype of super-Value Type and Concept has GUID,
- ValueTypeSupertypeGUID varchar NULL,
- -- maybe Object Type is a kind of Concept and maybe Value Type is a kind of Object Type and maybe Value Type is of Unit and Unit has Unit Code,
- ValueTypeUnitCode char NULL,
- -- maybe Object Type is a kind of Concept and maybe Value Type is a kind of Object Type and maybe Value Type has Value Constraint and Concept has GUID,
- ValueTypeValueConstraintGUID varchar NULL,
- PRIMARY KEY(GUID),
- FOREIGN KEY (RingConstraintOtherRoleGUID) REFERENCES Concept (GUID),
- FOREIGN KEY (RingConstraintRoleGUID) REFERENCES Concept (GUID),
- FOREIGN KEY (ValueConstraintRoleGUID) REFERENCES Concept (GUID),
- FOREIGN KEY (ValueTypeValueConstraintGUID) REFERENCES Concept (GUID),
- FOREIGN KEY (FactTypeEntityTypeGUID) REFERENCES Concept (GUID),
- FOREIGN KEY (RoleImplicitFactTypeGUID) REFERENCES Concept (GUID),
- FOREIGN KEY (RoleFactTypeGUID) REFERENCES Concept (GUID),
- FOREIGN KEY (RoleObjectTypeGUID) REFERENCES Concept (GUID),
- FOREIGN KEY (ValueTypeSupertypeGUID) REFERENCES Concept (GUID)
+ -- maybe Vocabulary contains Constraint and Vocabulary is where Topic is described in Language and Language has Language Code,
+ VocabularyLanguageCode char(3) NULL,
+ -- maybe Vocabulary contains Constraint and Vocabulary is where Topic is described in Language and Topic has Name,
+ VocabularyTopicName varchar(64) NULL,
+ PRIMARY KEY(ConceptGUID)
)
GO
-CREATE VIEW dbo.ConstraintInConcept_VocabularyTopicNameVocabularyLanguageCodeName (ConstraintVocabularyTopicName, ConstraintVocabularyLanguageCode, ConstraintName) WITH SCHEMABINDING AS
- SELECT ConstraintVocabularyTopicName, ConstraintVocabularyLanguageCode, ConstraintName FROM dbo.Concept
- WHERE ConstraintVocabularyTopicName IS NOT NULL
- AND ConstraintVocabularyLanguageCode IS NOT NULL
- AND ConstraintName IS NOT NULL
-GO
-
-CREATE UNIQUE CLUSTERED INDEX IX_ConstraintInConceptByConstraintVocabularyTopicNameConstraintVocabularyLanguageCodeConstraintName ON dbo.ConstraintInConcept_VocabularyTopicNameVocabularyLanguageCodeName(ConstraintVocabularyTopicName, ConstraintVocabularyLanguageCode, ConstraintName)
-GO
-
-CREATE VIEW dbo.FactTypeInConcept_FactTypeEntityTypeGUID (FactTypeEntityTypeGUID) WITH SCHEMABINDING AS
- SELECT FactTypeEntityTypeGUID FROM dbo.Concept
- WHERE FactTypeEntityTypeGUID IS NOT NULL
-GO
-
-CREATE UNIQUE CLUSTERED INDEX EntityTypeNestsOneFactType ON dbo.FactTypeInConcept_FactTypeEntityTypeGUID(FactTypeEntityTypeGUID)
-GO
-
-CREATE VIEW dbo.RoleInConcept_FactTypeGUIDOrdinal (RoleFactTypeGUID, RoleOrdinal) WITH SCHEMABINDING AS
- SELECT RoleFactTypeGUID, RoleOrdinal FROM dbo.Concept
- WHERE RoleFactTypeGUID IS NOT NULL
- AND RoleOrdinal IS NOT NULL
-GO
-
-CREATE UNIQUE CLUSTERED INDEX IX_RoleInConceptByRoleFactTypeGUIDRoleOrdinal ON dbo.RoleInConcept_FactTypeGUIDOrdinal(RoleFactTypeGUID, RoleOrdinal)
-GO
-
-CREATE VIEW dbo.RoleInConcept_ImplicitFactTypeGUID (RoleImplicitFactTypeGUID) WITH SCHEMABINDING AS
- SELECT RoleImplicitFactTypeGUID FROM dbo.Concept
- WHERE RoleImplicitFactTypeGUID IS NOT NULL
-GO
-
-CREATE UNIQUE CLUSTERED INDEX IX_RoleInConceptByRoleImplicitFactTypeGUID ON dbo.RoleInConcept_ImplicitFactTypeGUID(RoleImplicitFactTypeGUID)
-GO
-
-CREATE VIEW dbo.SubsetConstraintInConcept_SubsetConstraintSubsetRoleSequenceGUIDSubsetConstraintSupersetRoleSequenceGUID (SubsetConstraintSubsetRoleSequenceGUID, SubsetConstraintSupersetRoleSequenceGUID) WITH SCHEMABINDING AS
- SELECT SubsetConstraintSubsetRoleSequenceGUID, SubsetConstraintSupersetRoleSequenceGUID FROM dbo.Concept
+CREATE VIEW dbo.SubsetConstraintInConstraint_SubsetConstraintSubsetRoleSequenceGUIDSubsetConstraintSupersetRoleSequenceGUID (SubsetConstraintSubsetRoleSequenceGUID, SubsetConstraintSupersetRoleSequenceGUID) WITH SCHEMABINDING AS
+ SELECT SubsetConstraintSubsetRoleSequenceGUID, SubsetConstraintSupersetRoleSequenceGUID FROM dbo.[Constraint]
WHERE SubsetConstraintSubsetRoleSequenceGUID IS NOT NULL
AND SubsetConstraintSupersetRoleSequenceGUID IS NOT NULL
GO
-CREATE UNIQUE CLUSTERED INDEX IX_SubsetConstraintInConceptBySubsetConstraintSubsetRoleSequenceGUIDSubsetConstraintSupersetRoleSequenceGUID ON dbo.SubsetConstraintInConcept_SubsetConstraintSubsetRoleSequenceGUIDSubsetConstraintSupersetRoleSequenceGUID(SubsetConstraintSubsetRoleSequenceGUID, SubsetConstraintSupersetRoleSequenceGUID)
+CREATE UNIQUE CLUSTERED INDEX IX_SubsetConstraintInConstraintBySubsetConstraintSubsetRoleSequenceGUIDSubsetConstraintSupersetRoleSequenceGUID ON dbo.SubsetConstraintInConstraint_SubsetConstraintSubsetRoleSequenceGUIDSubsetConstraintSupersetRoleSequenceGUID(SubsetConstraintSubsetRoleSequenceGUID, SubsetConstraintSupersetRoleSequenceGUID)
GO
-CREATE VIEW dbo.ValueConstraintInConcept_ValueConstraintRoleGUID (ValueConstraintRoleGUID) WITH SCHEMABINDING AS
- SELECT ValueConstraintRoleGUID FROM dbo.Concept
+CREATE VIEW dbo.ValueConstraintInConstraint_ValueConstraintRoleGUID (ValueConstraintRoleGUID) WITH SCHEMABINDING AS
+ SELECT ValueConstraintRoleGUID FROM dbo.[Constraint]
WHERE ValueConstraintRoleGUID IS NOT NULL
GO
-CREATE UNIQUE CLUSTERED INDEX RoleHasOneRoleValueConstraint ON dbo.ValueConstraintInConcept_ValueConstraintRoleGUID(ValueConstraintRoleGUID)
+CREATE UNIQUE CLUSTERED INDEX RoleHasOneRoleValueConstraint ON dbo.ValueConstraintInConstraint_ValueConstraintRoleGUID(ValueConstraintRoleGUID)
GO
-CREATE VIEW dbo.ValueTypeInConcept_ValueTypeValueConstraintGUID (ValueTypeValueConstraintGUID) WITH SCHEMABINDING AS
- SELECT ValueTypeValueConstraintGUID FROM dbo.Concept
- WHERE ValueTypeValueConstraintGUID IS NOT NULL
+CREATE VIEW dbo.Constraint_VocabularyTopicNameVocabularyLanguageCodeName (VocabularyTopicName, VocabularyLanguageCode, Name) WITH SCHEMABINDING AS
+ SELECT VocabularyTopicName, VocabularyLanguageCode, Name FROM dbo.[Constraint]
+ WHERE VocabularyTopicName IS NOT NULL
+ AND VocabularyLanguageCode IS NOT NULL
+ AND Name IS NOT NULL
GO
-CREATE UNIQUE CLUSTERED INDEX IX_ValueTypeInConceptByValueTypeValueConstraintGUID ON dbo.ValueTypeInConcept_ValueTypeValueConstraintGUID(ValueTypeValueConstraintGUID)
+CREATE UNIQUE CLUSTERED INDEX IX_ConstraintByVocabularyTopicNameVocabularyLanguageCodeName ON dbo.Constraint_VocabularyTopicNameVocabularyLanguageCodeName(VocabularyTopicName, VocabularyLanguageCode, Name)
GO
CREATE TABLE ContextAccordingTo (
@@ -196,8 +120,7 @@ CREATE TABLE ContextNote (
Discussion varchar NOT NULL,
-- Context Note has GUID,
GUID varchar NOT NULL,
- PRIMARY KEY(GUID),
- FOREIGN KEY (ConceptGUID) REFERENCES Concept (GUID)
+ PRIMARY KEY(GUID)
)
GO
@@ -213,39 +136,36 @@ CREATE TABLE Derivation (
GO
CREATE TABLE Facet (
- -- maybe Facet has values of facet-Value Type and Concept has GUID,
+ -- maybe Facet has values of facet-Value Type and Object Type is a kind of Concept and Concept has GUID,
FacetValueTypeGUID varchar NULL,
-- Facet is where Value Type has facet called Name,
Name varchar(64) NOT NULL,
- -- Facet is where Value Type has facet called Name and Concept has GUID,
+ -- Facet is where Value Type has facet called Name and Object Type is a kind of Concept and Concept has GUID,
ValueTypeGUID varchar NOT NULL,
- PRIMARY KEY(ValueTypeGUID, Name),
- FOREIGN KEY (FacetValueTypeGUID) REFERENCES Concept (GUID),
- FOREIGN KEY (ValueTypeGUID) REFERENCES Concept (GUID)
+ PRIMARY KEY(ValueTypeGUID, Name)
)
GO
CREATE TABLE FacetValue (
-- Facet Value is where Value Type defines Facet as having Value and Facet is where Value Type has facet called Name,
FacetName varchar(64) NOT NULL,
- -- Facet Value is where Value Type defines Facet as having Value and Facet is where Value Type has facet called Name and Concept has GUID,
+ -- Facet Value is where Value Type defines Facet as having Value and Facet is where Value Type has facet called Name and Object Type is a kind of Concept and Concept has GUID,
FacetValueTypeGUID varchar NOT NULL,
-- Facet Value is where Value Type defines Facet as having Value and Value is a string,
ValueIsAString bit NOT NULL,
-- Facet Value is where Value Type defines Facet as having Value and Value is represented by Literal,
ValueLiteral varchar NOT NULL,
- -- Facet Value is where Value Type defines Facet as having Value and Concept has GUID,
+ -- Facet Value is where Value Type defines Facet as having Value and Object Type is a kind of Concept and Concept has GUID,
ValueTypeGUID varchar NOT NULL,
-- Facet Value is where Value Type defines Facet as having Value and maybe Value is in Unit and Unit has Unit Code,
ValueUnitCode char NULL,
PRIMARY KEY(ValueTypeGUID, FacetValueTypeGUID, FacetName),
- FOREIGN KEY (ValueTypeGUID) REFERENCES Concept (GUID),
FOREIGN KEY (FacetName, FacetValueTypeGUID) REFERENCES Facet (Name, ValueTypeGUID)
)
GO
CREATE TABLE Fact (
- -- Fact is of Fact Type and Concept has GUID,
+ -- Fact is of Fact Type and Fact Type is a kind of Concept and Concept has GUID,
FactTypeGUID varchar NOT NULL,
-- Fact has GUID,
GUID varchar NOT NULL,
@@ -253,17 +173,52 @@ CREATE TABLE Fact (
PopulationName varchar(64) NOT NULL,
-- Population includes Fact and maybe Topic includes Population and Topic has Name,
PopulationTopicName varchar(64) NULL,
- PRIMARY KEY(GUID),
- FOREIGN KEY (FactTypeGUID) REFERENCES Concept (GUID)
+ PRIMARY KEY(GUID)
)
GO
+CREATE TABLE FactType (
+ -- Fact Type is a kind of Concept and Concept has GUID,
+ ConceptGUID varchar NOT NULL,
+ -- maybe Entity Type objectifies Fact Type and Object Type is a kind of Concept and Concept has GUID,
+ EntityTypeGUID varchar NULL,
+ -- maybe Type Inheritance implies Fact Type and maybe Assimilation applies to Type Inheritance,
+ TypeInheritanceAssimilation varchar NULL CHECK(TypeInheritanceAssimilation = 'partitioned' OR TypeInheritanceAssimilation = 'separate'),
+ -- maybe Type Inheritance implies Fact Type and Type Inheritance provides identification,
+ TypeInheritanceProvidesIdentification bit NULL,
+ -- maybe Type Inheritance implies Fact Type and Type Inheritance is where Entity Type is subtype of super-Entity Type and Object Type is a kind of Concept and Concept has GUID,
+ TypeInheritanceSubtypeGUID varchar NULL,
+ -- maybe Type Inheritance implies Fact Type and Type Inheritance is where Entity Type is subtype of super-Entity Type and Object Type is a kind of Concept and Concept has GUID,
+ TypeInheritanceSupertypeGUID varchar NULL,
+ PRIMARY KEY(ConceptGUID)
+)
+GO
+
+CREATE VIEW dbo.FactType_EntityTypeGUID (EntityTypeGUID) WITH SCHEMABINDING AS
+ SELECT EntityTypeGUID FROM dbo.FactType
+ WHERE EntityTypeGUID IS NOT NULL
+GO
+
+CREATE UNIQUE CLUSTERED INDEX EntityTypeNestsOneFactType ON dbo.FactType_EntityTypeGUID(EntityTypeGUID)
+GO
+
+CREATE VIEW dbo.FactType_TypeInheritanceSubtypeGUIDTypeInheritanceSupertypeGUIDTypeInheritanceAssimilationTypeInheritanceProvidesIdentif (TypeInheritanceSubtypeGUID, TypeInheritanceSupertypeGUID, TypeInheritanceAssimilation, TypeInheritanceProvidesIdentification) WITH SCHEMABINDING AS
+ SELECT TypeInheritanceSubtypeGUID, TypeInheritanceSupertypeGUID, TypeInheritanceAssimilation, TypeInheritanceProvidesIdentification FROM dbo.FactType
+ WHERE TypeInheritanceSubtypeGUID IS NOT NULL
+ AND TypeInheritanceSupertypeGUID IS NOT NULL
+ AND TypeInheritanceAssimilation IS NOT NULL
+ AND TypeInheritanceProvidesIdentification IS NOT NULL
+GO
+
+CREATE UNIQUE CLUSTERED INDEX IX_FactTypeByTypeInheritanceSubtypeGUIDTypeInheritanceSupertypeGUIDTypeInheritanceAssimilationTypeInheritanceProvidesIde ON dbo.FactType_TypeInheritanceSubtypeGUIDTypeInheritanceSupertypeGUIDTypeInheritanceAssimilationTypeInheritanceProvidesIdentif(TypeInheritanceSubtypeGUID, TypeInheritanceSupertypeGUID, TypeInheritanceAssimilation, TypeInheritanceProvidesIdentification)
+GO
+
CREATE TABLE Instance (
-- maybe Instance objectifies Fact and Fact has GUID,
FactGUID varchar NULL,
-- Instance has GUID,
GUID varchar NOT NULL,
- -- Instance is of Object Type and Concept has GUID,
+ -- Instance is of Object Type and Object Type is a kind of Concept and Concept has GUID,
ObjectTypeGUID varchar NOT NULL,
-- Population includes Instance and Population has Name,
PopulationName varchar(64) NOT NULL,
@@ -276,7 +231,6 @@ CREATE TABLE Instance (
-- maybe Instance has Value and maybe Value is in Unit and Unit has Unit Code,
ValueUnitCode char NULL,
PRIMARY KEY(GUID),
- FOREIGN KEY (ObjectTypeGUID) REFERENCES Concept (GUID),
FOREIGN KEY (FactGUID) REFERENCES Fact (GUID)
)
GO
@@ -299,7 +253,7 @@ GO
CREATE TABLE JoinNode (
-- Join includes Join Node and Join has GUID,
JoinGUID varchar NOT NULL,
- -- Join Node is for Object Type and Concept has GUID,
+ -- Join Node is for Object Type and Object Type is a kind of Concept and Concept has GUID,
ObjectTypeGUID varchar NOT NULL,
-- Join Node has Ordinal position,
Ordinal shortint NOT NULL,
@@ -314,7 +268,6 @@ CREATE TABLE JoinNode (
-- maybe Join Node has Value and maybe Value is in Unit and Unit has Unit Code,
ValueUnitCode char NULL,
PRIMARY KEY(JoinGUID, Ordinal),
- FOREIGN KEY (ObjectTypeGUID) REFERENCES Concept (GUID),
FOREIGN KEY (JoinGUID) REFERENCES [Join] (GUID)
)
GO
@@ -324,26 +277,25 @@ CREATE TABLE JoinRole (
JoinNodeJoinGUID varchar NOT NULL,
-- Join Role is where Join Node includes Role and Join Node has Ordinal position,
JoinNodeOrdinal shortint NOT NULL,
- -- maybe Join Step involves incidental-Join Role and Join Step has input-Join Role and Join Role is where Join Node includes Role and Concept has GUID,
+ -- maybe Join Step involves incidental-Join Role and Join Step has input-Join Role and Join Role is where Join Node includes Role and Role is a kind of Concept and Concept has GUID,
JoinStepInputJoinRoleGUID varchar NULL,
-- maybe Join Step involves incidental-Join Role and Join Step has input-Join Role and Join Role is where Join Node includes Role and Join includes Join Node and Join has GUID,
JoinStepInputJoinRoleJoinNodeJoinGUID varchar NULL,
-- maybe Join Step involves incidental-Join Role and Join Step has input-Join Role and Join Role is where Join Node includes Role and Join Node has Ordinal position,
JoinStepInputJoinRoleJoinNodeOrdinal shortint NULL,
- -- maybe Join Step involves incidental-Join Role and Join Step has output-Join Role and Join Role is where Join Node includes Role and Concept has GUID,
+ -- maybe Join Step involves incidental-Join Role and Join Step has output-Join Role and Join Role is where Join Node includes Role and Role is a kind of Concept and Concept has GUID,
JoinStepOutputJoinRoleGUID varchar NULL,
-- maybe Join Step involves incidental-Join Role and Join Step has output-Join Role and Join Role is where Join Node includes Role and Join includes Join Node and Join has GUID,
JoinStepOutputJoinRoleJoinNodeJoinGUID varchar NULL,
-- maybe Join Step involves incidental-Join Role and Join Step has output-Join Role and Join Role is where Join Node includes Role and Join Node has Ordinal position,
JoinStepOutputJoinRoleJoinNodeOrdinal shortint NULL,
- -- Join Role is where Join Node includes Role and Concept has GUID,
+ -- Join Role is where Join Node includes Role and Role is a kind of Concept and Concept has GUID,
RoleGUID varchar NOT NULL,
-- maybe Join Role projects Role Ref and Role Ref is where Role Sequence in Ordinal position includes Role,
RoleRefOrdinal shortint NULL,
-- maybe Join Role projects Role Ref and Role Ref is where Role Sequence in Ordinal position includes Role and Role Sequence has GUID,
RoleRefRoleSequenceGUID varchar NULL,
PRIMARY KEY(JoinNodeJoinGUID, JoinNodeOrdinal, RoleGUID),
- FOREIGN KEY (RoleGUID) REFERENCES Concept (GUID),
FOREIGN KEY (JoinNodeJoinGUID, JoinNodeOrdinal) REFERENCES JoinNode (JoinGUID, Ordinal)
)
GO
@@ -358,9 +310,9 @@ CREATE UNIQUE CLUSTERED INDEX IX_JoinRoleByRoleRefRoleSequenceGUIDRoleRefOrdinal
GO
CREATE TABLE JoinStep (
- -- Join Step traverses Fact Type and Concept has GUID,
+ -- Join Step traverses Fact Type and Fact Type is a kind of Concept and Concept has GUID,
FactTypeGUID varchar NOT NULL,
- -- Join Step has input-Join Role and Join Role is where Join Node includes Role and Concept has GUID,
+ -- Join Step has input-Join Role and Join Role is where Join Node includes Role and Role is a kind of Concept and Concept has GUID,
InputJoinRoleGUID varchar NOT NULL,
-- Join Step has input-Join Role and Join Role is where Join Node includes Role and Join includes Join Node and Join has GUID,
InputJoinRoleJoinNodeJoinGUID varchar NOT NULL,
@@ -370,21 +322,56 @@ CREATE TABLE JoinStep (
IsAnti bit NOT NULL,
-- Join Step is outer,
IsOuter bit NOT NULL,
- -- Join Step has output-Join Role and Join Role is where Join Node includes Role and Concept has GUID,
+ -- Join Step has output-Join Role and Join Role is where Join Node includes Role and Role is a kind of Concept and Concept has GUID,
OutputJoinRoleGUID varchar NOT NULL,
-- Join Step has output-Join Role and Join Role is where Join Node includes Role and Join includes Join Node and Join has GUID,
OutputJoinRoleJoinNodeJoinGUID varchar NOT NULL,
-- Join Step has output-Join Role and Join Role is where Join Node includes Role and Join Node has Ordinal position,
OutputJoinRoleJoinNodeOrdinal shortint NOT NULL,
PRIMARY KEY(InputJoinRoleJoinNodeJoinGUID, InputJoinRoleJoinNodeOrdinal, InputJoinRoleGUID, OutputJoinRoleJoinNodeJoinGUID, OutputJoinRoleJoinNodeOrdinal, OutputJoinRoleGUID),
- FOREIGN KEY (FactTypeGUID) REFERENCES Concept (GUID),
+ FOREIGN KEY (FactTypeGUID) REFERENCES FactType (ConceptGUID),
FOREIGN KEY (InputJoinRoleJoinNodeJoinGUID, InputJoinRoleJoinNodeOrdinal, InputJoinRoleGUID) REFERENCES JoinRole (JoinNodeJoinGUID, JoinNodeOrdinal, RoleGUID),
FOREIGN KEY (OutputJoinRoleJoinNodeJoinGUID, OutputJoinRoleJoinNodeOrdinal, OutputJoinRoleGUID) REFERENCES JoinRole (JoinNodeJoinGUID, JoinNodeOrdinal, RoleGUID)
)
GO
+CREATE TABLE ObjectType (
+ -- Object Type is a kind of Concept and Concept has GUID,
+ ConceptGUID varchar NOT NULL,
+ -- maybe Entity Type is a kind of Object Type and Entity Type is implied by objectification,
+ EntityTypeIsImpliedByObjectification bit NULL,
+ -- Object Type is independent,
+ IsIndependent bit NOT NULL,
+ -- maybe Object Type uses Pronoun,
+ Pronoun varchar(20) NULL CHECK(Pronoun = 'feminine' OR Pronoun = 'masculine' OR Pronoun = 'neuter' OR Pronoun = 'personal'),
+ -- maybe Value Type is a kind of Object Type and maybe Value Type has auto- assigned Transaction Timing,
+ ValueTypeAutoAssignedTransactionTiming varchar NULL CHECK(ValueTypeAutoAssignedTransactionTiming = 'assert' OR ValueTypeAutoAssignedTransactionTiming = 'commit'),
+ -- maybe Value Type is a kind of Object Type and maybe Value Type has Length,
+ ValueTypeLength int NULL,
+ -- maybe Value Type is a kind of Object Type and maybe Value Type has Scale,
+ ValueTypeScale int NULL,
+ -- maybe Value Type is a kind of Object Type and maybe Value Type is subtype of super-Value Type and Object Type is a kind of Concept and Concept has GUID,
+ ValueTypeSupertypeGUID varchar NULL,
+ -- maybe Value Type is a kind of Object Type and maybe Value Type is of Unit and Unit has Unit Code,
+ ValueTypeUnitCode char NULL,
+ -- maybe Value Type is a kind of Object Type and maybe Value Type has Value Constraint and Constraint is a kind of Concept and Concept has GUID,
+ ValueTypeValueConstraintGUID varchar NULL,
+ PRIMARY KEY(ConceptGUID),
+ FOREIGN KEY (ValueTypeValueConstraintGUID) REFERENCES [Constraint] (ConceptGUID),
+ FOREIGN KEY (ValueTypeSupertypeGUID) REFERENCES ObjectType (ConceptGUID)
+)
+GO
+
+CREATE VIEW dbo.ValueTypeInObjectType_ValueTypeValueConstraintGUID (ValueTypeValueConstraintGUID) WITH SCHEMABINDING AS
+ SELECT ValueTypeValueConstraintGUID FROM dbo.ObjectType
+ WHERE ValueTypeValueConstraintGUID IS NOT NULL
+GO
+
+CREATE UNIQUE CLUSTERED INDEX IX_ValueTypeInObjectTypeByValueTypeValueConstraintGUID ON dbo.ValueTypeInObjectType_ValueTypeValueConstraintGUID(ValueTypeValueConstraintGUID)
+GO
+
CREATE TABLE Reading (
- -- Fact Type has Reading and Concept has GUID,
+ -- Fact Type has Reading and Fact Type is a kind of Concept and Concept has GUID,
FactTypeGUID varchar NOT NULL,
-- Reading is in Ordinal position,
Ordinal shortint NOT NULL,
@@ -397,19 +384,52 @@ CREATE TABLE Reading (
-- maybe Reading is for Vocabulary and Vocabulary is where Topic is described in Language and Topic has Name,
VocabularyTopicName varchar(64) NULL,
PRIMARY KEY(FactTypeGUID, Ordinal),
- FOREIGN KEY (FactTypeGUID) REFERENCES Concept (GUID)
+ FOREIGN KEY (FactTypeGUID) REFERENCES FactType (ConceptGUID)
+)
+GO
+
+CREATE TABLE Role (
+ -- Role is a kind of Concept and Concept has GUID,
+ ConceptGUID varchar NOT NULL,
+ -- Role is where Fact Type has Ordinal role and Fact Type is a kind of Concept and Concept has GUID,
+ FactTypeGUID varchar NOT NULL,
+ -- maybe Implicit Fact Type is implied by Role and Fact Type is a kind of Concept and Concept has GUID,
+ ImplicitFactTypeGUID varchar NULL,
+ -- Object Type plays Role and Object Type is a kind of Concept and Concept has GUID,
+ ObjectTypeGUID varchar NOT NULL,
+ -- Role is where Fact Type has Ordinal role,
+ Ordinal shortint NOT NULL,
+ -- maybe Term is name of Role and Term is where Vocabulary uses Name for Object Type,
+ RoleName varchar(64) NULL,
+ -- maybe Term is name of Role and Term is where Vocabulary uses Name for Object Type and Vocabulary is where Topic is described in Language and Language has Language Code,
+ RoleNameVocabularyLanguageCode char(3) NULL,
+ -- maybe Term is name of Role and Term is where Vocabulary uses Name for Object Type and Vocabulary is where Topic is described in Language and Topic has Name,
+ RoleNameVocabularyTopicName varchar(64) NULL,
+ PRIMARY KEY(ConceptGUID),
+ UNIQUE(FactTypeGUID, Ordinal),
+ FOREIGN KEY (ImplicitFactTypeGUID) REFERENCES FactType (ConceptGUID),
+ FOREIGN KEY (FactTypeGUID) REFERENCES FactType (ConceptGUID),
+ FOREIGN KEY (ObjectTypeGUID) REFERENCES ObjectType (ConceptGUID)
)
GO
+CREATE VIEW dbo.Role_ImplicitFactTypeGUID (ImplicitFactTypeGUID) WITH SCHEMABINDING AS
+ SELECT ImplicitFactTypeGUID FROM dbo.Role
+ WHERE ImplicitFactTypeGUID IS NOT NULL
+GO
+
+CREATE UNIQUE CLUSTERED INDEX IX_RoleByImplicitFactTypeGUID ON dbo.Role_ImplicitFactTypeGUID(ImplicitFactTypeGUID)
+GO
+
CREATE TABLE RoleDisplay (
-- Role Display is where Fact Type Shape displays Role in Ordinal position and Shape has GUID,
FactTypeShapeGUID varchar NOT NULL,
-- Role Display is where Fact Type Shape displays Role in Ordinal position,
Ordinal shortint NOT NULL,
- -- Role Display is where Fact Type Shape displays Role in Ordinal position and Concept has GUID,
+ -- Role Display is where Fact Type Shape displays Role in Ordinal position and Role is a kind of Concept and Concept has GUID,
RoleGUID varchar NOT NULL,
PRIMARY KEY(FactTypeShapeGUID, Ordinal),
- FOREIGN KEY (RoleGUID) REFERENCES Concept (GUID)
+ FOREIGN KEY (RoleGUID) REFERENCES Role (ConceptGUID)
)
GO
@@ -418,7 +438,7 @@ CREATE TABLE RoleRef (
LeadingAdjective varchar(64) NULL,
-- Role Ref is where Role Sequence in Ordinal position includes Role,
Ordinal shortint NOT NULL,
- -- Role Ref is where Role Sequence in Ordinal position includes Role and Concept has GUID,
+ -- Role Ref is where Role Sequence in Ordinal position includes Role and Role is a kind of Concept and Concept has GUID,
RoleGUID varchar NOT NULL,
-- Role Ref is where Role Sequence in Ordinal position includes Role and Role Sequence has GUID,
RoleSequenceGUID varchar NOT NULL,
@@ -426,16 +446,7 @@ CREATE TABLE RoleRef (
TrailingAdjective varchar(64) NULL,
PRIMARY KEY(RoleSequenceGUID, Ordinal),
UNIQUE(RoleGUID, RoleSequenceGUID),
- FOREIGN KEY (RoleGUID) REFERENCES Concept (GUID)
-)
-GO
-
-CREATE TABLE RoleSequence (
- -- Role Sequence has GUID,
- GUID varchar NOT NULL,
- -- Role Sequence has unused dependency to force table in norma,
- HasUnusedDependencyToForceTableInNorma bit NOT NULL,
- PRIMARY KEY(GUID)
+ FOREIGN KEY (RoleGUID) REFERENCES Role (ConceptGUID)
)
GO
@@ -448,12 +459,12 @@ CREATE TABLE RoleValue (
PopulationName varchar(64) NOT NULL,
-- Population includes Role Value and maybe Topic includes Population and Topic has Name,
PopulationTopicName varchar(64) NULL,
- -- Role Value is of Role and Concept has GUID,
+ -- Role Value is of Role and Role is a kind of Concept and Concept has GUID,
RoleGUID varchar NOT NULL,
PRIMARY KEY(InstanceGUID, FactGUID),
- FOREIGN KEY (RoleGUID) REFERENCES Concept (GUID),
FOREIGN KEY (FactGUID) REFERENCES Fact (GUID),
- FOREIGN KEY (InstanceGUID) REFERENCES Instance (GUID)
+ FOREIGN KEY (InstanceGUID) REFERENCES Instance (GUID),
+ FOREIGN KEY (RoleGUID) REFERENCES Role (ConceptGUID)
)
GO
@@ -462,17 +473,16 @@ CREATE TABLE SetComparisonRoles (
Ordinal shortint NOT NULL,
-- Set Comparison Roles is where Set Comparison Constraint has in Ordinal position Role Sequence and Role Sequence has GUID,
RoleSequenceGUID varchar NOT NULL,
- -- Set Comparison Roles is where Set Comparison Constraint has in Ordinal position Role Sequence and Concept has GUID,
+ -- Set Comparison Roles is where Set Comparison Constraint has in Ordinal position Role Sequence and Constraint is a kind of Concept and Concept has GUID,
SetComparisonConstraintGUID varchar NOT NULL,
PRIMARY KEY(SetComparisonConstraintGUID, Ordinal),
UNIQUE(SetComparisonConstraintGUID, RoleSequenceGUID),
- FOREIGN KEY (SetComparisonConstraintGUID) REFERENCES Concept (GUID),
- FOREIGN KEY (RoleSequenceGUID) REFERENCES RoleSequence (GUID)
+ FOREIGN KEY (SetComparisonConstraintGUID) REFERENCES [Constraint] (ConceptGUID)
)
GO
CREATE TABLE Shape (
- -- maybe Constraint Shape is a kind of Shape and Constraint Shape is for Constraint and Concept has GUID,
+ -- maybe Constraint Shape is a kind of Shape and Constraint Shape is for Constraint and Constraint is a kind of Concept and Concept has GUID,
ConstraintShapeConstraintGUID varchar NULL,
-- Shape is in Diagram and Diagram is called Name,
DiagramName varchar(64) NOT NULL,
@@ -482,13 +492,13 @@ CREATE TABLE Shape (
DiagramVocabularyTopicName varchar(64) NOT NULL,
-- maybe Fact Type Shape is a kind of Shape and maybe Fact Type Shape has Display Role Names Setting,
FactTypeShapeDisplayRoleNamesSetting varchar NULL CHECK(FactTypeShapeDisplayRoleNamesSetting = 'false' OR FactTypeShapeDisplayRoleNamesSetting = 'true'),
- -- maybe Fact Type Shape is a kind of Shape and Fact Type Shape is for Fact Type and Concept has GUID,
+ -- maybe Fact Type Shape is a kind of Shape and Fact Type Shape is for Fact Type and Fact Type is a kind of Concept and Concept has GUID,
FactTypeShapeFactTypeGUID varchar NULL,
-- maybe Fact Type Shape is a kind of Shape and maybe Fact Type Shape has Reading Shape and Reading Shape is a kind of Shape and Shape has GUID,
FactTypeShapeGUID varchar NULL,
-- maybe Fact Type Shape is a kind of Shape and maybe Objectified Fact Type Name Shape is for Fact Type Shape and Objectified Fact Type Name Shape is a kind of Shape and Shape has GUID,
FactTypeShapeGUID varchar NULL,
- -- maybe Fact Type Shape is a kind of Shape and maybe Fact Type Shape has Reading Shape and Reading Shape is for Reading and Fact Type has Reading and Concept has GUID,
+ -- maybe Fact Type Shape is a kind of Shape and maybe Fact Type Shape has Reading Shape and Reading Shape is for Reading and Fact Type has Reading and Fact Type is a kind of Concept and Concept has GUID,
FactTypeShapeReadingFactTypeGUID varchar NULL,
-- maybe Fact Type Shape is a kind of Shape and maybe Fact Type Shape has Reading Shape and Reading Shape is for Reading and Reading is in Ordinal position,
FactTypeShapeReadingOrdinal shortint NULL,
@@ -500,13 +510,13 @@ CREATE TABLE Shape (
IsExpanded bit NOT NULL,
-- maybe Model Note Shape is a kind of Shape and Model Note Shape is for Context Note and Context Note has GUID,
ModelNoteShapeContextNoteGUID varchar NULL,
- -- maybe Object Type Shape is a kind of Shape and Object Type Shape is for Object Type and Concept has GUID,
+ -- maybe Object Type Shape is a kind of Shape and Object Type Shape is for Object Type and Object Type is a kind of Concept and Concept has GUID,
ObjectTypeShapeObjectTypeGUID varchar NULL,
-- maybe Shape is at Position and Position is at X,
PositionX int NULL,
-- maybe Shape is at Position and Position is at Y,
PositionY int NULL,
- -- maybe Constraint Shape is a kind of Shape and maybe Ring Constraint Shape is a kind of Constraint Shape and Ring Constraint Shape is attached to Fact Type and Concept has GUID,
+ -- maybe Constraint Shape is a kind of Shape and maybe Ring Constraint Shape is a kind of Constraint Shape and Ring Constraint Shape is attached to Fact Type and Fact Type is a kind of Concept and Concept has GUID,
RingConstraintShapeFactTypeGUID varchar NULL,
-- maybe Role Name Shape is a kind of Shape and Role Name Shape is for Role Display and Role Display is where Fact Type Shape displays Role in Ordinal position and Shape has GUID,
RoleNameShapeRoleDisplayFactTypeShapeGUID varchar NULL,
@@ -519,11 +529,11 @@ CREATE TABLE Shape (
-- maybe Constraint Shape is a kind of Shape and maybe Value Constraint Shape is a kind of Constraint Shape and maybe Role Display has Value Constraint Shape and Role Display is where Fact Type Shape displays Role in Ordinal position,
ValueConstraintShapeRoleDisplayOrdinal shortint NULL,
PRIMARY KEY(GUID),
- FOREIGN KEY (ConstraintShapeConstraintGUID) REFERENCES Concept (GUID),
- FOREIGN KEY (RingConstraintShapeFactTypeGUID) REFERENCES Concept (GUID),
- FOREIGN KEY (FactTypeShapeFactTypeGUID) REFERENCES Concept (GUID),
- FOREIGN KEY (ObjectTypeShapeObjectTypeGUID) REFERENCES Concept (GUID),
+ FOREIGN KEY (ConstraintShapeConstraintGUID) REFERENCES [Constraint] (ConceptGUID),
FOREIGN KEY (ModelNoteShapeContextNoteGUID) REFERENCES ContextNote (GUID),
+ FOREIGN KEY (RingConstraintShapeFactTypeGUID) REFERENCES FactType (ConceptGUID),
+ FOREIGN KEY (FactTypeShapeFactTypeGUID) REFERENCES FactType (ConceptGUID),
+ FOREIGN KEY (ObjectTypeShapeObjectTypeGUID) REFERENCES ObjectType (ConceptGUID),
FOREIGN KEY (FactTypeShapeReadingFactTypeGUID, FactTypeShapeReadingOrdinal) REFERENCES Reading (FactTypeGUID, Ordinal),
FOREIGN KEY (ValueConstraintShapeRoleDisplayFactTypeShapeGUID, ValueConstraintShapeRoleDisplayOrdinal) REFERENCES RoleDisplay (FactTypeShapeGUID, Ordinal),
FOREIGN KEY (RoleNameShapeRoleDisplayFactTypeShapeGUID, RoleNameShapeRoleDisplayOrdinal) REFERENCES RoleDisplay (FactTypeShapeGUID, Ordinal),
@@ -581,7 +591,7 @@ CREATE TABLE Term (
IsPreferred bit NOT NULL,
-- Term is where Vocabulary uses Name for Object Type,
Name varchar(64) NOT NULL,
- -- Term is where Vocabulary uses Name for Object Type and Concept has GUID,
+ -- Term is where Vocabulary uses Name for Object Type and Object Type is a kind of Concept and Concept has GUID,
ObjectTypeGUID varchar NOT NULL,
-- Term is where Vocabulary uses Name for Object Type and Vocabulary is where Topic is described in Language and Language has Language Code,
VocabularyLanguageCode char(3) NOT NULL,
@@ -589,27 +599,7 @@ CREATE TABLE Term (
VocabularyTopicName varchar(64) NOT NULL,
PRIMARY KEY(VocabularyTopicName, VocabularyLanguageCode, Name),
UNIQUE(VocabularyTopicName, VocabularyLanguageCode, ObjectTypeGUID, IsPreferred),
- FOREIGN KEY (ObjectTypeGUID) REFERENCES Concept (GUID)
-)
-GO
-
-CREATE TABLE TypeInheritance (
- -- maybe Assimilation applies to Type Inheritance,
- Assimilation varchar NULL CHECK(Assimilation = 'partitioned' OR Assimilation = 'separate'),
- -- Type Inheritance implies Fact Type and Concept has GUID,
- FactTypeGUID varchar NOT NULL,
- -- Type Inheritance provides identification,
- ProvidesIdentification bit NOT NULL,
- -- Type Inheritance is where Entity Type is subtype of super-Entity Type and Concept has GUID,
- SubtypeGUID varchar NOT NULL,
- -- Type Inheritance is where Entity Type is subtype of super-Entity Type and Concept has GUID,
- SupertypeGUID varchar NOT NULL,
- PRIMARY KEY(SubtypeGUID, SupertypeGUID),
- UNIQUE(FactTypeGUID),
- UNIQUE(SubtypeGUID, ProvidesIdentification),
- FOREIGN KEY (FactTypeGUID) REFERENCES Concept (GUID),
- FOREIGN KEY (SubtypeGUID) REFERENCES Concept (GUID),
- FOREIGN KEY (SupertypeGUID) REFERENCES Concept (GUID)
+ FOREIGN KEY (ObjectTypeGUID) REFERENCES ObjectType (ConceptGUID)
)
GO
@@ -642,27 +632,19 @@ CREATE TABLE Unit (
GO
ALTER TABLE AllowedRange
- ADD FOREIGN KEY (ValueConstraintGUID) REFERENCES Concept (GUID)
-GO
-
-ALTER TABLE Concept
- ADD FOREIGN KEY (PresenceConstraintRoleSequenceGUID) REFERENCES RoleSequence (GUID)
+ ADD FOREIGN KEY (ValueConstraintGUID) REFERENCES [Constraint] (ConceptGUID)
GO
-ALTER TABLE Concept
- ADD FOREIGN KEY (SubsetConstraintSubsetRoleSequenceGUID) REFERENCES RoleSequence (GUID)
+ALTER TABLE [Constraint]
+ ADD FOREIGN KEY (RingConstraintOtherRoleGUID) REFERENCES Role (ConceptGUID)
GO
-ALTER TABLE Concept
- ADD FOREIGN KEY (SubsetConstraintSupersetRoleSequenceGUID) REFERENCES RoleSequence (GUID)
+ALTER TABLE [Constraint]
+ ADD FOREIGN KEY (RingConstraintRoleGUID) REFERENCES Role (ConceptGUID)
GO
-ALTER TABLE Concept
- ADD FOREIGN KEY (RoleName, RoleNameVocabularyLanguageCode, RoleNameVocabularyTopicName) REFERENCES Term (Name, VocabularyLanguageCode, VocabularyTopicName)
-GO
-
-ALTER TABLE Concept
- ADD FOREIGN KEY (ValueTypeUnitCode) REFERENCES Unit (UnitCode)
+ALTER TABLE [Constraint]
+ ADD FOREIGN KEY (ValueConstraintRoleGUID) REFERENCES Role (ConceptGUID)
GO
ALTER TABLE ContextAccordingTo
@@ -681,23 +663,55 @@ ALTER TABLE Derivation
ADD FOREIGN KEY (DerivedUnitCode) REFERENCES Unit (UnitCode)
GO
+ALTER TABLE Facet
+ ADD FOREIGN KEY (FacetValueTypeGUID) REFERENCES ObjectType (ConceptGUID)
+GO
+
+ALTER TABLE Facet
+ ADD FOREIGN KEY (ValueTypeGUID) REFERENCES ObjectType (ConceptGUID)
+GO
+
+ALTER TABLE FacetValue
+ ADD FOREIGN KEY (ValueTypeGUID) REFERENCES ObjectType (ConceptGUID)
+GO
+
+ALTER TABLE Fact
+ ADD FOREIGN KEY (FactTypeGUID) REFERENCES FactType (ConceptGUID)
+GO
+
+ALTER TABLE FactType
+ ADD FOREIGN KEY (EntityTypeGUID) REFERENCES ObjectType (ConceptGUID)
+GO
+
+ALTER TABLE Instance
+ ADD FOREIGN KEY (ObjectTypeGUID) REFERENCES ObjectType (ConceptGUID)
+GO
+
+ALTER TABLE JoinNode
+ ADD FOREIGN KEY (ObjectTypeGUID) REFERENCES ObjectType (ConceptGUID)
+GO
+
ALTER TABLE JoinRole
ADD FOREIGN KEY (JoinStepInputJoinRoleGUID, JoinStepInputJoinRoleJoinNodeJoinGUID, JoinStepInputJoinRoleJoinNodeOrdinal, JoinStepOutputJoinRoleGUID, JoinStepOutputJoinRoleJoinNodeJoinGUID, JoinStepOutputJoinRoleJoinNodeOrdinal) REFERENCES JoinStep (InputJoinRoleGUID, InputJoinRoleJoinNodeJoinGUID, InputJoinRoleJoinNodeOrdinal, OutputJoinRoleGUID, OutputJoinRoleJoinNodeJoinGUID, OutputJoinRoleJoinNodeOrdinal)
GO
ALTER TABLE JoinRole
+ ADD FOREIGN KEY (RoleGUID) REFERENCES Role (ConceptGUID)
+GO
+
+ALTER TABLE JoinRole
ADD FOREIGN KEY (RoleRefOrdinal, RoleRefRoleSequenceGUID) REFERENCES RoleRef (Ordinal, RoleSequenceGUID)
GO
-ALTER TABLE Reading
- ADD FOREIGN KEY (RoleSequenceGUID) REFERENCES RoleSequence (GUID)
+ALTER TABLE ObjectType
+ ADD FOREIGN KEY (ValueTypeUnitCode) REFERENCES Unit (UnitCode)
GO
-ALTER TABLE RoleDisplay
- ADD FOREIGN KEY (FactTypeShapeGUID) REFERENCES Shape (GUID)
+ALTER TABLE Role
+ ADD FOREIGN KEY (RoleName, RoleNameVocabularyLanguageCode, RoleNameVocabularyTopicName) REFERENCES Term (Name, VocabularyLanguageCode, VocabularyTopicName)
GO
-ALTER TABLE RoleRef
- ADD FOREIGN KEY (RoleSequenceGUID) REFERENCES RoleSequence (GUID)
+ALTER TABLE RoleDisplay
+ ADD FOREIGN KEY (FactTypeShapeGUID) REFERENCES Shape (GUID)
GO
View
34 examples/norma/ExampleModels.csproj
@@ -629,23 +629,6 @@
<ORMGenerator>DDILtoSQLServer</ORMGenerator>
</None>
</ItemGroup>
- <ItemGroup Condition="Exists('MetamodelNext.orm')">
- <None Include="MetamodelNext.DCIL.xml">
- <AutoGen>True</AutoGen>
- <DependentUpon>MetamodelNext.orm</DependentUpon>
- <ORMGenerator>ConceptualDBtoDCL</ORMGenerator>
- </None>
- <None Include="MetamodelNext.DDIL.xml">
- <AutoGen>True</AutoGen>
- <DependentUpon>MetamodelNext.orm</DependentUpon>
- <ORMGenerator>DCILtoDDIL</ORMGenerator>
- </None>
- <None Include="MetamodelNext.SQLServer.sql">
- <AutoGen>True</AutoGen>
- <DependentUpon>MetamodelNext.orm</DependentUpon>
- <ORMGenerator>DDILtoSQLServer</ORMGenerator>
- </None>
- </ItemGroup>
<ItemGroup Condition="Exists('RedundantDependency.orm')">
<None Include="RedundantDependency.DCIL.xml">
<AutoGen>True</AutoGen>
@@ -801,6 +784,23 @@
<ORMGenerator>DDILtoSQLServer</ORMGenerator>
</None>
</ItemGroup>
+ <ItemGroup Condition="Exists('MetamodelNext.orm')">
+ <None Include="MetamodelNext.DCIL.xml">
+ <AutoGen>True</AutoGen>
+ <DependentUpon>MetamodelNext.orm</DependentUpon>
+ <ORMGenerator>ConceptualDBtoDCL</ORMGenerator>
+ </None>
+ <None Include="MetamodelNext.DDIL.xml">
+ <AutoGen>True</AutoGen>
+ <DependentUpon>MetamodelNext.orm</DependentUpon>
+ <ORMGenerator>DCILtoDDIL</ORMGenerator>
+ </None>
+ <None Include="MetamodelNext.SQLServer.sql">
+ <AutoGen>True</AutoGen>
+ <DependentUpon>MetamodelNext.orm</DependentUpon>
+ <ORMGenerator>DDILtoSQLServer</ORMGenerator>
+ </None>
+ </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
View
6 examples/norma/ExampleModels.sln
@@ -7,6 +7,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Experimental", "..\..\adhoc
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImplicitJoins", "..\..\joins\norma\ImplicitJoins.csproj", "{88C3528A-D795-4C0E-835A-F8E4EEFB55DB}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Metamodels", "..\..\Metamodels\norma\Metamodels.csproj", "{60C452B1-77E5-4019-BB59-62AD0F9839A9}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -25,6 +27,10 @@ Global
{88C3528A-D795-4C0E-835A-F8E4EEFB55DB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{88C3528A-D795-4C0E-835A-F8E4EEFB55DB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{88C3528A-D795-4C0E-835A-F8E4EEFB55DB}.Release|Any CPU.Build.0 = Release|Any CPU
+ {60C452B1-77E5-4019-BB59-62AD0F9839A9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {60C452B1-77E5-4019-BB59-62AD0F9839A9}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {60C452B1-77E5-4019-BB59-62AD0F9839A9}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {60C452B1-77E5-4019-BB59-62AD0F9839A9}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
View
3,693 examples/norma/MetamodelNext.orm
2,613 additions, 1,080 deletions not shown
View
16 examples/norma/MultipleSubtyping.orm
@@ -317,28 +317,28 @@
</orm:ORMModel>
<ormDiagram:ORMDiagram id="_DD8966BA-EE5D-4668-830E-552F58880C34" IsCompleteView="false" Name="MultipleSubtyping" BaseFontName="Tahoma" BaseFontSize="0.0972222238779068">
<ormDiagram:Shapes>
- <ormDiagram:ObjectTypeShape id="_E4E7DCD1-8F09-48B2-9E0D-8EDE7AE3B443" IsExpanded="true" AbsoluteBounds="2.8854167461395264, 1.3125, 0.56669368863105773, 0.35900605320930479">
+ <ormDiagram:ObjectTypeShape id="_E4E7DCD1-8F09-48B2-9E0D-8EDE7AE3B443" IsExpanded="true" AbsoluteBounds="2.1250001192092896, 0.5, 0.56669368863105773, 0.35900605320930479">
<ormDiagram:Subject ref="_6F6CA13D-E9AB-42E2-BA0A-7562D6CCCBD2" />
</ormDiagram:ObjectTypeShape>
- <ormDiagram:ObjectTypeShape id="_C5684E4E-440D-40D4-827E-77C58F9B5111" IsExpanded="true" AbsoluteBounds="1.2604166269302368, 2.6041665871938076, 0.40685617446899419, 0.22950302660465241">
+ <ormDiagram:ObjectTypeShape id="_C5684E4E-440D-40D4-827E-77C58F9B5111" IsExpanded="true" AbsoluteBounds="0.5, 1.7916665871938076, 0.40685617446899419, 0.22950302660465241">
<ormDiagram:Subject ref="_D872D3E1-BEA6-4827-9868-8FC0940AD001" />
</ormDiagram:ObjectTypeShape>
- <ormDiagram:ObjectTypeShape id="_C88B3744-3B08-4EBD-AC25-FB68070FD741" IsExpanded="true" AbsoluteBounds="1.8958332935969033, 2.6041665871938076, 0.62256794691085815, 0.22950302660465241">
+ <ormDiagram:ObjectTypeShape id="_C88B3744-3B08-4EBD-AC25-FB68070FD741" IsExpanded="true" AbsoluteBounds="1.1354166666666665, 1.7916665871938076, 0.62256794691085815, 0.22950302660465241">
<ormDiagram:Subject ref="_5F841DFF-55B5-443C-94E3-A159AB2E701B" />
</ormDiagram:ObjectTypeShape>
- <ormDiagram:ObjectTypeShape id="_74DBBB5C-42BC-43B9-80B7-2E8CCABC59AC" IsExpanded="true" AbsoluteBounds="2.7395832538604736, 2.6041665871938076, 0.4199583780765534, 0.22950302660465241">
+ <ormDiagram:ObjectTypeShape id="_74DBBB5C-42BC-43B9-80B7-2E8CCABC59AC" IsExpanded="true" AbsoluteBounds="1.9791666269302368, 1.7916665871938076, 0.4199583780765534, 0.22950302660465241">
<ormDiagram:Subject ref="_BACF801F-99F6-46B5-8712-E53F943D0D08" />
</ormDiagram:ObjectTypeShape>
- <ormDiagram:ExternalConstraintShape id="_101E905B-BF78-48C5-8A51-4E9D8098BB22" IsExpanded="true" AbsoluteBounds="2.6979166666666665, 2.1875, 0.16, 0.16">
+ <ormDiagram:ExternalConstraintShape id="_101E905B-BF78-48C5-8A51-4E9D8098BB22" IsExpanded="true" AbsoluteBounds="1.9375000397364297, 1.375, 0.16, 0.16">
<ormDiagram:Subject ref="_E8820A23-EB00-4825-A3E8-37289CD58990" />
</ormDiagram:ExternalConstraintShape>
- <ormDiagram:ObjectTypeShape id="_3C51BAF1-2E38-403A-A81A-F7831FB9D095" IsExpanded="true" AbsoluteBounds="3.9583332538604736, 2.6041665871938076, 0.39147531509399419, 0.22950302660465241">
+ <ormDiagram:ObjectTypeShape id="_3C51BAF1-2E38-403A-A81A-F7831FB9D095" IsExpanded="true" AbsoluteBounds="3.1979166269302368, 1.7916665871938076, 0.39147531509399419, 0.22950302660465241">
<ormDiagram:Subject ref="_1E38A26F-5B4E-4854-BB2A-E9CBE8CD9FD6" />
</ormDiagram:ObjectTypeShape>
- <ormDiagram:ObjectTypeShape id="_EFE763D7-3B25-44C5-A89E-27C3DA15E59B" IsExpanded="true" AbsoluteBounds="4.5625, 2.6041665871938071, 0.51518681168556224, 0.22950302660465241">
+ <ormDiagram:ObjectTypeShape id="_EFE763D7-3B25-44C5-A89E-27C3DA15E59B" IsExpanded="true" AbsoluteBounds="3.8020833730697632, 1.7916665871938071, 0.51518681168556224, 0.22950302660465241">
<ormDiagram:Subject ref="_517CADE9-0005-4BF6-9425-B9C87D583939" />
</ormDiagram:ObjectTypeShape>
- <ormDiagram:ExternalConstraintShape id="_A9B97EE4-D87C-41FE-99CB-EB43A6470A02" IsExpanded="true" AbsoluteBounds="3.9375001589457188, 2.2083333333333335, 0.16, 0.16">
+ <ormDiagram:ExternalConstraintShape id="_A9B97EE4-D87C-41FE-99CB-EB43A6470A02" IsExpanded="true" AbsoluteBounds="3.177083532015482, 1.3958333333333335, 0.16, 0.16">
<ormDiagram:Subject ref="_E41D1C80-FE7A-4855-A0E4-123785B2623F" />
</ormDiagram:ExternalConstraintShape>
</ormDiagram:Shapes>
View
12 lib/activefacts/generate/dm.rb
@@ -105,8 +105,16 @@ def generate(out = $>) #:nodoc:
supertype = (a = o.absorbed_via and a.role_type == :supertype) ? supertype = a.from : nil
if o.is_a?(ActiveFacts::Metamodel::EntityType)
if secondary_supertypes = o.supertypes-[supertype] and
- secondary_supertypes.size > 0
- raise "Cannot handle models that contain classes like #{o.name} with external supertypes (#{secondary_supertypes.map{|t|t.name}*", "})"
+ secondary_supertypes.size > 0 and
+ secondary_supertypes.detect do |sst|
+ sst_ref_facts = sst.preferred_identifier.role_sequence.all_role_ref.map{|rr| rr.role.fact_type}.uniq
+ non_identifying_inheritable_references =
+ sst.references_from.reject do |ref|
+ sst_ref_facts.include?(ref.fact_type)
+ end
+ non_identifying_inheritable_references.size > 0
+ end
+ raise "Cannot map classes like #{o.name} with roles inherited from external supertypes (#{secondary_supertypes.map{|t|t.name}*", "})"
end
pi = o.preferred_identifier
identifying_role_refs = pi.role_sequence.all_role_ref.sort_by{|role_ref| role_ref.ordinal}
View
209 lib/activefacts/generate/html/glossary.rb
@@ -0,0 +1,209 @@
+#
+# ActiveFacts Generators.
+#
+# Generate a glossary in HTML
+#
+# Copyright (c) 2009 Clifford Heath. Read the LICENSE file.
+#
+require 'activefacts/api'
+
+module ActiveFacts
+ module Generate #:nodoc:
+ class HTML #:nodoc:
+ class GLOSSARY #:nodoc:
+ # Base class for generators of object-oriented class libraries for an ActiveFacts vocabulary.
+ def initialize(vocabulary, *options)
+ @vocabulary = vocabulary
+ @vocabulary = @vocabulary.Vocabulary.values[0] if ActiveFacts::API::Constellation === @vocabulary
+ options.each{|option| set_option(option) }
+ end
+
+ def set_option(option)
+ end
+
+ def puts(*a)
+ @out.puts *a
+ end
+
+ def print(*a)
+ @out.print *a
+ end
+
+ def generate(out = $>)
+ @out = out
+ vocabulary_start
+
+ object_types_dump()
+
+ vocabulary_end
+ end
+
+ def vocabulary_start
+ puts "<link rel='stylesheet' href='css/orm2.css' media='screen' type='text/css'/>"
+ puts "<h1>#{@vocabulary.name}</h1>"
+ puts "<dl>"
+ end
+
+ def vocabulary_end
+ puts "</dl>"
+ end
+
+ def object_types_dump
+ @vocabulary.
+ all_object_type.
+ sort_by{|o| o.name.gsub(/ /,'').downcase}.
+ each do |o|
+ case o
+ when ActiveFacts::Metamodel::TypeInheritance
+ nil
+ when ActiveFacts::Metamodel::ValueType
+ value_type_dump(o)
+ else
+ if o.fact_type
+ objectified_fact_type_dump(o)
+ else
+ entity_type_dump(o)
+ end
+ end
+ end
+ end
+
+ def element(text, attrs, tag = 'span')
+ "<#{tag}#{attrs.empty? ? '' : attrs.map{|k,v| " #{k}='#{v}'"}*''}>#{text}</#{tag}>"
+ end
+
+ # A definition of a term
+ def termdef(name)
+ element(name, {:name => name, :class => 'object_type'}, 'a')
+ end
+
+ # A reference to a defined term (excluding role adjectives)
+ def termref(name, role_name = nil)
+ role_name ||= name
+ element(role_name, {:href=>'#'+name, :class=>:object_type}, 'a')
+ end
+
+ # Text that should appear as part of a term (including role adjectives)
+ def term(name)
+ element(name, :class=>:object_type)
+ end
+
+ def value_type_dump(o)
+ return if o.all_role.size == 0 # Skip value types that are only used as supertypes
+ puts " <dt>" +
+ "Value Type: #{termdef(o.name)}" +
+ (o.supertype ? " (written as #{termref(o.supertype.name)})" : "") +
+ "</dt>"
+
+ puts " <dd>"
+ relevant_facts_and_constraints(o)
+ puts " </dd>"
+ end
+
+ def relevant_facts_and_constraints(o)
+ puts(
+ o.
+ all_role.
+ map{|r| r.fact_type}.
+ uniq.
+ reject{|ft| ft.is_a?(ActiveFacts::Metamodel::TypeInheritance) || ft.is_a?(ActiveFacts::Metamodel::ImplicitFactType) }.
+ map { |ft| " #{fact_type_with_constraints(ft, o)}</br>" }.
+ sort * "\n"
+ )
+ end
+
+ def role_ref rr, freq_con, l_adj, name, t_adj, role_name_def, literal
+ term_parts = [l_adj, termref(name), t_adj].compact
+ [
+ freq_con ? element(freq_con, :class=>:keyword) : nil,
+ term_parts.size > 1 ? term([l_adj, termref(name), t_adj].compact*' ') : term_parts[0],
+ role_name_def,
+ literal
+ ]
+ end
+
+ def expand_reading(r)
+ element(
+ r.expand do |*a|
+ role_ref(*a)
+ end,
+ {:class => 'copula'}
+ )
+ end
+
+ def fact_type(ft, wrt = nil)
+ role = ft.all_role.detect{|r| r.object_type == wrt}
+ preferred_reading = ft.reading_preferably_starting_with_role(role)
+ alternate_readings = ft.all_reading.reject{|r| r == preferred_reading}
+ expand_reading(preferred_reading) +
+ (alternate_readings.size > 0 ?
+ ' (alternatively, ' +
+ alternate_readings.map { |r| expand_reading(r)}*', ' +
+ ')' : '')
+ end
+
+ def fact_type_with_constraints(ft, wrt = nil)
+ fact_type(ft, wrt) +
+ "<br/>\n<ul>\n" +
+ fact_type_constraints(ft) +
+ "</ul>"
+ end
+
+ def fact_type_constraints(ft)
+ ft.internal_presence_constraints.map do |pc|
+ residual_role = ft.all_role.detect{|r| !pc.role_sequence.all_role_ref.detect{|rr| rr.role == r}}
+ next nil unless residual_role
+ reading = ft.all_reading.detect{|reading|
+ reading.role_sequence.all_role_ref_in_order[reading.role_numbers[-1]].role == residual_role
+ }
+ next nil unless reading
+ element(
+ reading.expand_with_final_presence_constraint { |*a| role_ref(*a) },
+ {:class => 'copula'}
+ )+"<br/>\n"
+ end.compact*''
+ end
+
+ def objectified_fact_type_dump(o)
+ puts " <dt>" +
+ "Entity Type: #{termdef(o.name)}" +
+ " (objectification of #{fact_type(o.fact_type)})" +
+ "</dt>"
+ # REVISIT: Handle separate identification
+
+ puts " <dd>"
+ puts fact_type_constraints(o.fact_type)
+ o.fact_type.all_role_in_order.each do |r|
+ n = r.object_type.name
+ puts "#{termref(o.name)} involves exactly one #{termref(r.role_name || n, n)}<br/>"
+ end
+ relevant_facts_and_constraints(o)
+ puts " </dd>"
+ end
+
+ def entity_type_dump(o)
+ pi = o.preferred_identifier
+ supers = o.supertypes
+ if (supers.size > 0) # Ignore identification by a supertype:
+ pi = nil if pi && pi.role_sequence.all_role_ref.detect{|rr| rr.role.fact_type.is_a?(ActiveFacts::Metamodel::TypeInheritance) }
+ end
+
+ puts " <dt>" +
+ "Entity Type: #{termdef(o.name)}" +
+ " (" +
+ [
+ (supers.size > 0 ? "Subtype of #{supers.map{|s| s.name}*', '})" : nil),
+ (pi ? "identified by "+pi.role_sequence.describe : nil)
+ ].compact*', '
+ ")" +
+ "</dt>"
+
+ puts " <dd>"
+ relevant_facts_and_constraints(o)
+ puts " </dd>"
+ end
+
+ end
+ end
+ end
+end
View
6 lib/activefacts/persistence/tables.rb
@@ -237,6 +237,12 @@ def decide_tables #:nodoc:
}
debug :absorption, "#{object_type.name} has #{non_identifying_refs_from.size} non-identifying functional roles"
+ # If all non-identifying functional roles are one-to-ones that can be flipped, do that:
+ if non_identifying_refs_from.all? { |ref| ref.role_type == :one_one && (ref.to.is_table || ref.to.tentative) }
+ non_identifying_refs_from.each { |ref| ref.flip }
+ non_identifying_refs_from = []
+ end
+
if object_type.references_to.size > 1 and
non_identifying_refs_from.size > 0
debug :absorption, "#{object_type.name} has non-identifying functional dependencies so 3NF requires it be a table"
View
18 lib/activefacts/support.rb
@@ -150,3 +150,21 @@ def elide_repeated_subsequences &compare_block
self
end
end
+
+# Load the ruby debugger before everything else, if requested
+if debug :debug
+ begin
+ require 'ruby-debug'
+ Debugger.start # (:post_mortem => true) # Some Ruby versions crash on post-mortem debugging
+ rescue LoadError
+ # Ok, no debugger, tough luck.
+ end
+
+ if debug :trap
+ trap('SIGINT') do
+ puts "Stopped at:\n\t"+caller*"\n\t"
+ debugger
+ true
+ end
+ end
+end
View
70 lib/activefacts/vocabulary/extensions.rb
@@ -183,7 +183,7 @@ def subtypes_transitive
class EntityType
def preferred_identifier
- #return @preferred_identifier if @preferred_identifier
+ return @preferred_identifier if @preferred_identifier
if fact_type
# For a nested fact type, the PI is a unique constraint over N or N-1 roles
@@ -394,39 +394,42 @@ def expand(frequency_constraints = [], define_role_names = nil, literals = [], &
(0...role_refs.size).each{|i|
role_ref = role_refs[i]
role = role_ref.role
- la = "#{role_ref.leading_adjective}".sub(/(.\b|.\Z)/, '\1-').sub(/- /,'- ')
- la = nil if la == ""
+ l_adj = "#{role_ref.leading_adjective}".sub(/(.\b|.\Z)/, '\1-').sub(/- /,'- ')
+ l_adj = nil if l_adj == ""
# Double the space to compensate for space removed below
- ta = "#{role_ref.trailing_adjective}".sub(/(\b.|\A.)/, '-\1').sub(/ -/,' -')
- ta = nil if ta == ""
+ t_adj = "#{role_ref.trailing_adjective}".sub(/(\b.|\A.)/, '-\1').sub(/ -/,' -')
+ t_adj = nil if t_adj == ""
- expanded.gsub!(/\{#{i}\}/) {
+ expanded.gsub!(/\{#{i}\}/) do
role_ref = role_refs[i]
player = role_ref.role.object_type
role_name = role.role_name
role_name = nil if role_name == ""
if role_name && define_role_names == false
- la = ta = nil # When using role names, don't add adjectives
+ l_adj = t_adj = nil # When using role names, don't add adjectives
end
- fc = frequency_constraints[i]
- fc = fc.frequency if fc && fc.is_a?(ActiveFacts::Metamodel::PresenceConstraint)
- if fc.is_a?(Array)
- fc, player_name = *fc
+ freq_con = frequency_constraints[i]
+ freq_con = freq_con.frequency if freq_con && freq_con.is_a?(ActiveFacts::Metamodel::PresenceConstraint)
+ if freq_con.is_a?(Array)
+ freq_con, player_name = *freq_con
else
player_name = player.name
end
literal = literals[i]
- [
- fc ? fc : nil,
- la,
+ words = [
+ freq_con ? freq_con : nil,
+ l_adj,
define_role_names == false && role_name ? role_name : player_name,
- ta,
+ t_adj,
define_role_names && role_name && player.name != role_name ? "(as #{role_name})" : nil,
# Can't have both a literal and a value constraint, but we don't enforce that here:
literal ? literal : nil
- ].compact*" " +
- (subscript_block ? subscript_block.call(role_ref) : "")
- }
+ ]
+ if (subscript_block)
+ words = subscript_block.call(role_ref, *words)
+ end
+ words.compact*" "
+ end
}
expanded.gsub!(/ ?- ?/, '-') # Remove single spaces around adjectives
#debug "Expanded '#{expanded}' using #{frequency_constraints.inspect}"
@@ -445,6 +448,37 @@ def words_and_role_refs
end
end
end
+
+ # Return the array of the numbers of the RoleRefs inserted into this reading from the role_sequence
+ def role_numbers
+ text.scan(/\{(\d)\}/).flatten.map{|m| Integer(m) }
+ end
+
+ def expand_with_final_presence_constraint &b
+ # Arrange the roles in order they occur in this reading:
+ role_refs = role_sequence.all_role_ref_in_order
+ role_numbers = text.scan(/\{(\d)\}/).flatten.map{|m| Integer(m) }
+ roles = role_numbers.map{|m| role_refs[m].role }
+ fact_constraints = fact_type.internal_presence_constraints
+
+ # Find the constraints that constrain frequency over each role we can verbalise:
+ frequency_constraints = []
+ roles.each do |role|
+ frequency_constraints <<
+ if (role == roles.last) # On the last role of the reading, emit any presence constraint
+ constraint = fact_constraints.
+ detect do |c| # Find a UC that spans all other Roles
+ c.is_a?(ActiveFacts::Metamodel::PresenceConstraint) &&
+ roles-c.role_sequence.all_role_ref.map(&:role) == [role]
+ end
+ constraint && constraint.frequency
+ else
+ nil
+ end
+ end
+
+ expand(frequency_constraints) { |*a| b && b.call(*a) }
+ end
end
class ValueConstraint
View
6 lib/activefacts/vocabulary/verbaliser.rb
@@ -305,8 +305,10 @@ def create_subscripts(matching = :normal)
# these expansions include frequency constraints, role names and value constraints as passed-in,
# and also define adjectives by using the hyphenated form (on at least the first occurrence).
def expand_reading(reading, frequency_constraints = [], define_role_names = nil, value_constraints = [], &subscript_block)
- reading.expand(frequency_constraints, define_role_names, value_constraints) do |role_ref|
- (!(role_ref.role.role_name and define_role_names != nil) and p = player(role_ref) and p.subscript) ? "(#{p.subscript})" : ""
+ reading.expand(frequency_constraints, define_role_names, value_constraints) do |role_ref, *parts|
+ parts + [
+ (!(role_ref.role.role_name and define_role_names != nil) and p = player(role_ref) and p.subscript) ? "(#{p.subscript})" : nil
+ ]
end
end
View
1  spec/cql/fact_type_matching_spec.rb
@@ -2,6 +2,7 @@
# ActiveFacts CQL Fact Type matching tests
# Copyright (c) 2009 Clifford Heath. Read the LICENSE file.
#
+$: << Dir::getwd
require 'rspec/expectations'
View
1  spec/cql/role_matching_spec.rb
@@ -2,6 +2,7 @@
# ActiveFacts CQL Fact Type matching tests
# Copyright (c) 2009 Clifford Heath. Read the LICENSE file.
#
+$: << Dir::getwd
require 'rspec/expectations'
View
1  spec/cql_dm_spec.rb
@@ -38,7 +38,6 @@
mapping_failures = { # These models can't be mapped to DM
'OrienteeringER' => 'Invalid CQL results in unmappable model',
'Insurance' => 'Cannot handle models that contain classes like Vehicle Incident with external supertypes (Incident)',
- 'MetamodelNext' => 'Cannot handle models that contain classes like Constraint with external supertypes (ObjectType)',
'MultiInheritance' => 'Cannot handle models that contain classes like Australian Employee with external supertypes (Australian)',
'SeparateSubtype' => 'Cannot handle models that contain classes like Vehicle Incident with external supertypes (Incident)',
'ServiceDirector' => 'Cannot handle models that contain classes like Client with external supertypes (Company)',

No commit comments for this range

Something went wrong with that request. Please try again.