/* SQL DDL: Create an implementation of the model using the SQL Data Definition Language */ /* Note: Comments such as this may not be supported by your system and may have to be removed */ /* You may want to change some field types to improve the implementation on your DBMS. */ /* Data type 'National Character' etc. indicates Unicode text. */ /* PostgreSQL: You should create the entire database as Unicode! */ /* PostgreSQL: For Postgres you should create the entire database as Unicode! The 'National' has been removed from the SQL code */ /* PostgreSQL: the data type CHARACTER VARYING has been replaced with VARCHAR */ /* PostgreSQL: the data type DATETIME has been replaced with TIMESTAMP */ /* PostgreSQL: Table and field names have been quoted (= "Fieldname") to allow case-sensitivity */ /* PostgreSQL: the default values for boolean fields have been replaced with 'true' and 'false' */ /*=== Table: "DD_CHAR" ===*/ /* Character table. */ /* CID: Character ID number. Also currently defines the order of characters. This ID may change over time, please compare the separate CharID. */ /* CharName: Short name of character. */ /* Unit: For numeric characters: an optional measurement unit like 'mm'. Only true units here, text like 'wide' belongs to CharWording2! */ /* Notes: Character notes. */ /* Type: Type of character: Text, Ordered/unordered multistate, Integer/Real numeric. */ /* Mandatory: Is the scoring of this character mandatory (required) in each item? */ /* MultiStateType: Are multiple states allowed and how are they interpreted? */ /* Reliability: Reliability (or weight) of character for identification, 1-10, default is 5. */ /* Availability: Availability (or accessibility) of character for identification, 1-10, default is 5. This is an extension to the Delta standard. */ /* Fuzziness: For identification: Unless a range is explicitly present, used to form a range around the mean (RN/IN) or state (OM). */ /* FuzzinessIsPercent: Interpret 'Fuzziness' as 'percent' rather than 'absolute value' (e.g. Fuzziness=10 -> range=mean +/- 10%, instead of +/- 10 absolute). */ /* KeyStates: For use in a key: combine multistate char, into new combinations or define ranges for numeric char. */ /* CharHeading: A heading defined in the headings definition, inserted in char. def. output in front of the current character. */ /* HeadingLink: A heading defined in the headings definition, inserted in natural language descriptions in front of descriptions using this character. */ /* CharWording: Natural language descript.: Wording to be used instead of CharName. */ /* CharWording2: Natural language descript.: Wording to be used AFTER states or values + unit, e.g. 'wide' for 'leaves 3-5 mm wide'. */ /* UnitIsPrefix: True if unit is to be placed in front of value, e.g. to output "pH 7.2". */ /* FormatString: Default formatting for all states (compare StateFormatString). Esp. for numeric values (number of decimal places etc.). Standard Basic formatting string like "#.0". */ /* ParagraphLink: Nat.language descript.: Define char. linked into a single paragraph. A new paragraph starts if group ID changes. */ /* SentenceLink: Nat.language descript.: Define char. linked into a single sentence. A new sentence starts if group ID changes or whenever Null. */ /* CommaLink: Nat.language descript.: Define characters linked into a comma-enumeration ('sub-sentence'). A new group starts starts if group ID changes or whenever Null. */ /* SpecialLink: Nat.language descript.: Define characters that are linked by special means (as defined in SpecialElement). */ /* SpecialElement: Nat.language descript.: SpecialLink is rendered using this ReportElement (concatenation: char. separated only by blank, multi-char. formula/equation or table definition) [Denormalized n:m relation b/w Char.SpecialLink & ReportElement.ReportElement] */ /* UseComma2: Nat.language descript.: Use alternative comma separator between states of this character (e.g. for Chinese). */ /* OmitFinalComma: Nat.language descript.: The final comma between character states is omitted ('1,2 and 3' instead of '1,2, and 3'). */ /* OmitValues: Natural language descript.: Omit lower ('-') or upper ('+') part of numeric character ranges. */ /* Emphasize: Nat.language descript.: Emphasize (italic or bold print) this character in all items. */ /* OmitPeriod: Nat.language descript.: Omit the end delimiter (usually the period for a sentence, DELTA: 'OMIT PERIOD FOR CHAR'). */ /* NumStates: Calculated field: Number of states other than special states U,V,- present in this character, default is 2. Calculated automatically, do not edit! */ /* CharID: Immutable unique number identifying a character (candidate key). Not exported to DELTA! Semantics are similar to CID, which, however, is exported to DELTA and requires renumbering after character deletions. */ CREATE TABLE "DD_CHAR" ( "CID" int2 NOT NULL PRIMARY KEY, "CharName" varchar(255) NOT NULL UNIQUE, "Unit" varchar(255) NULL, "Notes" text NULL, "Type" varchar(2) NOT NULL DEFAULT 'UM', "Mandatory" bool NOT NULL DEFAULT 'false', "MultiStateType" int2 NOT NULL DEFAULT 1, "Reliability" float4 NOT NULL DEFAULT 5, "Availability" float4 NOT NULL DEFAULT 5, "Fuzziness" float4 NOT NULL DEFAULT 0, "FuzzinessIsPercent" bool NOT NULL DEFAULT 'false', "KeyStates" varchar(255) NULL, "CharHeading" int2 NULL, "HeadingLink" int2 NULL, "CharWording" varchar(255) NULL, "CharWording2" varchar(255) NULL, "UnitIsPrefix" bool NULL, "FormatString" varchar(255) NULL, "ParagraphLink" int4 NULL DEFAULT 1, "SentenceLink" int4 NULL, "CommaLink" int4 NULL, "SpecialLink" int4 NULL, "SpecialElement" int4 NULL, "UseComma2" bool NULL, "OmitFinalComma" bool NOT NULL DEFAULT 'false', "OmitValues" varchar(1) NULL, "Emphasize" bool NULL DEFAULT 'false', "OmitPeriod" bool NULL DEFAULT 'false', "NumStates" int2 NOT NULL DEFAULT 2, "CharID" SERIAL NOT NULL UNIQUE ); /*=== Table: "DD_CHAR_Translation" ===*/ /* Character table, translations into multiple languages. */ /* CharID: Character ID (unchanging version). */ /* Language: Language of the translation. */ /* CharName: Short label for character; in the current Language. */ /* CharWording: Natural language descript.: Wording to be used instead of CharName; in the current Language. */ /* CharWording2: Natural language descript.: Wording to be used AFTER states or values + unit, e.g. 'wide' for 'leaves 3-5 mm wide'; in the current Language. */ /* Unit: For numeric characters: an optional measurement unit like 'mm'. Only true units here, text like 'wide' belongs to CharWording2! */ /* UnitIsPrefix: True if unit is to be placed in front of value, e.g. to output "pH 7.2". */ /* Notes: Character Notes (for DELTA data this could be an extensive definition of the character). */ /* FormatString: Default formatting for all states (compare StateFormatString). Esp. for numeric values (number of decimal places etc.). Standard Basic formatting string like "#.0". */ CREATE TABLE "DD_CHAR_Translation" ( "CharID" int4 NOT NULL, "Language" varchar(2) NOT NULL, "CharName" varchar(255) NOT NULL, "CharWording" varchar(255) NULL, "CharWording2" varchar(255) NULL, "Unit" varchar(50) NULL, "UnitIsPrefix" bool NULL, "Notes" text NULL, "FormatString" varchar(255) NULL, PRIMARY KEY ("CharID","Language") ); /*=== Table: "DD_CHAR_Heading" ===*/ /* Character heading/Identification/HeadingLink table. */ /* HID: Character heading ID; determines sequence of headings when used in identification; change number to change that sequence! */ /* HeadingName: Heading name, used for CharHeadings and Named character groups (identification). */ /* HeadingWording: Optional wording; preferred over HeadingName if headings for natural language descriptions are defined through the HeadingLink mechanism . */ /* Notes: Internal notes (not exported to Delta format). */ /* AutoGroup: Empty for user defined headings; else special code which is recognized during identification or a SQL query returning a set of character IDs. (HeadingName of predefined AutoGroups may be changed!). */ /* ParentHeadingID: A hierarchy of headings can be defined in DeltaAccess by adding the higher hierarchy here. However, this is not supported by DELTA and can not be exported. */ /* HeadingID: Immutable unique number identifying a heading (candidate key). */ CREATE TABLE "DD_CHAR_Heading" ( "HID" int2 NOT NULL PRIMARY KEY, "HeadingName" varchar(255) NOT NULL UNIQUE, "HeadingWording" varchar(255) NULL, "Notes" text NULL, "AutoGroup" varchar(255) NULL, "ParentHeadingID" int4 NULL, "HeadingID" SERIAL NOT NULL UNIQUE ); /*=== Table: "DD_CHAR_Heading_Translation" ===*/ /* Character headings, translations into multiple languages. */ /* HeadingID: Character heading ID. */ /* Language: Language of the translation. */ /* HeadingName: Heading name, used for CharHeadings and Named character groups (identification). */ /* HeadingWording: Optional wording; preferred over HeadingName if headings for natural language descriptions are defined through the HeadingLink mechanism . */ /* Notes: Notes on translation. */ CREATE TABLE "DD_CHAR_Heading_Translation" ( "HeadingID" int4 NOT NULL, "Language" varchar(2) NOT NULL, "HeadingName" varchar(255) NOT NULL UNIQUE, "HeadingWording" varchar(255) NULL, "Notes" text NULL, PRIMARY KEY ("HeadingID","Language") ); /*=== Table: "DD_CHAR_Heading_Link" ===*/ /* Character groups for Identification, Linking. */ /* HID: Character heading ID to be linked. */ /* CID: Character ID to which the identification heading is applicable. */ CREATE TABLE "DD_CHAR_Heading_Link" ( "HID" int2 NOT NULL, "CID" int2 NOT NULL, PRIMARY KEY ("HID","CID") ); /*=== Table: "DD_CS" ===*/ /* Character states for each character. */ /* CID: Character ID. */ /* CS: Character state code. Usually pos. integer number or special codes for variable/unknown and for statistics (mean etc.). */ /* CharStateName: Name or description of character state. */ /* Notes: Character state notes. */ /* StateWording: Wording to be used instead of CharStateName for natural language descriptions output. */ /* StateFormatString: State specific formatting, overriding FormatString defined in the character definition. Standard Basic formatting string like "#.0". */ /* Implicit: Mark this state as a default which is automatically set. */ /* UseEdit: (Not yet implemented!) Use this state during entering or updating of item descriptions. */ /* UseIdentify: (Not yet implemented!) Use this state during interactive identification. */ /* UseDescr: (Not yet implemented!) Use this state for natural language item descriptions. */ /* UsePhylo: (Not yet implemented!) Use this state for phylogenetic analysis. */ /* UseOther: (Not yet implemented!) Use this to define a character state set for user-defined purposes. */ /* MinValue: Numeric characters only: The lowest value of X in item description to be mapped to this state (inclusive). */ /* MaxValue: Numeric characters only: The highest value of X in item description to be mapped to this state (inclusive). */ /* StateID: Immutable unique number identifying a character state independently of the character. Not exported to DELTA! Preferred key for any external references to states not protected by cascaded referential updates. (Candidate key). */ CREATE TABLE "DD_CS" ( "CID" int2 NOT NULL, "CS" varchar(16) NOT NULL, "CharStateName" varchar(255) NOT NULL UNIQUE, "Notes" text NULL, "StateWording" varchar(255) NULL, "StateFormatString" varchar(255) NULL, "Implicit" bool NOT NULL DEFAULT 'false', "UseEdit" bool NULL DEFAULT 'true', "UseIdentify" bool NULL DEFAULT 'false', "UseDescr" bool NULL DEFAULT 'false', "UsePhylo" bool NULL DEFAULT 'false', "UseOther" bool NULL DEFAULT 'false', "MinValue" float8 NOT NULL DEFAULT -1E+308, "MaxValue" float8 NOT NULL DEFAULT 1E+308, "StateID" SERIAL NOT NULL UNIQUE, PRIMARY KEY ("CID","CS") ); /*=== Table: "DD_CS_Translation" ===*/ /* Character states, translations into multiple languages. */ /* StateID: State ID (foreign key). */ /* Language: Language of the translation. */ /* CharStateName: Name or description of character state. */ /* Notes: Notes on translation. */ /* StateWording: Wording to be used instead of CharStateName for natural language descriptions output. */ /* StateFormatString: State specific formatting, overriding FormatString defined in the character definition. Standard Basic formatting string like "#.0". */ CREATE TABLE "DD_CS_Translation" ( "StateID" int4 NOT NULL DEFAULT 0, "Language" varchar(2) NOT NULL, "CharStateName" varchar(255) NOT NULL, "Notes" text NULL, "StateWording" varchar(255) NULL, "StateFormatString" varchar(255) NULL, PRIMARY KEY ("StateID","Language") ); /*=== Table: "DD_MOD" ===*/ /* Modifier wordings for categorical or numerical data. */ /* Usage: Type of characters for which the modifier is applicable, e.g. GENERAL. COLORS, FREQuency of occurrence. */ /* Modifier: Modifier wording for categorical or numerical data, e.g. "mostly", "usually", "rarely". */ /* Reliability: Influence of modifier on data coded through categorical/numerical char. states. More (>5) or less reliable (<5); 5 is default. */ /* MisinterpretationMarker: If set to true, the state to which this modifier is added is marked as being present only by misinterpretation of structure (phyllocladium as leaf) or state (rough spore surface as smooth). */ /* Postfix: Checked = output after the character state wording, unchecked = in front of it. */ /* UseBlank: Checked = blank is added between the modifier wording and the item data text, else modifier added compress. */ /* Operator: >0 = Override operator, the normal operator between states is omitted when this modifier is encountered, e.g. to insert AND where normal operator would be OR. */ /* Notes: Internal notes. */ /* LowerFreq: The lower border of the frequency range, for freq. modifiers only. */ /* UpperFreq: The upper border of the frequency range, for freq. modifiers only. */ CREATE TABLE "DD_MOD" ( "Usage" varchar(255) NOT NULL, "Modifier" varchar(255) NOT NULL PRIMARY KEY, "Reliability" int2 NOT NULL DEFAULT 5, "MisinterpretationMarker" bool NOT NULL DEFAULT 'false', "Postfix" bool NOT NULL, "UseBlank" bool NOT NULL DEFAULT 'true', "Operator" int2 NOT NULL DEFAULT 0, "Notes" varchar(255) NULL, "LowerFreq" float4 NULL, "UpperFreq" float4 NULL ); /*=== Table: "DD_MOD_Translation" ===*/ /* Modifier wordings, translations into multiple languages. */ /* Modifier: Modifier wording. Foreign key linking to _MOD. In current language! */ /* Language: Language of the translation. */ /* ModifierTranslation: Translation of modifier wording. */ CREATE TABLE "DD_MOD_Translation" ( "Modifier" varchar(255) NOT NULL, "Language" varchar(2) NOT NULL, "ModifierTranslation" varchar(255) NOT NULL, PRIMARY KEY ("Modifier","Language") ); /*=== Table: "DD_MOD_Link" ===*/ /* Links between characters and modifiers. */ /* CID: Character ID to which the modifier is applicable. */ /* Modifier: Modifier wording for categorical or numerical data, e.g. "mostly", "usually", "rarely". */ CREATE TABLE "DD_MOD_Link" ( "CID" int2 NOT NULL, "Modifier" varchar(255) NOT NULL, PRIMARY KEY ("Modifier","CID") ); /*=== Table: "DD_DEP" ===*/ /* Dependent (= inapplicable) characters for each character state. */ /* CID: Controlling character ID. */ /* CS: Controlling character state. */ /* InapplicableCID: CID of dependent character, i.e. inapplicable for any item where current CID/CS combination is used. */ CREATE TABLE "DD_DEP" ( "CID" int2 NOT NULL, "CS" varchar(16) NOT NULL, "InapplicableCID" int2 NOT NULL, PRIMARY KEY ("CID","CS","InapplicableCID") ); /*=== Table: "DD_ITEM" ===*/ /* Item or taxon table. */ /* IID: Item ID. */ /* ItemName: Name or description of item (incl. taxon authors if necessary), link to taxonomic subsystem. */ /* ItemWording: Natural language descript.: Wording to be used instead of ItemName. */ /* Notes: Item notes. */ /* Abundance: Abundance, relative importance (or weight) of item, 1-10, default is 5. */ /* CollUnit: Unit code in specimen collection, link into collection subsystem. NOT DEFINED IN DELTA! */ /* LitRef: Literature reference (user-readable text form). NOT DEFINED IN DELTA! */ /* LitKey: Literature reference (numeric link into literature reference subsystem). NOT DEFINED IN DELTA! */ /* LitRefDetail: Reference detail, like page(s) of interest, specific figures, etc. */ /* ItemID: Immutable unique number identifying an item (candidate key). Not exported to DELTA! Semantics are similar to IID, which, however, is exported to DELTA and requires renumbering after deletions. */ CREATE TABLE "DD_ITEM" ( "IID" int4 NOT NULL PRIMARY KEY, "ItemName" varchar(255) NOT NULL, "ItemWording" varchar(255) NULL, "Notes" text NULL, "Abundance" float4 NOT NULL DEFAULT 5, "CollUnit" varchar(255) NULL, "LitRef" varchar(255) NULL, "LitKey" int4 NULL, "LitRefDetail" varchar(255) NULL, "ItemID" SERIAL NOT NULL UNIQUE ); /*=== Table: "DD_DESCR" ===*/ /* Data/descriptions for each item. */ /* IID: Item ID. */ /* CID: Character ID. */ /* Modifier: Modifier wording for categorical or numerical data, e.g. "mostly", "usually", "rarely". */ /* CS: Character state code. Usually pos. integer number or special codes for variable/unknown and for statistics (mean etc.). */ /* X: Numeric value, defined by CS. */ /* TXT: Text data. */ /* Notes: Notes and additional information, included in natural language item descriptions. */ /* SEQ: Sequence of character states for the item. */ CREATE TABLE "DD_DESCR" ( "IID" int4 NOT NULL, "CID" int2 NOT NULL, "Modifier" varchar(255) NULL, "CS" varchar(16) NOT NULL, "X" float8 NULL, "TXT" text NULL, "Notes" text NULL, "SEQ" int4 NULL, PRIMARY KEY ("CID","CS","IID") ); /*=== Table: "DD_RSC" ===*/ /* External resources stored as files or URL, e.g. illustrations for characters/items. */ /* ItemID: ID of associated item (optional). This refers to ItemID, not IID! */ /* CharID: ID of associated character (optional). This refers to CharID, not CID! */ /* StateID: ID of associated character state (optional). This refers to StateID, not CS! */ /* Resource: Filename of illustration (photo/drawing/graph) or other media resources (see ResourceDefaultPath/DefaultURL in table _PROPERTY for setting global paths). */ /* Caption: Caption for the resource, e.g. a text to display while showing an illustration or a video. */ /* Role: Roles the resource is intended for: I = Icon, S = Selector (displayed directly, e. g. to select a state), D = Definition (usually displayed only as thumbnail image or link for further information). */ /* ItemUsage: Usage of resource in the context of items (including natural language descriptions). Usage is especially relevant if both Item and CharIDs are defined, but resource is relevant for entire item (e.g. habit). */ /* CharUsage: Usage of resource in the context of items (especially character definition in print or web form). Usage is especially relevant if also Item or StateIDs are defined, but resource is relevant for entire character as well. */ /* Notes: Internal notes (perhaps also formatting commands for INTKEY). */ /* DisplayOrder: A positive number that can be used to define the sequence in which multiple resources are displayed. */ /* ResourceID: Media resource ID (any of item, char, state IDs may be missing). */ CREATE TABLE "DD_RSC" ( "ItemID" int4 NULL, "CharID" int4 NULL, "StateID" int4 NULL, "Resource" varchar(255) NOT NULL, "Caption" text NULL, "Role" varchar(1) NOT NULL DEFAULT 'S', "Language" varchar(2) NULL, "ItemUsage" varchar(1) NULL, "CharUsage" varchar(1) NULL, "Notes" text NULL, "DisplayOrder" int4 NOT NULL DEFAULT 0, "ResourceID" SERIAL NOT NULL PRIMARY KEY ); /*=== Table: "DD_PROPERTY" ===*/ /* General header information about the project. */ /* PropertyName: The name of the project property (do not change!). */ /* TextValue: Text information. Use Shift F2 to zoom into larger window! */ /* DateTimeValue: Date or time information, e.g. of last update. */ /* NumericValue: Numerical information, stored as real number. */ /* Language: Language of a property translation, e.g. for project title. */ CREATE TABLE "DD_PROPERTY" ( "PropertyName" varchar(255) NOT NULL PRIMARY KEY, "TextValue" text NULL, "DateTimeValue" timestamp NULL, "NumericValue" float8 NULL, "Language" varchar(2) NOT NULL DEFAULT 'en' ); /*=== Table: "DD_CurrentLanguage" ===*/ /* Definition of a single language as the current working language, determines which language is displayed in editing forms, reports, etc. The table supports only a single record! */ /* ID: ID (restricted to a single record, ID must always be 1!). */ /* Language: 2 character ISO language code. */ CREATE TABLE "DD_CurrentLanguage" ( "ID" int4 NOT NULL PRIMARY KEY DEFAULT 1, "Language" varchar(2) NOT NULL ); ALTER TABLE "DD_CHAR" ADD FOREIGN KEY ("CharHeading") REFERENCES "DD_CHAR_Heading" ("HID") ON UPDATE CASCADE; ALTER TABLE "DD_CHAR" ADD FOREIGN KEY ("HeadingLink") REFERENCES "DD_CHAR_Heading" ("HID") ON UPDATE CASCADE; ALTER TABLE "DD_CHAR_Translation" ADD FOREIGN KEY ("CharID") REFERENCES "DD_CHAR" ("CharID") ON UPDATE CASCADE ON DELETE CASCADE; ALTER TABLE "DD_CHAR_Heading" ADD FOREIGN KEY ("ParentHeadingID") REFERENCES "DD_CHAR_Heading" ("HeadingID") ON UPDATE CASCADE; ALTER TABLE "DD_CHAR_Heading_Translation" ADD FOREIGN KEY ("HeadingID") REFERENCES "DD_CHAR_Heading" ("HeadingID") ON UPDATE CASCADE ON DELETE CASCADE; ALTER TABLE "DD_CHAR_Heading_Link" ADD FOREIGN KEY ("HID") REFERENCES "DD_CHAR_Heading" ("HID") ON UPDATE CASCADE ON DELETE CASCADE; ALTER TABLE "DD_CHAR_Heading_Link" ADD FOREIGN KEY ("CID") REFERENCES "DD_CHAR" ("CID") ON UPDATE CASCADE ON DELETE CASCADE; ALTER TABLE "DD_CS" ADD FOREIGN KEY ("CID") REFERENCES "DD_CHAR" ("CID") ON UPDATE CASCADE ON DELETE CASCADE; ALTER TABLE "DD_CS_Translation" ADD FOREIGN KEY ("StateID") REFERENCES "DD_CS" ("StateID") ON UPDATE CASCADE ON DELETE CASCADE; ALTER TABLE "DD_MOD_Translation" ADD FOREIGN KEY ("Modifier") REFERENCES "DD_MOD" ("Modifier") ON UPDATE CASCADE ON DELETE CASCADE; ALTER TABLE "DD_MOD_Link" ADD FOREIGN KEY ("CID") REFERENCES "DD_CHAR" ("CID") ON UPDATE CASCADE ON DELETE CASCADE; ALTER TABLE "DD_MOD_Link" ADD FOREIGN KEY ("Modifier") REFERENCES "DD_MOD" ("Modifier") ON UPDATE CASCADE ON DELETE CASCADE; ALTER TABLE "DD_DEP" ADD FOREIGN KEY ("InapplicableCID") REFERENCES "DD_CHAR" ("CID") ON UPDATE CASCADE ON DELETE CASCADE; ALTER TABLE "DD_DEP" ADD FOREIGN KEY ("CID","CS") REFERENCES "DD_CS" ("CID","CS") ON UPDATE CASCADE ON DELETE CASCADE; ALTER TABLE "DD_DESCR" ADD FOREIGN KEY ("CID","CS") REFERENCES "DD_CS" ("CID","CS") ON UPDATE CASCADE ON DELETE CASCADE; ALTER TABLE "DD_DESCR" ADD FOREIGN KEY ("IID") REFERENCES "DD_ITEM" ("IID") ON UPDATE CASCADE ON DELETE CASCADE; ALTER TABLE "DD_DESCR" ADD FOREIGN KEY ("Modifier") REFERENCES "DD_MOD" ("Modifier") ON UPDATE CASCADE ON DELETE CASCADE; ALTER TABLE "DD_RSC" ADD FOREIGN KEY ("CharID") REFERENCES "DD_CHAR" ("CharID") ON UPDATE CASCADE ON DELETE CASCADE; ALTER TABLE "DD_RSC" ADD FOREIGN KEY ("StateID") REFERENCES "DD_CS" ("StateID") ON UPDATE CASCADE ON DELETE CASCADE; ALTER TABLE "DD_RSC" ADD FOREIGN KEY ("ItemID") REFERENCES "DD_ITEM" ("ItemID") ON UPDATE CASCADE ON DELETE CASCADE;