-- MycoBase SQLite Schema CREATE TABLE sys_users ( id INTEGER PRIMARY KEY AUTOINCREMENT, uuid TEXT NOT NULL DEFAULT (lower(hex(randomblob(4))) || '-' || lower(hex(randomblob(2))) || '-4' || substr(lower(hex(randomblob(2))),2) || '-' || substr('89ab',abs(random()) % 4 + 1, 1) || substr(lower(hex(randomblob(2))),2) || '-' || lower(hex(randomblob(6)))), username TEXT NOT NULL, email TEXT NOT NULL, display_name TEXT NOT NULL, password_hash TEXT, orcid TEXT, primary_institution_id INTEGER, is_active INTEGER NOT NULL DEFAULT 1, is_curator INTEGER NOT NULL DEFAULT 0, last_login_at TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY (primary_institution_id) REFERENCES people_institutions (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (username), UNIQUE (email), UNIQUE (uuid) ); CREATE INDEX ix_sys_users_is_active ON sys_users (is_active); CREATE INDEX ix_sys_users_is_curator ON sys_users (is_curator); CREATE TABLE sys_roles ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_sys_roles_is_active ON sys_roles (is_active); CREATE INDEX ix_sys_roles_label ON sys_roles (label); CREATE TABLE sys_user_roles ( user_id INTEGER NOT NULL, role_id INTEGER NOT NULL, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, PRIMARY KEY (user_id, role_id), FOREIGN KEY (user_id) REFERENCES sys_users (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (role_id) REFERENCES sys_roles (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_sys_user_roles_role_id ON sys_user_roles (role_id); CREATE TABLE sys_permissions ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_sys_permissions_is_active ON sys_permissions (is_active); CREATE INDEX ix_sys_permissions_label ON sys_permissions (label); CREATE TABLE sys_role_permissions ( role_id INTEGER NOT NULL, permission_id INTEGER NOT NULL, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, PRIMARY KEY (role_id, permission_id), FOREIGN KEY (role_id) REFERENCES sys_roles (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (permission_id) REFERENCES sys_permissions (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_sys_role_permissions_permission_id ON sys_role_permissions (permission_id); CREATE TABLE sys_api_keys ( id INTEGER PRIMARY KEY AUTOINCREMENT, user_id INTEGER NOT NULL, key_hash TEXT NOT NULL, key_prefix TEXT NOT NULL, scopes TEXT, expires_at TEXT, last_used_at TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY (user_id) REFERENCES sys_users (id) ON DELETE CASCADE ON UPDATE CASCADE, UNIQUE (key_hash) ); CREATE INDEX ix_sys_api_keys_user_id ON sys_api_keys (user_id); CREATE INDEX ix_sys_api_keys_key_prefix ON sys_api_keys (key_prefix); CREATE TABLE sys_settings ( id INTEGER PRIMARY KEY AUTOINCREMENT, scope TEXT NOT NULL, scope_id INTEGER, setting_key TEXT NOT NULL, setting_value TEXT, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, UNIQUE (scope, scope_id, setting_key) ); CREATE TABLE sys_audit_log ( id INTEGER PRIMARY KEY AUTOINCREMENT, user_id INTEGER, action TEXT NOT NULL, target_type TEXT, target_id INTEGER, ip_address TEXT, user_agent TEXT, payload TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY (user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_sys_audit_log_user_id ON sys_audit_log (user_id); CREATE INDEX ix_sys_audit_log_action ON sys_audit_log (action); CREATE INDEX ix_sys_audit_log_target_type_target_id ON sys_audit_log (target_type, target_id); CREATE INDEX ix_sys_audit_log_created_at ON sys_audit_log (created_at); CREATE TABLE sys_jobs ( id INTEGER PRIMARY KEY AUTOINCREMENT, job_type TEXT NOT NULL, status TEXT NOT NULL DEFAULT 'queued' CHECK (status IN ('queued','running','succeeded','failed','cancelled')), submitted_by_user_id INTEGER, submitted_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, started_at TEXT, finished_at TEXT, error_message TEXT, input_payload TEXT, result_payload TEXT, FOREIGN KEY (submitted_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_sys_jobs_status ON sys_jobs (status); CREATE INDEX ix_sys_jobs_job_type ON sys_jobs (job_type); CREATE INDEX ix_sys_jobs_submitted_at ON sys_jobs (submitted_at); CREATE TABLE geo_continents ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_geo_continents_is_active ON geo_continents (is_active); CREATE INDEX ix_geo_continents_label ON geo_continents (label); CREATE TABLE geo_countries ( id INTEGER PRIMARY KEY AUTOINCREMENT, iso_alpha2 TEXT NOT NULL, iso_alpha3 TEXT NOT NULL, iso_numeric INTEGER NOT NULL, name TEXT NOT NULL, official_name TEXT, continent_id INTEGER NOT NULL, capital TEXT, area_km2 REAL, centroid_lat REAL, centroid_lon REAL, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (continent_id) REFERENCES geo_continents (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (iso_alpha2), UNIQUE (iso_alpha3), UNIQUE (iso_numeric) ); CREATE INDEX ix_geo_countries_name ON geo_countries (name); CREATE TABLE geo_subdivisions ( id INTEGER PRIMARY KEY AUTOINCREMENT, country_id INTEGER NOT NULL, parent_subdivision_id INTEGER, level INTEGER NOT NULL, iso_3166_2 TEXT, name TEXT NOT NULL, local_name TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (parent_subdivision_id) REFERENCES geo_subdivisions (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_geo_subdivisions_country_id ON geo_subdivisions (country_id); CREATE INDEX ix_geo_subdivisions_parent_subdivision_id ON geo_subdivisions (parent_subdivision_id); CREATE INDEX ix_geo_subdivisions_level ON geo_subdivisions (level); CREATE TABLE geo_biomes ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, typical_temperature_c REAL, typical_precipitation_mm REAL, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_geo_biomes_is_active ON geo_biomes (is_active); CREATE INDEX ix_geo_biomes_label ON geo_biomes (label); CREATE TABLE geo_ecoregions ( id INTEGER PRIMARY KEY AUTOINCREMENT, biome_id INTEGER NOT NULL, realm_code TEXT, name TEXT NOT NULL, wwf_eco_code TEXT, description TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (biome_id) REFERENCES geo_biomes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (wwf_eco_code) ); CREATE INDEX ix_geo_ecoregions_realm_code ON geo_ecoregions (realm_code); CREATE TABLE geo_climate_zones ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_geo_climate_zones_is_active ON geo_climate_zones (is_active); CREATE INDEX ix_geo_climate_zones_label ON geo_climate_zones (label); CREATE TABLE geo_soil_orders ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_geo_soil_orders_is_active ON geo_soil_orders (is_active); CREATE INDEX ix_geo_soil_orders_label ON geo_soil_orders (label); CREATE TABLE geo_vegetation_types ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_geo_vegetation_types_is_active ON geo_vegetation_types (is_active); CREATE INDEX ix_geo_vegetation_types_label ON geo_vegetation_types (label); CREATE TABLE geo_localities ( id INTEGER PRIMARY KEY AUTOINCREMENT, uuid TEXT NOT NULL DEFAULT (lower(hex(randomblob(4))) || '-' || lower(hex(randomblob(2))) || '-4' || substr(lower(hex(randomblob(2))),2) || '-' || substr('89ab',abs(random()) % 4 + 1, 1) || substr(lower(hex(randomblob(2))),2) || '-' || lower(hex(randomblob(6)))), name TEXT NOT NULL, country_id INTEGER NOT NULL, subdivision_id INTEGER, ecoregion_id INTEGER, decimal_latitude REAL, decimal_longitude REAL, coordinate_uncertainty_m REAL, elevation_m REAL, depth_m REAL, georeference_method TEXT, georeference_source TEXT, georeferenced_by_user_id INTEGER, georeferenced_at TEXT, is_type_locality INTEGER NOT NULL DEFAULT 0, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (subdivision_id) REFERENCES geo_subdivisions (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (ecoregion_id) REFERENCES geo_ecoregions (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (georeferenced_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_geo_localities_country_id ON geo_localities (country_id); CREATE INDEX ix_geo_localities_ecoregion_id ON geo_localities (ecoregion_id); CREATE INDEX ix_geo_localities_decimal_latitude_decimal_longitude ON geo_localities (decimal_latitude, decimal_longitude); CREATE TABLE geo_locality_aliases ( id INTEGER PRIMARY KEY AUTOINCREMENT, locality_id INTEGER NOT NULL, alias TEXT NOT NULL, language_code TEXT, source TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (locality_id) REFERENCES geo_localities (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_geo_locality_aliases_locality_id ON geo_locality_aliases (locality_id); CREATE INDEX ix_geo_locality_aliases_alias ON geo_locality_aliases (alias); CREATE TABLE people_persons ( id INTEGER PRIMARY KEY AUTOINCREMENT, uuid TEXT NOT NULL DEFAULT (lower(hex(randomblob(4))) || '-' || lower(hex(randomblob(2))) || '-4' || substr(lower(hex(randomblob(2))),2) || '-' || substr('89ab',abs(random()) % 4 + 1, 1) || substr(lower(hex(randomblob(2))),2) || '-' || lower(hex(randomblob(6)))), family_name TEXT NOT NULL, given_names TEXT, standard_form TEXT, orcid TEXT, birth_year INTEGER, death_year INTEGER, nationality_country_id INTEGER, biography TEXT, is_collector INTEGER NOT NULL DEFAULT 0, is_taxonomist INTEGER NOT NULL DEFAULT 0, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (nationality_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (orcid) ); CREATE INDEX ix_people_persons_family_name ON people_persons (family_name); CREATE INDEX ix_people_persons_standard_form ON people_persons (standard_form); CREATE TABLE people_institutions ( id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL, acronym TEXT, ror_id TEXT, country_id INTEGER, website_url TEXT, address TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (ror_id) ); CREATE INDEX ix_people_institutions_acronym ON people_institutions (acronym); CREATE TABLE people_herbaria ( id INTEGER PRIMARY KEY AUTOINCREMENT, institution_id INTEGER NOT NULL, ih_code TEXT NOT NULL, name TEXT NOT NULL, specimen_count_estimate INTEGER, focus_taxa TEXT, contact_user_id INTEGER, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (institution_id) REFERENCES people_institutions (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (contact_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (ih_code) ); CREATE TABLE people_affiliations ( id INTEGER PRIMARY KEY AUTOINCREMENT, person_id INTEGER NOT NULL, institution_id INTEGER NOT NULL, position_title TEXT, start_date TEXT, end_date TEXT, is_primary INTEGER NOT NULL DEFAULT 0, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (person_id) REFERENCES people_persons (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (institution_id) REFERENCES people_institutions (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_people_affiliations_person_id ON people_affiliations (person_id); CREATE INDEX ix_people_affiliations_institution_id ON people_affiliations (institution_id); CREATE TABLE people_role_types ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_people_role_types_is_active ON people_role_types (is_active); CREATE INDEX ix_people_role_types_label ON people_role_types (label); CREATE TABLE lit_publication_types ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_lit_publication_types_is_active ON lit_publication_types (is_active); CREATE INDEX ix_lit_publication_types_label ON lit_publication_types (label); CREATE TABLE lit_journals ( id INTEGER PRIMARY KEY AUTOINCREMENT, title TEXT NOT NULL, abbreviation TEXT, issn_print TEXT, issn_online TEXT, publisher TEXT, country_id INTEGER, first_year INTEGER, last_year INTEGER, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (issn_print), UNIQUE (issn_online) ); CREATE INDEX ix_lit_journals_title ON lit_journals (title); CREATE INDEX ix_lit_journals_abbreviation ON lit_journals (abbreviation); CREATE TABLE lit_publications ( id INTEGER PRIMARY KEY AUTOINCREMENT, uuid TEXT NOT NULL DEFAULT (lower(hex(randomblob(4))) || '-' || lower(hex(randomblob(2))) || '-4' || substr(lower(hex(randomblob(2))),2) || '-' || substr('89ab',abs(random()) % 4 + 1, 1) || substr(lower(hex(randomblob(2))),2) || '-' || lower(hex(randomblob(6)))), publication_type_id INTEGER NOT NULL, title TEXT NOT NULL, year INTEGER, journal_id INTEGER, volume TEXT, issue TEXT, page_start TEXT, page_end TEXT, doi TEXT, isbn TEXT, url TEXT, abstract TEXT, language_code TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_type_id) REFERENCES lit_publication_types (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (journal_id) REFERENCES lit_journals (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (doi) ); CREATE INDEX ix_lit_publications_year ON lit_publications (year); CREATE INDEX ix_lit_publications_journal_id ON lit_publications (journal_id); CREATE TABLE lit_authorships ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER NOT NULL, person_id INTEGER NOT NULL, author_position INTEGER NOT NULL, is_corresponding INTEGER NOT NULL DEFAULT 0, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (person_id) REFERENCES people_persons (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (publication_id, author_position) ); CREATE INDEX ix_lit_authorships_person_id ON lit_authorships (person_id); CREATE TABLE lit_keywords ( id INTEGER PRIMARY KEY AUTOINCREMENT, term TEXT NOT NULL, vocabulary TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (term, vocabulary) ); CREATE TABLE lit_publication_keywords ( publication_id INTEGER NOT NULL, keyword_id INTEGER NOT NULL, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, PRIMARY KEY (publication_id, keyword_id), FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (keyword_id) REFERENCES lit_keywords (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_lit_publication_keywords_keyword_id ON lit_publication_keywords (keyword_id); CREATE TABLE tax_nomenclatural_codes ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_tax_nomenclatural_codes_is_active ON tax_nomenclatural_codes (is_active); CREATE INDEX ix_tax_nomenclatural_codes_label ON tax_nomenclatural_codes (label); CREATE TABLE tax_taxonomic_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_tax_taxonomic_status_is_active ON tax_taxonomic_status (is_active); CREATE INDEX ix_tax_taxonomic_status_label ON tax_taxonomic_status (label); CREATE TABLE tax_type_designation_kinds ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_tax_type_designation_kinds_is_active ON tax_type_designation_kinds (is_active); CREATE INDEX ix_tax_type_designation_kinds_label ON tax_type_designation_kinds (label); CREATE TABLE tax_kingdoms ( id INTEGER PRIMARY KEY AUTOINCREMENT, uuid TEXT NOT NULL DEFAULT (lower(hex(randomblob(4))) || '-' || lower(hex(randomblob(2))) || '-4' || substr(lower(hex(randomblob(2))),2) || '-' || substr('89ab',abs(random()) % 4 + 1, 1) || substr(lower(hex(randomblob(2))),2) || '-' || lower(hex(randomblob(6)))), scientific_name TEXT NOT NULL, authority TEXT, year_published INTEGER, protologue_publication_id INTEGER, nomenclatural_code_id INTEGER, status_id INTEGER NOT NULL, accepted_id INTEGER, ipni_id TEXT, mycobank_number INTEGER, index_fungorum_id INTEGER, etymology TEXT, description_morphology TEXT, type_locality_id INTEGER, is_type_genus INTEGER NOT NULL DEFAULT 0, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (protologue_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (nomenclatural_code_id) REFERENCES tax_nomenclatural_codes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (status_id) REFERENCES tax_taxonomic_status (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (accepted_id) REFERENCES tax_kingdoms (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_locality_id) REFERENCES geo_localities (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (scientific_name, authority) ); CREATE INDEX ix_tax_kingdoms_scientific_name ON tax_kingdoms (scientific_name); CREATE INDEX ix_tax_kingdoms_status_id ON tax_kingdoms (status_id); CREATE TABLE tax_subkingdoms ( id INTEGER PRIMARY KEY AUTOINCREMENT, uuid TEXT NOT NULL DEFAULT (lower(hex(randomblob(4))) || '-' || lower(hex(randomblob(2))) || '-4' || substr(lower(hex(randomblob(2))),2) || '-' || substr('89ab',abs(random()) % 4 + 1, 1) || substr(lower(hex(randomblob(2))),2) || '-' || lower(hex(randomblob(6)))), scientific_name TEXT NOT NULL, authority TEXT, year_published INTEGER, protologue_publication_id INTEGER, nomenclatural_code_id INTEGER, status_id INTEGER NOT NULL, accepted_id INTEGER, parent_kingdom_id INTEGER, ipni_id TEXT, mycobank_number INTEGER, index_fungorum_id INTEGER, etymology TEXT, description_morphology TEXT, type_locality_id INTEGER, is_type_genus INTEGER NOT NULL DEFAULT 0, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (protologue_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (nomenclatural_code_id) REFERENCES tax_nomenclatural_codes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (status_id) REFERENCES tax_taxonomic_status (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (accepted_id) REFERENCES tax_subkingdoms (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_locality_id) REFERENCES geo_localities (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (parent_kingdom_id) REFERENCES tax_kingdoms (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (scientific_name, authority) ); CREATE INDEX ix_tax_subkingdoms_scientific_name ON tax_subkingdoms (scientific_name); CREATE INDEX ix_tax_subkingdoms_status_id ON tax_subkingdoms (status_id); CREATE TABLE tax_phyla ( id INTEGER PRIMARY KEY AUTOINCREMENT, uuid TEXT NOT NULL DEFAULT (lower(hex(randomblob(4))) || '-' || lower(hex(randomblob(2))) || '-4' || substr(lower(hex(randomblob(2))),2) || '-' || substr('89ab',abs(random()) % 4 + 1, 1) || substr(lower(hex(randomblob(2))),2) || '-' || lower(hex(randomblob(6)))), scientific_name TEXT NOT NULL, authority TEXT, year_published INTEGER, protologue_publication_id INTEGER, nomenclatural_code_id INTEGER, status_id INTEGER NOT NULL, accepted_id INTEGER, parent_subkingdom_id INTEGER, ipni_id TEXT, mycobank_number INTEGER, index_fungorum_id INTEGER, etymology TEXT, description_morphology TEXT, type_locality_id INTEGER, is_type_genus INTEGER NOT NULL DEFAULT 0, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (protologue_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (nomenclatural_code_id) REFERENCES tax_nomenclatural_codes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (status_id) REFERENCES tax_taxonomic_status (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (accepted_id) REFERENCES tax_phyla (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_locality_id) REFERENCES geo_localities (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (parent_subkingdom_id) REFERENCES tax_subkingdoms (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (scientific_name, authority) ); CREATE INDEX ix_tax_phyla_scientific_name ON tax_phyla (scientific_name); CREATE INDEX ix_tax_phyla_status_id ON tax_phyla (status_id); CREATE TABLE tax_subphyla ( id INTEGER PRIMARY KEY AUTOINCREMENT, uuid TEXT NOT NULL DEFAULT (lower(hex(randomblob(4))) || '-' || lower(hex(randomblob(2))) || '-4' || substr(lower(hex(randomblob(2))),2) || '-' || substr('89ab',abs(random()) % 4 + 1, 1) || substr(lower(hex(randomblob(2))),2) || '-' || lower(hex(randomblob(6)))), scientific_name TEXT NOT NULL, authority TEXT, year_published INTEGER, protologue_publication_id INTEGER, nomenclatural_code_id INTEGER, status_id INTEGER NOT NULL, accepted_id INTEGER, parent_phylum_id INTEGER, ipni_id TEXT, mycobank_number INTEGER, index_fungorum_id INTEGER, etymology TEXT, description_morphology TEXT, type_locality_id INTEGER, is_type_genus INTEGER NOT NULL DEFAULT 0, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (protologue_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (nomenclatural_code_id) REFERENCES tax_nomenclatural_codes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (status_id) REFERENCES tax_taxonomic_status (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (accepted_id) REFERENCES tax_subphyla (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_locality_id) REFERENCES geo_localities (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (parent_phylum_id) REFERENCES tax_phyla (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (scientific_name, authority) ); CREATE INDEX ix_tax_subphyla_scientific_name ON tax_subphyla (scientific_name); CREATE INDEX ix_tax_subphyla_status_id ON tax_subphyla (status_id); CREATE TABLE tax_classes ( id INTEGER PRIMARY KEY AUTOINCREMENT, uuid TEXT NOT NULL DEFAULT (lower(hex(randomblob(4))) || '-' || lower(hex(randomblob(2))) || '-4' || substr(lower(hex(randomblob(2))),2) || '-' || substr('89ab',abs(random()) % 4 + 1, 1) || substr(lower(hex(randomblob(2))),2) || '-' || lower(hex(randomblob(6)))), scientific_name TEXT NOT NULL, authority TEXT, year_published INTEGER, protologue_publication_id INTEGER, nomenclatural_code_id INTEGER, status_id INTEGER NOT NULL, accepted_id INTEGER, parent_subphylum_id INTEGER, ipni_id TEXT, mycobank_number INTEGER, index_fungorum_id INTEGER, etymology TEXT, description_morphology TEXT, type_locality_id INTEGER, is_type_genus INTEGER NOT NULL DEFAULT 0, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (protologue_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (nomenclatural_code_id) REFERENCES tax_nomenclatural_codes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (status_id) REFERENCES tax_taxonomic_status (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (accepted_id) REFERENCES tax_classes (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_locality_id) REFERENCES geo_localities (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (parent_subphylum_id) REFERENCES tax_subphyla (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (scientific_name, authority) ); CREATE INDEX ix_tax_classes_scientific_name ON tax_classes (scientific_name); CREATE INDEX ix_tax_classes_status_id ON tax_classes (status_id); CREATE TABLE tax_subclasses ( id INTEGER PRIMARY KEY AUTOINCREMENT, uuid TEXT NOT NULL DEFAULT (lower(hex(randomblob(4))) || '-' || lower(hex(randomblob(2))) || '-4' || substr(lower(hex(randomblob(2))),2) || '-' || substr('89ab',abs(random()) % 4 + 1, 1) || substr(lower(hex(randomblob(2))),2) || '-' || lower(hex(randomblob(6)))), scientific_name TEXT NOT NULL, authority TEXT, year_published INTEGER, protologue_publication_id INTEGER, nomenclatural_code_id INTEGER, status_id INTEGER NOT NULL, accepted_id INTEGER, parent_class_id INTEGER, ipni_id TEXT, mycobank_number INTEGER, index_fungorum_id INTEGER, etymology TEXT, description_morphology TEXT, type_locality_id INTEGER, is_type_genus INTEGER NOT NULL DEFAULT 0, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (protologue_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (nomenclatural_code_id) REFERENCES tax_nomenclatural_codes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (status_id) REFERENCES tax_taxonomic_status (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (accepted_id) REFERENCES tax_subclasses (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_locality_id) REFERENCES geo_localities (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (parent_class_id) REFERENCES tax_classes (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (scientific_name, authority) ); CREATE INDEX ix_tax_subclasses_scientific_name ON tax_subclasses (scientific_name); CREATE INDEX ix_tax_subclasses_status_id ON tax_subclasses (status_id); CREATE TABLE tax_orders ( id INTEGER PRIMARY KEY AUTOINCREMENT, uuid TEXT NOT NULL DEFAULT (lower(hex(randomblob(4))) || '-' || lower(hex(randomblob(2))) || '-4' || substr(lower(hex(randomblob(2))),2) || '-' || substr('89ab',abs(random()) % 4 + 1, 1) || substr(lower(hex(randomblob(2))),2) || '-' || lower(hex(randomblob(6)))), scientific_name TEXT NOT NULL, authority TEXT, year_published INTEGER, protologue_publication_id INTEGER, nomenclatural_code_id INTEGER, status_id INTEGER NOT NULL, accepted_id INTEGER, parent_subclass_id INTEGER, ipni_id TEXT, mycobank_number INTEGER, index_fungorum_id INTEGER, etymology TEXT, description_morphology TEXT, type_locality_id INTEGER, is_type_genus INTEGER NOT NULL DEFAULT 0, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (protologue_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (nomenclatural_code_id) REFERENCES tax_nomenclatural_codes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (status_id) REFERENCES tax_taxonomic_status (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (accepted_id) REFERENCES tax_orders (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_locality_id) REFERENCES geo_localities (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (parent_subclass_id) REFERENCES tax_subclasses (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (scientific_name, authority) ); CREATE INDEX ix_tax_orders_scientific_name ON tax_orders (scientific_name); CREATE INDEX ix_tax_orders_status_id ON tax_orders (status_id); CREATE TABLE tax_suborders ( id INTEGER PRIMARY KEY AUTOINCREMENT, uuid TEXT NOT NULL DEFAULT (lower(hex(randomblob(4))) || '-' || lower(hex(randomblob(2))) || '-4' || substr(lower(hex(randomblob(2))),2) || '-' || substr('89ab',abs(random()) % 4 + 1, 1) || substr(lower(hex(randomblob(2))),2) || '-' || lower(hex(randomblob(6)))), scientific_name TEXT NOT NULL, authority TEXT, year_published INTEGER, protologue_publication_id INTEGER, nomenclatural_code_id INTEGER, status_id INTEGER NOT NULL, accepted_id INTEGER, parent_order_id INTEGER, ipni_id TEXT, mycobank_number INTEGER, index_fungorum_id INTEGER, etymology TEXT, description_morphology TEXT, type_locality_id INTEGER, is_type_genus INTEGER NOT NULL DEFAULT 0, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (protologue_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (nomenclatural_code_id) REFERENCES tax_nomenclatural_codes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (status_id) REFERENCES tax_taxonomic_status (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (accepted_id) REFERENCES tax_suborders (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_locality_id) REFERENCES geo_localities (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (parent_order_id) REFERENCES tax_orders (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (scientific_name, authority) ); CREATE INDEX ix_tax_suborders_scientific_name ON tax_suborders (scientific_name); CREATE INDEX ix_tax_suborders_status_id ON tax_suborders (status_id); CREATE TABLE tax_families ( id INTEGER PRIMARY KEY AUTOINCREMENT, uuid TEXT NOT NULL DEFAULT (lower(hex(randomblob(4))) || '-' || lower(hex(randomblob(2))) || '-4' || substr(lower(hex(randomblob(2))),2) || '-' || substr('89ab',abs(random()) % 4 + 1, 1) || substr(lower(hex(randomblob(2))),2) || '-' || lower(hex(randomblob(6)))), scientific_name TEXT NOT NULL, authority TEXT, year_published INTEGER, protologue_publication_id INTEGER, nomenclatural_code_id INTEGER, status_id INTEGER NOT NULL, accepted_id INTEGER, parent_suborder_id INTEGER, ipni_id TEXT, mycobank_number INTEGER, index_fungorum_id INTEGER, etymology TEXT, description_morphology TEXT, type_locality_id INTEGER, is_type_genus INTEGER NOT NULL DEFAULT 0, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (protologue_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (nomenclatural_code_id) REFERENCES tax_nomenclatural_codes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (status_id) REFERENCES tax_taxonomic_status (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (accepted_id) REFERENCES tax_families (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_locality_id) REFERENCES geo_localities (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (parent_suborder_id) REFERENCES tax_suborders (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (scientific_name, authority) ); CREATE INDEX ix_tax_families_scientific_name ON tax_families (scientific_name); CREATE INDEX ix_tax_families_status_id ON tax_families (status_id); CREATE TABLE tax_subfamilies ( id INTEGER PRIMARY KEY AUTOINCREMENT, uuid TEXT NOT NULL DEFAULT (lower(hex(randomblob(4))) || '-' || lower(hex(randomblob(2))) || '-4' || substr(lower(hex(randomblob(2))),2) || '-' || substr('89ab',abs(random()) % 4 + 1, 1) || substr(lower(hex(randomblob(2))),2) || '-' || lower(hex(randomblob(6)))), scientific_name TEXT NOT NULL, authority TEXT, year_published INTEGER, protologue_publication_id INTEGER, nomenclatural_code_id INTEGER, status_id INTEGER NOT NULL, accepted_id INTEGER, parent_family_id INTEGER, ipni_id TEXT, mycobank_number INTEGER, index_fungorum_id INTEGER, etymology TEXT, description_morphology TEXT, type_locality_id INTEGER, is_type_genus INTEGER NOT NULL DEFAULT 0, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (protologue_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (nomenclatural_code_id) REFERENCES tax_nomenclatural_codes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (status_id) REFERENCES tax_taxonomic_status (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (accepted_id) REFERENCES tax_subfamilies (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_locality_id) REFERENCES geo_localities (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (parent_family_id) REFERENCES tax_families (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (scientific_name, authority) ); CREATE INDEX ix_tax_subfamilies_scientific_name ON tax_subfamilies (scientific_name); CREATE INDEX ix_tax_subfamilies_status_id ON tax_subfamilies (status_id); CREATE TABLE tax_tribes ( id INTEGER PRIMARY KEY AUTOINCREMENT, uuid TEXT NOT NULL DEFAULT (lower(hex(randomblob(4))) || '-' || lower(hex(randomblob(2))) || '-4' || substr(lower(hex(randomblob(2))),2) || '-' || substr('89ab',abs(random()) % 4 + 1, 1) || substr(lower(hex(randomblob(2))),2) || '-' || lower(hex(randomblob(6)))), scientific_name TEXT NOT NULL, authority TEXT, year_published INTEGER, protologue_publication_id INTEGER, nomenclatural_code_id INTEGER, status_id INTEGER NOT NULL, accepted_id INTEGER, parent_subfamily_id INTEGER, ipni_id TEXT, mycobank_number INTEGER, index_fungorum_id INTEGER, etymology TEXT, description_morphology TEXT, type_locality_id INTEGER, is_type_genus INTEGER NOT NULL DEFAULT 0, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (protologue_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (nomenclatural_code_id) REFERENCES tax_nomenclatural_codes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (status_id) REFERENCES tax_taxonomic_status (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (accepted_id) REFERENCES tax_tribes (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_locality_id) REFERENCES geo_localities (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (parent_subfamily_id) REFERENCES tax_subfamilies (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (scientific_name, authority) ); CREATE INDEX ix_tax_tribes_scientific_name ON tax_tribes (scientific_name); CREATE INDEX ix_tax_tribes_status_id ON tax_tribes (status_id); CREATE TABLE tax_genera ( id INTEGER PRIMARY KEY AUTOINCREMENT, uuid TEXT NOT NULL DEFAULT (lower(hex(randomblob(4))) || '-' || lower(hex(randomblob(2))) || '-4' || substr(lower(hex(randomblob(2))),2) || '-' || substr('89ab',abs(random()) % 4 + 1, 1) || substr(lower(hex(randomblob(2))),2) || '-' || lower(hex(randomblob(6)))), scientific_name TEXT NOT NULL, authority TEXT, year_published INTEGER, protologue_publication_id INTEGER, nomenclatural_code_id INTEGER, status_id INTEGER NOT NULL, accepted_id INTEGER, parent_tribe_id INTEGER, ipni_id TEXT, mycobank_number INTEGER, index_fungorum_id INTEGER, etymology TEXT, description_morphology TEXT, type_locality_id INTEGER, is_type_genus INTEGER NOT NULL DEFAULT 0, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (protologue_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (nomenclatural_code_id) REFERENCES tax_nomenclatural_codes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (status_id) REFERENCES tax_taxonomic_status (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (accepted_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_locality_id) REFERENCES geo_localities (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (parent_tribe_id) REFERENCES tax_tribes (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (scientific_name, authority) ); CREATE INDEX ix_tax_genera_scientific_name ON tax_genera (scientific_name); CREATE INDEX ix_tax_genera_status_id ON tax_genera (status_id); CREATE TABLE tax_subgenera ( id INTEGER PRIMARY KEY AUTOINCREMENT, uuid TEXT NOT NULL DEFAULT (lower(hex(randomblob(4))) || '-' || lower(hex(randomblob(2))) || '-4' || substr(lower(hex(randomblob(2))),2) || '-' || substr('89ab',abs(random()) % 4 + 1, 1) || substr(lower(hex(randomblob(2))),2) || '-' || lower(hex(randomblob(6)))), scientific_name TEXT NOT NULL, authority TEXT, year_published INTEGER, protologue_publication_id INTEGER, nomenclatural_code_id INTEGER, status_id INTEGER NOT NULL, accepted_id INTEGER, parent_genus_id INTEGER, ipni_id TEXT, mycobank_number INTEGER, index_fungorum_id INTEGER, etymology TEXT, description_morphology TEXT, type_locality_id INTEGER, is_type_genus INTEGER NOT NULL DEFAULT 0, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (protologue_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (nomenclatural_code_id) REFERENCES tax_nomenclatural_codes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (status_id) REFERENCES tax_taxonomic_status (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (accepted_id) REFERENCES tax_subgenera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_locality_id) REFERENCES geo_localities (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (parent_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (scientific_name, authority) ); CREATE INDEX ix_tax_subgenera_scientific_name ON tax_subgenera (scientific_name); CREATE INDEX ix_tax_subgenera_status_id ON tax_subgenera (status_id); CREATE TABLE tax_sections ( id INTEGER PRIMARY KEY AUTOINCREMENT, uuid TEXT NOT NULL DEFAULT (lower(hex(randomblob(4))) || '-' || lower(hex(randomblob(2))) || '-4' || substr(lower(hex(randomblob(2))),2) || '-' || substr('89ab',abs(random()) % 4 + 1, 1) || substr(lower(hex(randomblob(2))),2) || '-' || lower(hex(randomblob(6)))), scientific_name TEXT NOT NULL, authority TEXT, year_published INTEGER, protologue_publication_id INTEGER, nomenclatural_code_id INTEGER, status_id INTEGER NOT NULL, accepted_id INTEGER, parent_subgenus_id INTEGER, ipni_id TEXT, mycobank_number INTEGER, index_fungorum_id INTEGER, etymology TEXT, description_morphology TEXT, type_locality_id INTEGER, is_type_genus INTEGER NOT NULL DEFAULT 0, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (protologue_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (nomenclatural_code_id) REFERENCES tax_nomenclatural_codes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (status_id) REFERENCES tax_taxonomic_status (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (accepted_id) REFERENCES tax_sections (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_locality_id) REFERENCES geo_localities (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (parent_subgenus_id) REFERENCES tax_subgenera (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (scientific_name, authority) ); CREATE INDEX ix_tax_sections_scientific_name ON tax_sections (scientific_name); CREATE INDEX ix_tax_sections_status_id ON tax_sections (status_id); CREATE TABLE tax_species ( id INTEGER PRIMARY KEY AUTOINCREMENT, uuid TEXT NOT NULL DEFAULT (lower(hex(randomblob(4))) || '-' || lower(hex(randomblob(2))) || '-4' || substr(lower(hex(randomblob(2))),2) || '-' || substr('89ab',abs(random()) % 4 + 1, 1) || substr(lower(hex(randomblob(2))),2) || '-' || lower(hex(randomblob(6)))), scientific_name TEXT NOT NULL, authority TEXT, year_published INTEGER, protologue_publication_id INTEGER, nomenclatural_code_id INTEGER, status_id INTEGER NOT NULL, accepted_id INTEGER, parent_section_id INTEGER, ipni_id TEXT, mycobank_number INTEGER, index_fungorum_id INTEGER, etymology TEXT, description_morphology TEXT, type_locality_id INTEGER, is_type_genus INTEGER NOT NULL DEFAULT 0, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (protologue_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (nomenclatural_code_id) REFERENCES tax_nomenclatural_codes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (status_id) REFERENCES tax_taxonomic_status (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (accepted_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_locality_id) REFERENCES geo_localities (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (parent_section_id) REFERENCES tax_sections (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (scientific_name, authority) ); CREATE INDEX ix_tax_species_scientific_name ON tax_species (scientific_name); CREATE INDEX ix_tax_species_status_id ON tax_species (status_id); CREATE TABLE tax_subspecies ( id INTEGER PRIMARY KEY AUTOINCREMENT, uuid TEXT NOT NULL DEFAULT (lower(hex(randomblob(4))) || '-' || lower(hex(randomblob(2))) || '-4' || substr(lower(hex(randomblob(2))),2) || '-' || substr('89ab',abs(random()) % 4 + 1, 1) || substr(lower(hex(randomblob(2))),2) || '-' || lower(hex(randomblob(6)))), scientific_name TEXT NOT NULL, authority TEXT, year_published INTEGER, protologue_publication_id INTEGER, nomenclatural_code_id INTEGER, status_id INTEGER NOT NULL, accepted_id INTEGER, parent_species_id INTEGER, ipni_id TEXT, mycobank_number INTEGER, index_fungorum_id INTEGER, etymology TEXT, description_morphology TEXT, type_locality_id INTEGER, is_type_genus INTEGER NOT NULL DEFAULT 0, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (protologue_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (nomenclatural_code_id) REFERENCES tax_nomenclatural_codes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (status_id) REFERENCES tax_taxonomic_status (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (accepted_id) REFERENCES tax_subspecies (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_locality_id) REFERENCES geo_localities (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (parent_species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (scientific_name, authority) ); CREATE INDEX ix_tax_subspecies_scientific_name ON tax_subspecies (scientific_name); CREATE INDEX ix_tax_subspecies_status_id ON tax_subspecies (status_id); CREATE TABLE tax_varieties ( id INTEGER PRIMARY KEY AUTOINCREMENT, uuid TEXT NOT NULL DEFAULT (lower(hex(randomblob(4))) || '-' || lower(hex(randomblob(2))) || '-4' || substr(lower(hex(randomblob(2))),2) || '-' || substr('89ab',abs(random()) % 4 + 1, 1) || substr(lower(hex(randomblob(2))),2) || '-' || lower(hex(randomblob(6)))), scientific_name TEXT NOT NULL, authority TEXT, year_published INTEGER, protologue_publication_id INTEGER, nomenclatural_code_id INTEGER, status_id INTEGER NOT NULL, accepted_id INTEGER, parent_subspecies_id INTEGER, ipni_id TEXT, mycobank_number INTEGER, index_fungorum_id INTEGER, etymology TEXT, description_morphology TEXT, type_locality_id INTEGER, is_type_genus INTEGER NOT NULL DEFAULT 0, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (protologue_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (nomenclatural_code_id) REFERENCES tax_nomenclatural_codes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (status_id) REFERENCES tax_taxonomic_status (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (accepted_id) REFERENCES tax_varieties (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_locality_id) REFERENCES geo_localities (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (parent_subspecies_id) REFERENCES tax_subspecies (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (scientific_name, authority) ); CREATE INDEX ix_tax_varieties_scientific_name ON tax_varieties (scientific_name); CREATE INDEX ix_tax_varieties_status_id ON tax_varieties (status_id); CREATE TABLE tax_forms ( id INTEGER PRIMARY KEY AUTOINCREMENT, uuid TEXT NOT NULL DEFAULT (lower(hex(randomblob(4))) || '-' || lower(hex(randomblob(2))) || '-4' || substr(lower(hex(randomblob(2))),2) || '-' || substr('89ab',abs(random()) % 4 + 1, 1) || substr(lower(hex(randomblob(2))),2) || '-' || lower(hex(randomblob(6)))), scientific_name TEXT NOT NULL, authority TEXT, year_published INTEGER, protologue_publication_id INTEGER, nomenclatural_code_id INTEGER, status_id INTEGER NOT NULL, accepted_id INTEGER, parent_variety_id INTEGER, ipni_id TEXT, mycobank_number INTEGER, index_fungorum_id INTEGER, etymology TEXT, description_morphology TEXT, type_locality_id INTEGER, is_type_genus INTEGER NOT NULL DEFAULT 0, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (protologue_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (nomenclatural_code_id) REFERENCES tax_nomenclatural_codes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (status_id) REFERENCES tax_taxonomic_status (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (accepted_id) REFERENCES tax_forms (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_locality_id) REFERENCES geo_localities (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (parent_variety_id) REFERENCES tax_varieties (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (scientific_name, authority) ); CREATE INDEX ix_tax_forms_scientific_name ON tax_forms (scientific_name); CREATE INDEX ix_tax_forms_status_id ON tax_forms (status_id); CREATE TABLE tax_synonymies ( id INTEGER PRIMARY KEY AUTOINCREMENT, synonym_rank TEXT NOT NULL, synonym_id INTEGER NOT NULL, accepted_rank TEXT NOT NULL, accepted_id INTEGER NOT NULL, synonymy_kind TEXT NOT NULL CHECK (synonymy_kind IN ('homotypic','heterotypic','nomen_dubium','replaced')), publication_id INTEGER, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_tax_synonymies_synonym_rank_synonym_id ON tax_synonymies (synonym_rank, synonym_id); CREATE INDEX ix_tax_synonymies_accepted_rank_accepted_id ON tax_synonymies (accepted_rank, accepted_id); CREATE TABLE tax_common_names ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, name TEXT NOT NULL, language_code TEXT NOT NULL, region_country_id INTEGER, source_publication_id INTEGER, is_preferred INTEGER NOT NULL DEFAULT 0, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (source_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_tax_common_names_species_id ON tax_common_names (species_id); CREATE INDEX ix_tax_common_names_language_code ON tax_common_names (language_code); CREATE TABLE tax_type_designations ( id INTEGER PRIMARY KEY AUTOINCREMENT, taxon_rank TEXT NOT NULL, taxon_id INTEGER NOT NULL, type_kind_id INTEGER NOT NULL, specimen_id INTEGER, designation_publication_id INTEGER, designated_by_person_id INTEGER, designated_year INTEGER, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (type_kind_id) REFERENCES tax_type_designation_kinds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (designation_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (designated_by_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_tax_type_designations_taxon_rank_taxon_id ON tax_type_designations (taxon_rank, taxon_id); CREATE INDEX ix_tax_type_designations_specimen_id ON tax_type_designations (specimen_id); CREATE TABLE tax_revisions ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER NOT NULL, scope_summary TEXT, affected_family_id INTEGER, affected_genus_id INTEGER, affected_species_id INTEGER, revision_year INTEGER, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (affected_family_id) REFERENCES tax_families (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE TABLE spc_preservation_methods ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_spc_preservation_methods_is_active ON spc_preservation_methods (is_active); CREATE INDEX ix_spc_preservation_methods_label ON spc_preservation_methods (label); CREATE TABLE spc_collection_methods ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_spc_collection_methods_is_active ON spc_collection_methods (is_active); CREATE INDEX ix_spc_collection_methods_label ON spc_collection_methods (label); CREATE TABLE spc_growth_substrates ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_spc_growth_substrates_is_active ON spc_growth_substrates (is_active); CREATE INDEX ix_spc_growth_substrates_label ON spc_growth_substrates (label); CREATE TABLE spc_collection_events ( id INTEGER PRIMARY KEY AUTOINCREMENT, uuid TEXT NOT NULL DEFAULT (lower(hex(randomblob(4))) || '-' || lower(hex(randomblob(2))) || '-4' || substr(lower(hex(randomblob(2))),2) || '-' || substr('89ab',abs(random()) % 4 + 1, 1) || substr(lower(hex(randomblob(2))),2) || '-' || lower(hex(randomblob(6)))), event_date TEXT, event_time_start TEXT, event_time_end TEXT, locality_id INTEGER NOT NULL, collection_method_id INTEGER, expedition_id INTEGER, habitat_summary TEXT, weather_summary TEXT, temperature_c REAL, humidity_pct REAL, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (locality_id) REFERENCES geo_localities (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (collection_method_id) REFERENCES spc_collection_methods (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (expedition_id) REFERENCES field_expeditions (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_spc_collection_events_event_date ON spc_collection_events (event_date); CREATE INDEX ix_spc_collection_events_locality_id ON spc_collection_events (locality_id); CREATE TABLE spc_collection_event_collectors ( event_id INTEGER NOT NULL, person_id INTEGER NOT NULL, role_id INTEGER, position_in_team INTEGER, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (event_id, person_id), FOREIGN KEY (event_id) REFERENCES spc_collection_events (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (person_id) REFERENCES people_persons (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (role_id) REFERENCES people_role_types (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_spc_collection_event_collectors_person_id ON spc_collection_event_collectors (person_id); CREATE TABLE spc_specimens ( id INTEGER PRIMARY KEY AUTOINCREMENT, uuid TEXT NOT NULL DEFAULT (lower(hex(randomblob(4))) || '-' || lower(hex(randomblob(2))) || '-4' || substr(lower(hex(randomblob(2))),2) || '-' || substr('89ab',abs(random()) % 4 + 1, 1) || substr(lower(hex(randomblob(2))),2) || '-' || lower(hex(randomblob(6)))), catalog_number TEXT NOT NULL, herbarium_id INTEGER NOT NULL, collection_event_id INTEGER, collector_number TEXT, primary_collector_person_id INTEGER, preservation_method_id INTEGER, growth_substrate_id INTEGER, substrate_detail TEXT, identified_species_id INTEGER, identified_at_rank TEXT, identification_confidence TEXT DEFAULT 'verified' CHECK (identification_confidence IN ('uncertain','tentative','verified','expert')), identified_by_person_id INTEGER, identified_at TEXT, is_type_specimen INTEGER NOT NULL DEFAULT 0, storage_location TEXT, condition_score INTEGER CHECK (condition_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (herbarium_id) REFERENCES people_herbaria (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (collection_event_id) REFERENCES spc_collection_events (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (primary_collector_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (preservation_method_id) REFERENCES spc_preservation_methods (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (growth_substrate_id) REFERENCES spc_growth_substrates (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (identified_species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (identified_by_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (herbarium_id, catalog_number), UNIQUE (uuid) ); CREATE INDEX ix_spc_specimens_catalog_number ON spc_specimens (catalog_number); CREATE INDEX ix_spc_specimens_identified_species_id ON spc_specimens (identified_species_id); CREATE INDEX ix_spc_specimens_herbarium_id ON spc_specimens (herbarium_id); CREATE INDEX ix_spc_specimens_is_type_specimen ON spc_specimens (is_type_specimen); CREATE TABLE spc_identification_history ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, identified_to_rank TEXT NOT NULL, identification_text TEXT, identified_by_person_id INTEGER, identified_at TEXT, source_publication_id INTEGER, is_current INTEGER NOT NULL DEFAULT 0, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (identified_by_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (source_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_spc_identification_history_specimen_id_is_current ON spc_identification_history (specimen_id, is_current); CREATE INDEX ix_spc_identification_history_identified_at ON spc_identification_history (identified_at); CREATE TABLE spc_specimen_duplicates ( id INTEGER PRIMARY KEY AUTOINCREMENT, primary_specimen_id INTEGER NOT NULL, duplicate_specimen_id INTEGER NOT NULL, relation_type TEXT NOT NULL DEFAULT 'duplicate', created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (primary_specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (duplicate_specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (primary_specimen_id, duplicate_specimen_id) ); CREATE TABLE spc_loans ( id INTEGER PRIMARY KEY AUTOINCREMENT, loan_number TEXT NOT NULL, from_herbarium_id INTEGER NOT NULL, to_institution_id INTEGER NOT NULL, requested_by_user_id INTEGER, loan_purpose TEXT, requested_date TEXT, shipped_date TEXT, expected_return_date TEXT, returned_date TEXT, status TEXT NOT NULL DEFAULT 'requested' CHECK (status IN ('requested','shipped','overdue','returned','cancelled')), created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (from_herbarium_id) REFERENCES people_herbaria (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (to_institution_id) REFERENCES people_institutions (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (requested_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (loan_number) ); CREATE INDEX ix_spc_loans_status ON spc_loans (status); CREATE TABLE spc_loan_specimens ( loan_id INTEGER NOT NULL, specimen_id INTEGER NOT NULL, returned_date TEXT, condition_on_return TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, PRIMARY KEY (loan_id, specimen_id), FOREIGN KEY (loan_id) REFERENCES spc_loans (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_spc_loan_specimens_specimen_id ON spc_loan_specimens (specimen_id); CREATE TABLE spc_specimen_publications ( specimen_id INTEGER NOT NULL, publication_id INTEGER NOT NULL, citation_context TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (specimen_id, publication_id), FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE CASCADE ON UPDATE CASCADE ); CREATE TABLE spc_specimen_images ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, file_uri TEXT NOT NULL, image_kind TEXT NOT NULL, photographer_person_id INTEGER, captured_at TEXT, width_px INTEGER, height_px INTEGER, file_size_bytes INTEGER, license TEXT, caption TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (photographer_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_spc_specimen_images_specimen_id ON spc_specimen_images (specimen_id); CREATE INDEX ix_spc_specimen_images_image_kind ON spc_specimen_images (image_kind); CREATE TABLE mor_color_standards ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_mor_color_standards_is_active ON mor_color_standards (is_active); CREATE INDEX ix_mor_color_standards_label ON mor_color_standards (label); CREATE TABLE mor_color_chips ( id INTEGER PRIMARY KEY AUTOINCREMENT, standard_id INTEGER NOT NULL, chip_code TEXT NOT NULL, chip_name TEXT, rgb_hex TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (standard_id) REFERENCES mor_color_standards (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (standard_id, chip_code) ); CREATE TABLE mor_chemical_reagents ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_mor_chemical_reagents_is_active ON mor_chemical_reagents (is_active); CREATE INDEX ix_mor_chemical_reagents_label ON mor_chemical_reagents (label); CREATE TABLE mor_spore_measurements ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, length_min_um REAL, length_max_um REAL, length_mean_um REAL, width_min_um REAL, width_max_um REAL, width_mean_um REAL, q_min REAL, q_max REAL, q_mean REAL, sample_size_n INTEGER, measured_in_reagent_id INTEGER, measured_at TEXT, measured_by_person_id INTEGER, publication_id INTEGER, excludes_apiculus INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (measured_in_reagent_id) REFERENCES mor_chemical_reagents (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (measured_by_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_mor_spore_measurements_specimen_id ON mor_spore_measurements (specimen_id); CREATE INDEX ix_mor_spore_measurements_species_id ON mor_spore_measurements (species_id); CREATE TABLE mor_states_pileus_shape ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_mor_states_pileus_shape_is_active ON mor_states_pileus_shape (is_active); CREATE INDEX ix_mor_states_pileus_shape_label ON mor_states_pileus_shape (label); CREATE TABLE mor_obs_pileus_shape ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, observed_by_person_id INTEGER, observed_at TEXT, publication_id INTEGER, state_id INTEGER, state_modifier TEXT, free_text_description TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (observed_by_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (state_id) REFERENCES mor_states_pileus_shape (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_mor_obs_pileus_shape_specimen_id ON mor_obs_pileus_shape (specimen_id); CREATE INDEX ix_mor_obs_pileus_shape_species_id ON mor_obs_pileus_shape (species_id); CREATE TABLE mor_states_pileus_surface ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_mor_states_pileus_surface_is_active ON mor_states_pileus_surface (is_active); CREATE INDEX ix_mor_states_pileus_surface_label ON mor_states_pileus_surface (label); CREATE TABLE mor_obs_pileus_surface ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, observed_by_person_id INTEGER, observed_at TEXT, publication_id INTEGER, state_id INTEGER, state_modifier TEXT, free_text_description TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (observed_by_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (state_id) REFERENCES mor_states_pileus_surface (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_mor_obs_pileus_surface_specimen_id ON mor_obs_pileus_surface (specimen_id); CREATE INDEX ix_mor_obs_pileus_surface_species_id ON mor_obs_pileus_surface (species_id); CREATE TABLE mor_states_pileus_margin ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_mor_states_pileus_margin_is_active ON mor_states_pileus_margin (is_active); CREATE INDEX ix_mor_states_pileus_margin_label ON mor_states_pileus_margin (label); CREATE TABLE mor_obs_pileus_margin ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, observed_by_person_id INTEGER, observed_at TEXT, publication_id INTEGER, state_id INTEGER, state_modifier TEXT, free_text_description TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (observed_by_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (state_id) REFERENCES mor_states_pileus_margin (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_mor_obs_pileus_margin_specimen_id ON mor_obs_pileus_margin (specimen_id); CREATE INDEX ix_mor_obs_pileus_margin_species_id ON mor_obs_pileus_margin (species_id); CREATE TABLE mor_states_pileus_color ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_mor_states_pileus_color_is_active ON mor_states_pileus_color (is_active); CREATE INDEX ix_mor_states_pileus_color_label ON mor_states_pileus_color (label); CREATE TABLE mor_obs_pileus_color ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, observed_by_person_id INTEGER, observed_at TEXT, publication_id INTEGER, state_id INTEGER, state_modifier TEXT, free_text_description TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (observed_by_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (state_id) REFERENCES mor_states_pileus_color (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_mor_obs_pileus_color_specimen_id ON mor_obs_pileus_color (specimen_id); CREATE INDEX ix_mor_obs_pileus_color_species_id ON mor_obs_pileus_color (species_id); CREATE TABLE mor_states_hymenophore_type ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_mor_states_hymenophore_type_is_active ON mor_states_hymenophore_type (is_active); CREATE INDEX ix_mor_states_hymenophore_type_label ON mor_states_hymenophore_type (label); CREATE TABLE mor_obs_hymenophore_type ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, observed_by_person_id INTEGER, observed_at TEXT, publication_id INTEGER, state_id INTEGER, state_modifier TEXT, free_text_description TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (observed_by_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (state_id) REFERENCES mor_states_hymenophore_type (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_mor_obs_hymenophore_type_specimen_id ON mor_obs_hymenophore_type (specimen_id); CREATE INDEX ix_mor_obs_hymenophore_type_species_id ON mor_obs_hymenophore_type (species_id); CREATE TABLE mor_states_lamella_attachment ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_mor_states_lamella_attachment_is_active ON mor_states_lamella_attachment (is_active); CREATE INDEX ix_mor_states_lamella_attachment_label ON mor_states_lamella_attachment (label); CREATE TABLE mor_obs_lamella_attachment ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, observed_by_person_id INTEGER, observed_at TEXT, publication_id INTEGER, state_id INTEGER, state_modifier TEXT, free_text_description TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (observed_by_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (state_id) REFERENCES mor_states_lamella_attachment (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_mor_obs_lamella_attachment_specimen_id ON mor_obs_lamella_attachment (specimen_id); CREATE INDEX ix_mor_obs_lamella_attachment_species_id ON mor_obs_lamella_attachment (species_id); CREATE TABLE mor_states_lamella_spacing ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_mor_states_lamella_spacing_is_active ON mor_states_lamella_spacing (is_active); CREATE INDEX ix_mor_states_lamella_spacing_label ON mor_states_lamella_spacing (label); CREATE TABLE mor_obs_lamella_spacing ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, observed_by_person_id INTEGER, observed_at TEXT, publication_id INTEGER, state_id INTEGER, state_modifier TEXT, free_text_description TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (observed_by_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (state_id) REFERENCES mor_states_lamella_spacing (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_mor_obs_lamella_spacing_specimen_id ON mor_obs_lamella_spacing (specimen_id); CREATE INDEX ix_mor_obs_lamella_spacing_species_id ON mor_obs_lamella_spacing (species_id); CREATE TABLE mor_states_lamella_color ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_mor_states_lamella_color_is_active ON mor_states_lamella_color (is_active); CREATE INDEX ix_mor_states_lamella_color_label ON mor_states_lamella_color (label); CREATE TABLE mor_obs_lamella_color ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, observed_by_person_id INTEGER, observed_at TEXT, publication_id INTEGER, state_id INTEGER, state_modifier TEXT, free_text_description TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (observed_by_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (state_id) REFERENCES mor_states_lamella_color (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_mor_obs_lamella_color_specimen_id ON mor_obs_lamella_color (specimen_id); CREATE INDEX ix_mor_obs_lamella_color_species_id ON mor_obs_lamella_color (species_id); CREATE TABLE mor_states_pore_shape ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_mor_states_pore_shape_is_active ON mor_states_pore_shape (is_active); CREATE INDEX ix_mor_states_pore_shape_label ON mor_states_pore_shape (label); CREATE TABLE mor_obs_pore_shape ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, observed_by_person_id INTEGER, observed_at TEXT, publication_id INTEGER, state_id INTEGER, state_modifier TEXT, free_text_description TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (observed_by_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (state_id) REFERENCES mor_states_pore_shape (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_mor_obs_pore_shape_specimen_id ON mor_obs_pore_shape (specimen_id); CREATE INDEX ix_mor_obs_pore_shape_species_id ON mor_obs_pore_shape (species_id); CREATE TABLE mor_obs_pore_density_per_mm ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, observed_by_person_id INTEGER, observed_at TEXT, publication_id INTEGER, value_min REAL, value_max REAL, value_mean REAL, value_unit TEXT, sample_size_n INTEGER, free_text_description TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (observed_by_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_mor_obs_pore_density_per_mm_specimen_id ON mor_obs_pore_density_per_mm (specimen_id); CREATE INDEX ix_mor_obs_pore_density_per_mm_species_id ON mor_obs_pore_density_per_mm (species_id); CREATE TABLE mor_obs_tubes_length ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, observed_by_person_id INTEGER, observed_at TEXT, publication_id INTEGER, value_min REAL, value_max REAL, value_mean REAL, value_unit TEXT, sample_size_n INTEGER, free_text_description TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (observed_by_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_mor_obs_tubes_length_specimen_id ON mor_obs_tubes_length (specimen_id); CREATE INDEX ix_mor_obs_tubes_length_species_id ON mor_obs_tubes_length (species_id); CREATE TABLE mor_states_teeth_shape ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_mor_states_teeth_shape_is_active ON mor_states_teeth_shape (is_active); CREATE INDEX ix_mor_states_teeth_shape_label ON mor_states_teeth_shape (label); CREATE TABLE mor_obs_teeth_shape ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, observed_by_person_id INTEGER, observed_at TEXT, publication_id INTEGER, state_id INTEGER, state_modifier TEXT, free_text_description TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (observed_by_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (state_id) REFERENCES mor_states_teeth_shape (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_mor_obs_teeth_shape_specimen_id ON mor_obs_teeth_shape (specimen_id); CREATE INDEX ix_mor_obs_teeth_shape_species_id ON mor_obs_teeth_shape (species_id); CREATE TABLE mor_states_stipe_shape ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_mor_states_stipe_shape_is_active ON mor_states_stipe_shape (is_active); CREATE INDEX ix_mor_states_stipe_shape_label ON mor_states_stipe_shape (label); CREATE TABLE mor_obs_stipe_shape ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, observed_by_person_id INTEGER, observed_at TEXT, publication_id INTEGER, state_id INTEGER, state_modifier TEXT, free_text_description TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (observed_by_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (state_id) REFERENCES mor_states_stipe_shape (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_mor_obs_stipe_shape_specimen_id ON mor_obs_stipe_shape (specimen_id); CREATE INDEX ix_mor_obs_stipe_shape_species_id ON mor_obs_stipe_shape (species_id); CREATE TABLE mor_states_stipe_surface ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_mor_states_stipe_surface_is_active ON mor_states_stipe_surface (is_active); CREATE INDEX ix_mor_states_stipe_surface_label ON mor_states_stipe_surface (label); CREATE TABLE mor_obs_stipe_surface ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, observed_by_person_id INTEGER, observed_at TEXT, publication_id INTEGER, state_id INTEGER, state_modifier TEXT, free_text_description TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (observed_by_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (state_id) REFERENCES mor_states_stipe_surface (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_mor_obs_stipe_surface_specimen_id ON mor_obs_stipe_surface (specimen_id); CREATE INDEX ix_mor_obs_stipe_surface_species_id ON mor_obs_stipe_surface (species_id); CREATE TABLE mor_states_stipe_color ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_mor_states_stipe_color_is_active ON mor_states_stipe_color (is_active); CREATE INDEX ix_mor_states_stipe_color_label ON mor_states_stipe_color (label); CREATE TABLE mor_obs_stipe_color ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, observed_by_person_id INTEGER, observed_at TEXT, publication_id INTEGER, state_id INTEGER, state_modifier TEXT, free_text_description TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (observed_by_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (state_id) REFERENCES mor_states_stipe_color (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_mor_obs_stipe_color_specimen_id ON mor_obs_stipe_color (specimen_id); CREATE INDEX ix_mor_obs_stipe_color_species_id ON mor_obs_stipe_color (species_id); CREATE TABLE mor_states_stipe_base_form ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_mor_states_stipe_base_form_is_active ON mor_states_stipe_base_form (is_active); CREATE INDEX ix_mor_states_stipe_base_form_label ON mor_states_stipe_base_form (label); CREATE TABLE mor_obs_stipe_base_form ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, observed_by_person_id INTEGER, observed_at TEXT, publication_id INTEGER, state_id INTEGER, state_modifier TEXT, free_text_description TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (observed_by_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (state_id) REFERENCES mor_states_stipe_base_form (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_mor_obs_stipe_base_form_specimen_id ON mor_obs_stipe_base_form (specimen_id); CREATE INDEX ix_mor_obs_stipe_base_form_species_id ON mor_obs_stipe_base_form (species_id); CREATE TABLE mor_states_annulus_form ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_mor_states_annulus_form_is_active ON mor_states_annulus_form (is_active); CREATE INDEX ix_mor_states_annulus_form_label ON mor_states_annulus_form (label); CREATE TABLE mor_obs_annulus_form ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, observed_by_person_id INTEGER, observed_at TEXT, publication_id INTEGER, state_id INTEGER, state_modifier TEXT, free_text_description TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (observed_by_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (state_id) REFERENCES mor_states_annulus_form (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_mor_obs_annulus_form_specimen_id ON mor_obs_annulus_form (specimen_id); CREATE INDEX ix_mor_obs_annulus_form_species_id ON mor_obs_annulus_form (species_id); CREATE TABLE mor_states_volva_form ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_mor_states_volva_form_is_active ON mor_states_volva_form (is_active); CREATE INDEX ix_mor_states_volva_form_label ON mor_states_volva_form (label); CREATE TABLE mor_obs_volva_form ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, observed_by_person_id INTEGER, observed_at TEXT, publication_id INTEGER, state_id INTEGER, state_modifier TEXT, free_text_description TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (observed_by_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (state_id) REFERENCES mor_states_volva_form (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_mor_obs_volva_form_specimen_id ON mor_obs_volva_form (specimen_id); CREATE INDEX ix_mor_obs_volva_form_species_id ON mor_obs_volva_form (species_id); CREATE TABLE mor_states_flesh_color ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_mor_states_flesh_color_is_active ON mor_states_flesh_color (is_active); CREATE INDEX ix_mor_states_flesh_color_label ON mor_states_flesh_color (label); CREATE TABLE mor_obs_flesh_color ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, observed_by_person_id INTEGER, observed_at TEXT, publication_id INTEGER, state_id INTEGER, state_modifier TEXT, free_text_description TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (observed_by_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (state_id) REFERENCES mor_states_flesh_color (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_mor_obs_flesh_color_specimen_id ON mor_obs_flesh_color (specimen_id); CREATE INDEX ix_mor_obs_flesh_color_species_id ON mor_obs_flesh_color (species_id); CREATE TABLE mor_states_flesh_color_change ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_mor_states_flesh_color_change_is_active ON mor_states_flesh_color_change (is_active); CREATE INDEX ix_mor_states_flesh_color_change_label ON mor_states_flesh_color_change (label); CREATE TABLE mor_obs_flesh_color_change ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, observed_by_person_id INTEGER, observed_at TEXT, publication_id INTEGER, state_id INTEGER, state_modifier TEXT, free_text_description TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (observed_by_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (state_id) REFERENCES mor_states_flesh_color_change (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_mor_obs_flesh_color_change_specimen_id ON mor_obs_flesh_color_change (specimen_id); CREATE INDEX ix_mor_obs_flesh_color_change_species_id ON mor_obs_flesh_color_change (species_id); CREATE TABLE mor_states_smell_character ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_mor_states_smell_character_is_active ON mor_states_smell_character (is_active); CREATE INDEX ix_mor_states_smell_character_label ON mor_states_smell_character (label); CREATE TABLE mor_obs_smell_character ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, observed_by_person_id INTEGER, observed_at TEXT, publication_id INTEGER, state_id INTEGER, state_modifier TEXT, free_text_description TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (observed_by_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (state_id) REFERENCES mor_states_smell_character (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_mor_obs_smell_character_specimen_id ON mor_obs_smell_character (specimen_id); CREATE INDEX ix_mor_obs_smell_character_species_id ON mor_obs_smell_character (species_id); CREATE TABLE mor_states_taste_character ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_mor_states_taste_character_is_active ON mor_states_taste_character (is_active); CREATE INDEX ix_mor_states_taste_character_label ON mor_states_taste_character (label); CREATE TABLE mor_obs_taste_character ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, observed_by_person_id INTEGER, observed_at TEXT, publication_id INTEGER, state_id INTEGER, state_modifier TEXT, free_text_description TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (observed_by_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (state_id) REFERENCES mor_states_taste_character (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_mor_obs_taste_character_specimen_id ON mor_obs_taste_character (specimen_id); CREATE INDEX ix_mor_obs_taste_character_species_id ON mor_obs_taste_character (species_id); CREATE TABLE mor_states_latex_color ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_mor_states_latex_color_is_active ON mor_states_latex_color (is_active); CREATE INDEX ix_mor_states_latex_color_label ON mor_states_latex_color (label); CREATE TABLE mor_obs_latex_color ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, observed_by_person_id INTEGER, observed_at TEXT, publication_id INTEGER, state_id INTEGER, state_modifier TEXT, free_text_description TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (observed_by_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (state_id) REFERENCES mor_states_latex_color (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_mor_obs_latex_color_specimen_id ON mor_obs_latex_color (specimen_id); CREATE INDEX ix_mor_obs_latex_color_species_id ON mor_obs_latex_color (species_id); CREATE TABLE mor_states_latex_color_change ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_mor_states_latex_color_change_is_active ON mor_states_latex_color_change (is_active); CREATE INDEX ix_mor_states_latex_color_change_label ON mor_states_latex_color_change (label); CREATE TABLE mor_obs_latex_color_change ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, observed_by_person_id INTEGER, observed_at TEXT, publication_id INTEGER, state_id INTEGER, state_modifier TEXT, free_text_description TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (observed_by_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (state_id) REFERENCES mor_states_latex_color_change (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_mor_obs_latex_color_change_specimen_id ON mor_obs_latex_color_change (specimen_id); CREATE INDEX ix_mor_obs_latex_color_change_species_id ON mor_obs_latex_color_change (species_id); CREATE TABLE mor_states_spore_shape ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_mor_states_spore_shape_is_active ON mor_states_spore_shape (is_active); CREATE INDEX ix_mor_states_spore_shape_label ON mor_states_spore_shape (label); CREATE TABLE mor_obs_spore_shape ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, observed_by_person_id INTEGER, observed_at TEXT, publication_id INTEGER, state_id INTEGER, state_modifier TEXT, free_text_description TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (observed_by_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (state_id) REFERENCES mor_states_spore_shape (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_mor_obs_spore_shape_specimen_id ON mor_obs_spore_shape (specimen_id); CREATE INDEX ix_mor_obs_spore_shape_species_id ON mor_obs_spore_shape (species_id); CREATE TABLE mor_states_spore_ornamentation ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_mor_states_spore_ornamentation_is_active ON mor_states_spore_ornamentation (is_active); CREATE INDEX ix_mor_states_spore_ornamentation_label ON mor_states_spore_ornamentation (label); CREATE TABLE mor_obs_spore_ornamentation ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, observed_by_person_id INTEGER, observed_at TEXT, publication_id INTEGER, state_id INTEGER, state_modifier TEXT, free_text_description TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (observed_by_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (state_id) REFERENCES mor_states_spore_ornamentation (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_mor_obs_spore_ornamentation_specimen_id ON mor_obs_spore_ornamentation (specimen_id); CREATE INDEX ix_mor_obs_spore_ornamentation_species_id ON mor_obs_spore_ornamentation (species_id); CREATE TABLE mor_states_spore_color_in_mass ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_mor_states_spore_color_in_mass_is_active ON mor_states_spore_color_in_mass (is_active); CREATE INDEX ix_mor_states_spore_color_in_mass_label ON mor_states_spore_color_in_mass (label); CREATE TABLE mor_obs_spore_color_in_mass ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, observed_by_person_id INTEGER, observed_at TEXT, publication_id INTEGER, state_id INTEGER, state_modifier TEXT, free_text_description TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (observed_by_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (state_id) REFERENCES mor_states_spore_color_in_mass (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_mor_obs_spore_color_in_mass_specimen_id ON mor_obs_spore_color_in_mass (specimen_id); CREATE INDEX ix_mor_obs_spore_color_in_mass_species_id ON mor_obs_spore_color_in_mass (species_id); CREATE TABLE mor_states_spore_color_in_koh ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_mor_states_spore_color_in_koh_is_active ON mor_states_spore_color_in_koh (is_active); CREATE INDEX ix_mor_states_spore_color_in_koh_label ON mor_states_spore_color_in_koh (label); CREATE TABLE mor_obs_spore_color_in_koh ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, observed_by_person_id INTEGER, observed_at TEXT, publication_id INTEGER, state_id INTEGER, state_modifier TEXT, free_text_description TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (observed_by_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (state_id) REFERENCES mor_states_spore_color_in_koh (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_mor_obs_spore_color_in_koh_specimen_id ON mor_obs_spore_color_in_koh (specimen_id); CREATE INDEX ix_mor_obs_spore_color_in_koh_species_id ON mor_obs_spore_color_in_koh (species_id); CREATE TABLE mor_states_spore_dextrinoid_reaction ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_mor_states_spore_dextrinoid_reaction_is_active ON mor_states_spore_dextrinoid_reaction (is_active); CREATE INDEX ix_mor_states_spore_dextrinoid_reaction_label ON mor_states_spore_dextrinoid_reaction (label); CREATE TABLE mor_obs_spore_dextrinoid_reaction ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, observed_by_person_id INTEGER, observed_at TEXT, publication_id INTEGER, state_id INTEGER, state_modifier TEXT, free_text_description TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (observed_by_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (state_id) REFERENCES mor_states_spore_dextrinoid_reaction (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_mor_obs_spore_dextrinoid_reaction_specimen_id ON mor_obs_spore_dextrinoid_reaction (specimen_id); CREATE INDEX ix_mor_obs_spore_dextrinoid_reaction_species_id ON mor_obs_spore_dextrinoid_reaction (species_id); CREATE TABLE mor_states_spore_germ_pore_present ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_mor_states_spore_germ_pore_present_is_active ON mor_states_spore_germ_pore_present (is_active); CREATE INDEX ix_mor_states_spore_germ_pore_present_label ON mor_states_spore_germ_pore_present (label); CREATE TABLE mor_obs_spore_germ_pore_present ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, observed_by_person_id INTEGER, observed_at TEXT, publication_id INTEGER, state_id INTEGER, state_modifier TEXT, free_text_description TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (observed_by_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (state_id) REFERENCES mor_states_spore_germ_pore_present (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_mor_obs_spore_germ_pore_present_specimen_id ON mor_obs_spore_germ_pore_present (specimen_id); CREATE INDEX ix_mor_obs_spore_germ_pore_present_species_id ON mor_obs_spore_germ_pore_present (species_id); CREATE TABLE mor_states_basidium_shape ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_mor_states_basidium_shape_is_active ON mor_states_basidium_shape (is_active); CREATE INDEX ix_mor_states_basidium_shape_label ON mor_states_basidium_shape (label); CREATE TABLE mor_obs_basidium_shape ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, observed_by_person_id INTEGER, observed_at TEXT, publication_id INTEGER, state_id INTEGER, state_modifier TEXT, free_text_description TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (observed_by_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (state_id) REFERENCES mor_states_basidium_shape (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_mor_obs_basidium_shape_specimen_id ON mor_obs_basidium_shape (specimen_id); CREATE INDEX ix_mor_obs_basidium_shape_species_id ON mor_obs_basidium_shape (species_id); CREATE TABLE mor_obs_basidium_n_spores ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, observed_by_person_id INTEGER, observed_at TEXT, publication_id INTEGER, value_min REAL, value_max REAL, value_mean REAL, value_unit TEXT, sample_size_n INTEGER, free_text_description TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (observed_by_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_mor_obs_basidium_n_spores_specimen_id ON mor_obs_basidium_n_spores (specimen_id); CREATE INDEX ix_mor_obs_basidium_n_spores_species_id ON mor_obs_basidium_n_spores (species_id); CREATE TABLE mor_states_ascus_type ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_mor_states_ascus_type_is_active ON mor_states_ascus_type (is_active); CREATE INDEX ix_mor_states_ascus_type_label ON mor_states_ascus_type (label); CREATE TABLE mor_obs_ascus_type ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, observed_by_person_id INTEGER, observed_at TEXT, publication_id INTEGER, state_id INTEGER, state_modifier TEXT, free_text_description TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (observed_by_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (state_id) REFERENCES mor_states_ascus_type (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_mor_obs_ascus_type_specimen_id ON mor_obs_ascus_type (specimen_id); CREATE INDEX ix_mor_obs_ascus_type_species_id ON mor_obs_ascus_type (species_id); CREATE TABLE mor_states_ascus_apical_apparatus ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_mor_states_ascus_apical_apparatus_is_active ON mor_states_ascus_apical_apparatus (is_active); CREATE INDEX ix_mor_states_ascus_apical_apparatus_label ON mor_states_ascus_apical_apparatus (label); CREATE TABLE mor_obs_ascus_apical_apparatus ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, observed_by_person_id INTEGER, observed_at TEXT, publication_id INTEGER, state_id INTEGER, state_modifier TEXT, free_text_description TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (observed_by_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (state_id) REFERENCES mor_states_ascus_apical_apparatus (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_mor_obs_ascus_apical_apparatus_specimen_id ON mor_obs_ascus_apical_apparatus (specimen_id); CREATE INDEX ix_mor_obs_ascus_apical_apparatus_species_id ON mor_obs_ascus_apical_apparatus (species_id); CREATE TABLE mor_states_paraphysis_shape ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_mor_states_paraphysis_shape_is_active ON mor_states_paraphysis_shape (is_active); CREATE INDEX ix_mor_states_paraphysis_shape_label ON mor_states_paraphysis_shape (label); CREATE TABLE mor_obs_paraphysis_shape ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, observed_by_person_id INTEGER, observed_at TEXT, publication_id INTEGER, state_id INTEGER, state_modifier TEXT, free_text_description TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (observed_by_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (state_id) REFERENCES mor_states_paraphysis_shape (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_mor_obs_paraphysis_shape_specimen_id ON mor_obs_paraphysis_shape (specimen_id); CREATE INDEX ix_mor_obs_paraphysis_shape_species_id ON mor_obs_paraphysis_shape (species_id); CREATE TABLE mor_states_cystidium_location ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_mor_states_cystidium_location_is_active ON mor_states_cystidium_location (is_active); CREATE INDEX ix_mor_states_cystidium_location_label ON mor_states_cystidium_location (label); CREATE TABLE mor_obs_cystidium_location ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, observed_by_person_id INTEGER, observed_at TEXT, publication_id INTEGER, state_id INTEGER, state_modifier TEXT, free_text_description TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (observed_by_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (state_id) REFERENCES mor_states_cystidium_location (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_mor_obs_cystidium_location_specimen_id ON mor_obs_cystidium_location (specimen_id); CREATE INDEX ix_mor_obs_cystidium_location_species_id ON mor_obs_cystidium_location (species_id); CREATE TABLE mor_states_cystidium_shape ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_mor_states_cystidium_shape_is_active ON mor_states_cystidium_shape (is_active); CREATE INDEX ix_mor_states_cystidium_shape_label ON mor_states_cystidium_shape (label); CREATE TABLE mor_obs_cystidium_shape ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, observed_by_person_id INTEGER, observed_at TEXT, publication_id INTEGER, state_id INTEGER, state_modifier TEXT, free_text_description TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (observed_by_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (state_id) REFERENCES mor_states_cystidium_shape (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_mor_obs_cystidium_shape_specimen_id ON mor_obs_cystidium_shape (specimen_id); CREATE INDEX ix_mor_obs_cystidium_shape_species_id ON mor_obs_cystidium_shape (species_id); CREATE TABLE mor_states_hyphal_system ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_mor_states_hyphal_system_is_active ON mor_states_hyphal_system (is_active); CREATE INDEX ix_mor_states_hyphal_system_label ON mor_states_hyphal_system (label); CREATE TABLE mor_obs_hyphal_system ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, observed_by_person_id INTEGER, observed_at TEXT, publication_id INTEGER, state_id INTEGER, state_modifier TEXT, free_text_description TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (observed_by_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (state_id) REFERENCES mor_states_hyphal_system (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_mor_obs_hyphal_system_specimen_id ON mor_obs_hyphal_system (specimen_id); CREATE INDEX ix_mor_obs_hyphal_system_species_id ON mor_obs_hyphal_system (species_id); CREATE TABLE mor_states_hyphal_clamp_connections ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_mor_states_hyphal_clamp_connections_is_active ON mor_states_hyphal_clamp_connections (is_active); CREATE INDEX ix_mor_states_hyphal_clamp_connections_label ON mor_states_hyphal_clamp_connections (label); CREATE TABLE mor_obs_hyphal_clamp_connections ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, observed_by_person_id INTEGER, observed_at TEXT, publication_id INTEGER, state_id INTEGER, state_modifier TEXT, free_text_description TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (observed_by_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (state_id) REFERENCES mor_states_hyphal_clamp_connections (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_mor_obs_hyphal_clamp_connections_specimen_id ON mor_obs_hyphal_clamp_connections (specimen_id); CREATE INDEX ix_mor_obs_hyphal_clamp_connections_species_id ON mor_obs_hyphal_clamp_connections (species_id); CREATE TABLE mor_states_hyphal_inflation ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_mor_states_hyphal_inflation_is_active ON mor_states_hyphal_inflation (is_active); CREATE INDEX ix_mor_states_hyphal_inflation_label ON mor_states_hyphal_inflation (label); CREATE TABLE mor_obs_hyphal_inflation ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, observed_by_person_id INTEGER, observed_at TEXT, publication_id INTEGER, state_id INTEGER, state_modifier TEXT, free_text_description TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (observed_by_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (state_id) REFERENCES mor_states_hyphal_inflation (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_mor_obs_hyphal_inflation_specimen_id ON mor_obs_hyphal_inflation (specimen_id); CREATE INDEX ix_mor_obs_hyphal_inflation_species_id ON mor_obs_hyphal_inflation (species_id); CREATE TABLE mor_states_subhymenium_structure ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_mor_states_subhymenium_structure_is_active ON mor_states_subhymenium_structure (is_active); CREATE INDEX ix_mor_states_subhymenium_structure_label ON mor_states_subhymenium_structure (label); CREATE TABLE mor_obs_subhymenium_structure ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, observed_by_person_id INTEGER, observed_at TEXT, publication_id INTEGER, state_id INTEGER, state_modifier TEXT, free_text_description TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (observed_by_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (state_id) REFERENCES mor_states_subhymenium_structure (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_mor_obs_subhymenium_structure_specimen_id ON mor_obs_subhymenium_structure (specimen_id); CREATE INDEX ix_mor_obs_subhymenium_structure_species_id ON mor_obs_subhymenium_structure (species_id); CREATE TABLE mor_states_trama_type ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_mor_states_trama_type_is_active ON mor_states_trama_type (is_active); CREATE INDEX ix_mor_states_trama_type_label ON mor_states_trama_type (label); CREATE TABLE mor_obs_trama_type ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, observed_by_person_id INTEGER, observed_at TEXT, publication_id INTEGER, state_id INTEGER, state_modifier TEXT, free_text_description TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (observed_by_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (state_id) REFERENCES mor_states_trama_type (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_mor_obs_trama_type_specimen_id ON mor_obs_trama_type (specimen_id); CREATE INDEX ix_mor_obs_trama_type_species_id ON mor_obs_trama_type (species_id); CREATE TABLE mor_states_pileipellis_type ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_mor_states_pileipellis_type_is_active ON mor_states_pileipellis_type (is_active); CREATE INDEX ix_mor_states_pileipellis_type_label ON mor_states_pileipellis_type (label); CREATE TABLE mor_obs_pileipellis_type ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, observed_by_person_id INTEGER, observed_at TEXT, publication_id INTEGER, state_id INTEGER, state_modifier TEXT, free_text_description TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (observed_by_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (state_id) REFERENCES mor_states_pileipellis_type (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_mor_obs_pileipellis_type_specimen_id ON mor_obs_pileipellis_type (specimen_id); CREATE INDEX ix_mor_obs_pileipellis_type_species_id ON mor_obs_pileipellis_type (species_id); CREATE TABLE mor_states_rhizomorph_anatomy ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_mor_states_rhizomorph_anatomy_is_active ON mor_states_rhizomorph_anatomy (is_active); CREATE INDEX ix_mor_states_rhizomorph_anatomy_label ON mor_states_rhizomorph_anatomy (label); CREATE TABLE mor_obs_rhizomorph_anatomy ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, observed_by_person_id INTEGER, observed_at TEXT, publication_id INTEGER, state_id INTEGER, state_modifier TEXT, free_text_description TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (observed_by_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (state_id) REFERENCES mor_states_rhizomorph_anatomy (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_mor_obs_rhizomorph_anatomy_specimen_id ON mor_obs_rhizomorph_anatomy (specimen_id); CREATE INDEX ix_mor_obs_rhizomorph_anatomy_species_id ON mor_obs_rhizomorph_anatomy (species_id); CREATE TABLE mor_states_conidium_shape ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_mor_states_conidium_shape_is_active ON mor_states_conidium_shape (is_active); CREATE INDEX ix_mor_states_conidium_shape_label ON mor_states_conidium_shape (label); CREATE TABLE mor_obs_conidium_shape ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, observed_by_person_id INTEGER, observed_at TEXT, publication_id INTEGER, state_id INTEGER, state_modifier TEXT, free_text_description TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (observed_by_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (state_id) REFERENCES mor_states_conidium_shape (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_mor_obs_conidium_shape_specimen_id ON mor_obs_conidium_shape (specimen_id); CREATE INDEX ix_mor_obs_conidium_shape_species_id ON mor_obs_conidium_shape (species_id); CREATE TABLE mor_states_conidiogenous_cell_type ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_mor_states_conidiogenous_cell_type_is_active ON mor_states_conidiogenous_cell_type (is_active); CREATE INDEX ix_mor_states_conidiogenous_cell_type_label ON mor_states_conidiogenous_cell_type (label); CREATE TABLE mor_obs_conidiogenous_cell_type ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, observed_by_person_id INTEGER, observed_at TEXT, publication_id INTEGER, state_id INTEGER, state_modifier TEXT, free_text_description TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (observed_by_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (state_id) REFERENCES mor_states_conidiogenous_cell_type (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_mor_obs_conidiogenous_cell_type_specimen_id ON mor_obs_conidiogenous_cell_type (specimen_id); CREATE INDEX ix_mor_obs_conidiogenous_cell_type_species_id ON mor_obs_conidiogenous_cell_type (species_id); CREATE TABLE mor_chemical_reactions ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, anatomical_part TEXT NOT NULL, reagent_id INTEGER NOT NULL, reaction_color_chip_id INTEGER, reaction_text TEXT, reaction_kind TEXT, observed_at TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (reagent_id) REFERENCES mor_chemical_reagents (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (reaction_color_chip_id) REFERENCES mor_color_chips (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_mor_chemical_reactions_specimen_id ON mor_chemical_reactions (specimen_id); CREATE INDEX ix_mor_chemical_reactions_reagent_id ON mor_chemical_reactions (reagent_id); CREATE TABLE eco_habitat_types ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_eco_habitat_types_is_active ON eco_habitat_types (is_active); CREATE INDEX ix_eco_habitat_types_label ON eco_habitat_types (label); CREATE TABLE eco_substrate_types ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_eco_substrate_types_is_active ON eco_substrate_types (is_active); CREATE INDEX ix_eco_substrate_types_label ON eco_substrate_types (label); CREATE TABLE eco_phenology_seasons ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_eco_phenology_seasons_is_active ON eco_phenology_seasons (is_active); CREATE INDEX ix_eco_phenology_seasons_label ON eco_phenology_seasons (label); CREATE TABLE eco_species_habitat_associations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, habitat_type_id INTEGER NOT NULL, frequency TEXT, evidence_publication_id INTEGER, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (habitat_type_id) REFERENCES eco_habitat_types (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (evidence_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (species_id, habitat_type_id) ); CREATE TABLE eco_species_substrate_associations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, substrate_type_id INTEGER NOT NULL, association_strength TEXT, evidence_publication_id INTEGER, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (substrate_type_id) REFERENCES eco_substrate_types (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (evidence_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (species_id, substrate_type_id) ); CREATE TABLE eco_mycorrhiza_types ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_eco_mycorrhiza_types_is_active ON eco_mycorrhiza_types (is_active); CREATE INDEX ix_eco_mycorrhiza_types_label ON eco_mycorrhiza_types (label); CREATE TABLE eco_plant_partners ( id INTEGER PRIMARY KEY AUTOINCREMENT, plant_family TEXT NOT NULL, plant_genus TEXT, plant_species TEXT, plant_common_name TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (plant_family, plant_genus, plant_species) ); CREATE INDEX ix_eco_plant_partners_plant_family ON eco_plant_partners (plant_family); CREATE INDEX ix_eco_plant_partners_plant_genus ON eco_plant_partners (plant_genus); CREATE TABLE eco_mycorrhiza_ectomycorrhizal ( id INTEGER PRIMARY KEY AUTOINCREMENT, fungal_species_id INTEGER NOT NULL, plant_partner_id INTEGER NOT NULL, evidence_specimen_id INTEGER, evidence_publication_id INTEGER, first_reported_year INTEGER, association_specificity TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (fungal_species_id) REFERENCES tax_species (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (plant_partner_id) REFERENCES eco_plant_partners (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (evidence_specimen_id) REFERENCES spc_specimens (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (evidence_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (fungal_species_id, plant_partner_id) ); CREATE INDEX ix_eco_mycorrhiza_ectomycorrhizal_fungal_species_id ON eco_mycorrhiza_ectomycorrhizal (fungal_species_id); CREATE INDEX ix_eco_mycorrhiza_ectomycorrhizal_plant_partner_id ON eco_mycorrhiza_ectomycorrhizal (plant_partner_id); CREATE TABLE eco_mycorrhiza_arbuscular ( id INTEGER PRIMARY KEY AUTOINCREMENT, fungal_species_id INTEGER NOT NULL, plant_partner_id INTEGER NOT NULL, evidence_specimen_id INTEGER, evidence_publication_id INTEGER, first_reported_year INTEGER, association_specificity TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (fungal_species_id) REFERENCES tax_species (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (plant_partner_id) REFERENCES eco_plant_partners (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (evidence_specimen_id) REFERENCES spc_specimens (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (evidence_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (fungal_species_id, plant_partner_id) ); CREATE INDEX ix_eco_mycorrhiza_arbuscular_fungal_species_id ON eco_mycorrhiza_arbuscular (fungal_species_id); CREATE INDEX ix_eco_mycorrhiza_arbuscular_plant_partner_id ON eco_mycorrhiza_arbuscular (plant_partner_id); CREATE TABLE eco_mycorrhiza_ericoid ( id INTEGER PRIMARY KEY AUTOINCREMENT, fungal_species_id INTEGER NOT NULL, plant_partner_id INTEGER NOT NULL, evidence_specimen_id INTEGER, evidence_publication_id INTEGER, first_reported_year INTEGER, association_specificity TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (fungal_species_id) REFERENCES tax_species (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (plant_partner_id) REFERENCES eco_plant_partners (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (evidence_specimen_id) REFERENCES spc_specimens (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (evidence_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (fungal_species_id, plant_partner_id) ); CREATE INDEX ix_eco_mycorrhiza_ericoid_fungal_species_id ON eco_mycorrhiza_ericoid (fungal_species_id); CREATE INDEX ix_eco_mycorrhiza_ericoid_plant_partner_id ON eco_mycorrhiza_ericoid (plant_partner_id); CREATE TABLE eco_mycorrhiza_orchid ( id INTEGER PRIMARY KEY AUTOINCREMENT, fungal_species_id INTEGER NOT NULL, plant_partner_id INTEGER NOT NULL, evidence_specimen_id INTEGER, evidence_publication_id INTEGER, first_reported_year INTEGER, association_specificity TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (fungal_species_id) REFERENCES tax_species (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (plant_partner_id) REFERENCES eco_plant_partners (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (evidence_specimen_id) REFERENCES spc_specimens (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (evidence_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (fungal_species_id, plant_partner_id) ); CREATE INDEX ix_eco_mycorrhiza_orchid_fungal_species_id ON eco_mycorrhiza_orchid (fungal_species_id); CREATE INDEX ix_eco_mycorrhiza_orchid_plant_partner_id ON eco_mycorrhiza_orchid (plant_partner_id); CREATE TABLE eco_mycorrhiza_monotropoid ( id INTEGER PRIMARY KEY AUTOINCREMENT, fungal_species_id INTEGER NOT NULL, plant_partner_id INTEGER NOT NULL, evidence_specimen_id INTEGER, evidence_publication_id INTEGER, first_reported_year INTEGER, association_specificity TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (fungal_species_id) REFERENCES tax_species (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (plant_partner_id) REFERENCES eco_plant_partners (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (evidence_specimen_id) REFERENCES spc_specimens (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (evidence_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (fungal_species_id, plant_partner_id) ); CREATE INDEX ix_eco_mycorrhiza_monotropoid_fungal_species_id ON eco_mycorrhiza_monotropoid (fungal_species_id); CREATE INDEX ix_eco_mycorrhiza_monotropoid_plant_partner_id ON eco_mycorrhiza_monotropoid (plant_partner_id); CREATE TABLE eco_mycorrhiza_arbutoid ( id INTEGER PRIMARY KEY AUTOINCREMENT, fungal_species_id INTEGER NOT NULL, plant_partner_id INTEGER NOT NULL, evidence_specimen_id INTEGER, evidence_publication_id INTEGER, first_reported_year INTEGER, association_specificity TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (fungal_species_id) REFERENCES tax_species (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (plant_partner_id) REFERENCES eco_plant_partners (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (evidence_specimen_id) REFERENCES spc_specimens (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (evidence_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (fungal_species_id, plant_partner_id) ); CREATE INDEX ix_eco_mycorrhiza_arbutoid_fungal_species_id ON eco_mycorrhiza_arbutoid (fungal_species_id); CREATE INDEX ix_eco_mycorrhiza_arbutoid_plant_partner_id ON eco_mycorrhiza_arbutoid (plant_partner_id); CREATE TABLE eco_mycorrhiza_ectendomycorrhizal ( id INTEGER PRIMARY KEY AUTOINCREMENT, fungal_species_id INTEGER NOT NULL, plant_partner_id INTEGER NOT NULL, evidence_specimen_id INTEGER, evidence_publication_id INTEGER, first_reported_year INTEGER, association_specificity TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (fungal_species_id) REFERENCES tax_species (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (plant_partner_id) REFERENCES eco_plant_partners (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (evidence_specimen_id) REFERENCES spc_specimens (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (evidence_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (fungal_species_id, plant_partner_id) ); CREATE INDEX ix_eco_mycorrhiza_ectendomycorrhizal_fungal_species_id ON eco_mycorrhiza_ectendomycorrhizal (fungal_species_id); CREATE INDEX ix_eco_mycorrhiza_ectendomycorrhizal_plant_partner_id ON eco_mycorrhiza_ectendomycorrhizal (plant_partner_id); CREATE TABLE eco_phenology_observations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, locality_id INTEGER, observation_year INTEGER, first_fruit_doy INTEGER CHECK (first_fruit_doy BETWEEN 1 AND 366), peak_fruit_doy INTEGER CHECK (peak_fruit_doy BETWEEN 1 AND 366), last_fruit_doy INTEGER CHECK (last_fruit_doy BETWEEN 1 AND 366), season_id INTEGER, data_source TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (locality_id) REFERENCES geo_localities (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (season_id) REFERENCES eco_phenology_seasons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_eco_phenology_observations_species_id ON eco_phenology_observations (species_id); CREATE INDEX ix_eco_phenology_observations_observation_year ON eco_phenology_observations (observation_year); CREATE TABLE eco_iucn_assessments ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, assessment_year INTEGER NOT NULL, category TEXT NOT NULL CHECK (category IN ('LC','NT','VU','EN','CR','EW','EX','DD','NE')), criteria TEXT, rationale TEXT, publication_id INTEGER, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (species_id, assessment_year) ); CREATE INDEX ix_eco_iucn_assessments_category ON eco_iucn_assessments (category); CREATE INDEX ix_eco_iucn_assessments_assessment_year ON eco_iucn_assessments (assessment_year); CREATE TABLE gen_sequencing_platforms ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_gen_sequencing_platforms_is_active ON gen_sequencing_platforms (is_active); CREATE INDEX ix_gen_sequencing_platforms_label ON gen_sequencing_platforms (label); CREATE TABLE gen_library_kit_types ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_gen_library_kit_types_is_active ON gen_library_kit_types (is_active); CREATE INDEX ix_gen_library_kit_types_label ON gen_library_kit_types (label); CREATE TABLE gen_assembly_software ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_gen_assembly_software_is_active ON gen_assembly_software (is_active); CREATE INDEX ix_gen_assembly_software_label ON gen_assembly_software (label); CREATE TABLE gen_alignment_software ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_gen_alignment_software_is_active ON gen_alignment_software (is_active); CREATE INDEX ix_gen_alignment_software_label ON gen_alignment_software (label); CREATE TABLE gen_dna_extracts ( id INTEGER PRIMARY KEY AUTOINCREMENT, uuid TEXT NOT NULL DEFAULT (lower(hex(randomblob(4))) || '-' || lower(hex(randomblob(2))) || '-4' || substr(lower(hex(randomblob(2))),2) || '-' || substr('89ab',abs(random()) % 4 + 1, 1) || substr(lower(hex(randomblob(2))),2) || '-' || lower(hex(randomblob(6)))), specimen_id INTEGER NOT NULL, extract_code TEXT NOT NULL, extracted_at TEXT, extracted_by_person_id INTEGER, extraction_kit TEXT, concentration_ng_per_ul REAL, a260_a280_ratio REAL, a260_a230_ratio REAL, storage_location TEXT, is_depleted INTEGER NOT NULL DEFAULT 0, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (extracted_by_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (extract_code) ); CREATE INDEX ix_gen_dna_extracts_specimen_id ON gen_dna_extracts (specimen_id); CREATE TABLE gen_libraries ( id INTEGER PRIMARY KEY AUTOINCREMENT, dna_extract_id INTEGER NOT NULL, library_code TEXT NOT NULL, kit_type_id INTEGER, insert_size_mean_bp INTEGER, library_concentration_nm REAL, prepared_at TEXT, prepared_by_person_id INTEGER, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (dna_extract_id) REFERENCES gen_dna_extracts (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (kit_type_id) REFERENCES gen_library_kit_types (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (prepared_by_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (library_code) ); CREATE TABLE gen_sequencing_runs ( id INTEGER PRIMARY KEY AUTOINCREMENT, run_code TEXT NOT NULL, platform_id INTEGER NOT NULL, instrument_serial TEXT, run_started_at TEXT, run_finished_at TEXT, flow_cell_id TEXT, read_length_cycles INTEGER, operator_user_id INTEGER, output_yield_gb REAL, q30_percent REAL, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (platform_id) REFERENCES gen_sequencing_platforms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (operator_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (run_code) ); CREATE TABLE gen_run_libraries ( run_id INTEGER NOT NULL, library_id INTEGER NOT NULL, barcode_index TEXT, read_count INTEGER, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, PRIMARY KEY (run_id, library_id), FOREIGN KEY (run_id) REFERENCES gen_sequencing_runs (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (library_id) REFERENCES gen_libraries (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_gen_run_libraries_library_id ON gen_run_libraries (library_id); CREATE TABLE gen_sequences ( id INTEGER PRIMARY KEY AUTOINCREMENT, uuid TEXT NOT NULL DEFAULT (lower(hex(randomblob(4))) || '-' || lower(hex(randomblob(2))) || '-4' || substr(lower(hex(randomblob(2))),2) || '-' || substr('89ab',abs(random()) % 4 + 1, 1) || substr(lower(hex(randomblob(2))),2) || '-' || lower(hex(randomblob(6)))), specimen_id INTEGER, dna_extract_id INTEGER, library_id INTEGER, locus TEXT, genbank_accession TEXT, sequence_md5 TEXT NOT NULL, length_bp INTEGER NOT NULL, gc_content_pct REAL, sequence_text TEXT NOT NULL, sequence_quality_text TEXT, submitted_to_genbank_at TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dna_extract_id) REFERENCES gen_dna_extracts (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (library_id) REFERENCES gen_libraries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (genbank_accession), UNIQUE (sequence_md5, locus) ); CREATE INDEX ix_gen_sequences_locus ON gen_sequences (locus); CREATE INDEX ix_gen_sequences_specimen_id ON gen_sequences (specimen_id); CREATE INDEX ix_gen_sequences_genbank_accession ON gen_sequences (genbank_accession); CREATE TABLE gen_assemblies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER, specimen_id INTEGER, strain_code TEXT, assembly_code TEXT NOT NULL, assembly_software_id INTEGER, assembly_software_version TEXT, genome_size_bp INTEGER, contig_n50_bp INTEGER, scaffold_count INTEGER, busco_complete_pct REAL, ncbi_assembly_accession TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (assembly_software_id) REFERENCES gen_assembly_software (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (assembly_code), UNIQUE (ncbi_assembly_accession) ); CREATE TABLE gen_genes ( id INTEGER PRIMARY KEY AUTOINCREMENT, assembly_id INTEGER NOT NULL, gene_symbol TEXT, locus_tag TEXT, scaffold_name TEXT, start_bp INTEGER, end_bp INTEGER, strand TEXT CHECK (strand IN ('+','-')), product_description TEXT, ec_number TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (assembly_id) REFERENCES gen_assemblies (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_gen_genes_assembly_id ON gen_genes (assembly_id); CREATE INDEX ix_gen_genes_locus_tag ON gen_genes (locus_tag); CREATE INDEX ix_gen_genes_gene_symbol ON gen_genes (gene_symbol); CREATE TABLE gen_proteins ( id INTEGER PRIMARY KEY AUTOINCREMENT, gene_id INTEGER NOT NULL, uniprot_accession TEXT, length_aa INTEGER, molecular_weight_da REAL, isoelectric_point REAL, amino_acid_sequence TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (gene_id) REFERENCES gen_genes (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (uniprot_accession) ); CREATE TABLE gen_orthogroups ( id INTEGER PRIMARY KEY AUTOINCREMENT, orthogroup_code TEXT NOT NULL, inferred_by_software TEXT, species_count INTEGER, gene_count INTEGER, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (orthogroup_code) ); CREATE TABLE gen_orthogroup_members ( orthogroup_id INTEGER NOT NULL, protein_id INTEGER NOT NULL, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, PRIMARY KEY (orthogroup_id, protein_id), FOREIGN KEY (orthogroup_id) REFERENCES gen_orthogroups (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (protein_id) REFERENCES gen_proteins (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_gen_orthogroup_members_protein_id ON gen_orthogroup_members (protein_id); CREATE TABLE gen_variants ( id INTEGER PRIMARY KEY AUTOINCREMENT, assembly_id INTEGER NOT NULL, scaffold_name TEXT NOT NULL, position_bp INTEGER NOT NULL, ref_allele TEXT NOT NULL, alt_allele TEXT NOT NULL, variant_type TEXT NOT NULL CHECK (variant_type IN ('SNP','INS','DEL','MNP','SV')), quality_score REAL, annotation_impact TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (assembly_id) REFERENCES gen_assemblies (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_gen_variants_assembly_id_scaffold_name_position_bp ON gen_variants (assembly_id, scaffold_name, position_bp); CREATE INDEX ix_gen_variants_variant_type ON gen_variants (variant_type); CREATE TABLE gen_marker_its_sequences ( id INTEGER PRIMARY KEY AUTOINCREMENT, sequence_id INTEGER NOT NULL, species_id INTEGER, specimen_id INTEGER, trimmed_length_bp INTEGER, aligned_length_bp INTEGER, is_reference INTEGER NOT NULL DEFAULT 0, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (sequence_id) REFERENCES gen_sequences (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE TABLE gen_marker_its_alignments ( id INTEGER PRIMARY KEY AUTOINCREMENT, alignment_code TEXT NOT NULL, software_id INTEGER, software_version TEXT, n_sequences INTEGER, alignment_length_bp INTEGER, trimmed_with TEXT, created_by_person_id INTEGER, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (software_id) REFERENCES gen_alignment_software (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (alignment_code) ); CREATE TABLE gen_marker_its_alignment_members ( alignment_id INTEGER NOT NULL, marker_sequence_id INTEGER NOT NULL, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, PRIMARY KEY (alignment_id, marker_sequence_id), FOREIGN KEY (alignment_id) REFERENCES gen_marker_its_alignments (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (marker_sequence_id) REFERENCES gen_marker_its_sequences (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_gen_marker_its_alignment_members_marker_sequence_id ON gen_marker_its_alignment_members (marker_sequence_id); CREATE TABLE gen_marker_its_consensus ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, alignment_id INTEGER, consensus_length_bp INTEGER, consensus_sequence TEXT NOT NULL, ambiguity_threshold_pct REAL, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (alignment_id) REFERENCES gen_marker_its_alignments (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (species_id, alignment_id) ); CREATE TABLE gen_marker_lsu_sequences ( id INTEGER PRIMARY KEY AUTOINCREMENT, sequence_id INTEGER NOT NULL, species_id INTEGER, specimen_id INTEGER, trimmed_length_bp INTEGER, aligned_length_bp INTEGER, is_reference INTEGER NOT NULL DEFAULT 0, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (sequence_id) REFERENCES gen_sequences (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE TABLE gen_marker_lsu_alignments ( id INTEGER PRIMARY KEY AUTOINCREMENT, alignment_code TEXT NOT NULL, software_id INTEGER, software_version TEXT, n_sequences INTEGER, alignment_length_bp INTEGER, trimmed_with TEXT, created_by_person_id INTEGER, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (software_id) REFERENCES gen_alignment_software (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (alignment_code) ); CREATE TABLE gen_marker_lsu_alignment_members ( alignment_id INTEGER NOT NULL, marker_sequence_id INTEGER NOT NULL, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, PRIMARY KEY (alignment_id, marker_sequence_id), FOREIGN KEY (alignment_id) REFERENCES gen_marker_lsu_alignments (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (marker_sequence_id) REFERENCES gen_marker_lsu_sequences (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_gen_marker_lsu_alignment_members_marker_sequence_id ON gen_marker_lsu_alignment_members (marker_sequence_id); CREATE TABLE gen_marker_lsu_consensus ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, alignment_id INTEGER, consensus_length_bp INTEGER, consensus_sequence TEXT NOT NULL, ambiguity_threshold_pct REAL, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (alignment_id) REFERENCES gen_marker_lsu_alignments (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (species_id, alignment_id) ); CREATE TABLE gen_marker_ssu_sequences ( id INTEGER PRIMARY KEY AUTOINCREMENT, sequence_id INTEGER NOT NULL, species_id INTEGER, specimen_id INTEGER, trimmed_length_bp INTEGER, aligned_length_bp INTEGER, is_reference INTEGER NOT NULL DEFAULT 0, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (sequence_id) REFERENCES gen_sequences (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE TABLE gen_marker_ssu_alignments ( id INTEGER PRIMARY KEY AUTOINCREMENT, alignment_code TEXT NOT NULL, software_id INTEGER, software_version TEXT, n_sequences INTEGER, alignment_length_bp INTEGER, trimmed_with TEXT, created_by_person_id INTEGER, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (software_id) REFERENCES gen_alignment_software (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (alignment_code) ); CREATE TABLE gen_marker_ssu_alignment_members ( alignment_id INTEGER NOT NULL, marker_sequence_id INTEGER NOT NULL, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, PRIMARY KEY (alignment_id, marker_sequence_id), FOREIGN KEY (alignment_id) REFERENCES gen_marker_ssu_alignments (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (marker_sequence_id) REFERENCES gen_marker_ssu_sequences (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_gen_marker_ssu_alignment_members_marker_sequence_id ON gen_marker_ssu_alignment_members (marker_sequence_id); CREATE TABLE gen_marker_ssu_consensus ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, alignment_id INTEGER, consensus_length_bp INTEGER, consensus_sequence TEXT NOT NULL, ambiguity_threshold_pct REAL, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (alignment_id) REFERENCES gen_marker_ssu_alignments (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (species_id, alignment_id) ); CREATE TABLE gen_marker_rpb1_sequences ( id INTEGER PRIMARY KEY AUTOINCREMENT, sequence_id INTEGER NOT NULL, species_id INTEGER, specimen_id INTEGER, trimmed_length_bp INTEGER, aligned_length_bp INTEGER, is_reference INTEGER NOT NULL DEFAULT 0, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (sequence_id) REFERENCES gen_sequences (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE TABLE gen_marker_rpb1_alignments ( id INTEGER PRIMARY KEY AUTOINCREMENT, alignment_code TEXT NOT NULL, software_id INTEGER, software_version TEXT, n_sequences INTEGER, alignment_length_bp INTEGER, trimmed_with TEXT, created_by_person_id INTEGER, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (software_id) REFERENCES gen_alignment_software (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (alignment_code) ); CREATE TABLE gen_marker_rpb1_alignment_members ( alignment_id INTEGER NOT NULL, marker_sequence_id INTEGER NOT NULL, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, PRIMARY KEY (alignment_id, marker_sequence_id), FOREIGN KEY (alignment_id) REFERENCES gen_marker_rpb1_alignments (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (marker_sequence_id) REFERENCES gen_marker_rpb1_sequences (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_gen_marker_rpb1_alignment_members_marker_sequence_id ON gen_marker_rpb1_alignment_members (marker_sequence_id); CREATE TABLE gen_marker_rpb1_consensus ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, alignment_id INTEGER, consensus_length_bp INTEGER, consensus_sequence TEXT NOT NULL, ambiguity_threshold_pct REAL, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (alignment_id) REFERENCES gen_marker_rpb1_alignments (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (species_id, alignment_id) ); CREATE TABLE gen_marker_rpb2_sequences ( id INTEGER PRIMARY KEY AUTOINCREMENT, sequence_id INTEGER NOT NULL, species_id INTEGER, specimen_id INTEGER, trimmed_length_bp INTEGER, aligned_length_bp INTEGER, is_reference INTEGER NOT NULL DEFAULT 0, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (sequence_id) REFERENCES gen_sequences (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE TABLE gen_marker_rpb2_alignments ( id INTEGER PRIMARY KEY AUTOINCREMENT, alignment_code TEXT NOT NULL, software_id INTEGER, software_version TEXT, n_sequences INTEGER, alignment_length_bp INTEGER, trimmed_with TEXT, created_by_person_id INTEGER, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (software_id) REFERENCES gen_alignment_software (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (alignment_code) ); CREATE TABLE gen_marker_rpb2_alignment_members ( alignment_id INTEGER NOT NULL, marker_sequence_id INTEGER NOT NULL, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, PRIMARY KEY (alignment_id, marker_sequence_id), FOREIGN KEY (alignment_id) REFERENCES gen_marker_rpb2_alignments (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (marker_sequence_id) REFERENCES gen_marker_rpb2_sequences (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_gen_marker_rpb2_alignment_members_marker_sequence_id ON gen_marker_rpb2_alignment_members (marker_sequence_id); CREATE TABLE gen_marker_rpb2_consensus ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, alignment_id INTEGER, consensus_length_bp INTEGER, consensus_sequence TEXT NOT NULL, ambiguity_threshold_pct REAL, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (alignment_id) REFERENCES gen_marker_rpb2_alignments (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (species_id, alignment_id) ); CREATE TABLE gen_marker_ef1a_sequences ( id INTEGER PRIMARY KEY AUTOINCREMENT, sequence_id INTEGER NOT NULL, species_id INTEGER, specimen_id INTEGER, trimmed_length_bp INTEGER, aligned_length_bp INTEGER, is_reference INTEGER NOT NULL DEFAULT 0, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (sequence_id) REFERENCES gen_sequences (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE TABLE gen_marker_ef1a_alignments ( id INTEGER PRIMARY KEY AUTOINCREMENT, alignment_code TEXT NOT NULL, software_id INTEGER, software_version TEXT, n_sequences INTEGER, alignment_length_bp INTEGER, trimmed_with TEXT, created_by_person_id INTEGER, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (software_id) REFERENCES gen_alignment_software (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (alignment_code) ); CREATE TABLE gen_marker_ef1a_alignment_members ( alignment_id INTEGER NOT NULL, marker_sequence_id INTEGER NOT NULL, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, PRIMARY KEY (alignment_id, marker_sequence_id), FOREIGN KEY (alignment_id) REFERENCES gen_marker_ef1a_alignments (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (marker_sequence_id) REFERENCES gen_marker_ef1a_sequences (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_gen_marker_ef1a_alignment_members_marker_sequence_id ON gen_marker_ef1a_alignment_members (marker_sequence_id); CREATE TABLE gen_marker_ef1a_consensus ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, alignment_id INTEGER, consensus_length_bp INTEGER, consensus_sequence TEXT NOT NULL, ambiguity_threshold_pct REAL, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (alignment_id) REFERENCES gen_marker_ef1a_alignments (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (species_id, alignment_id) ); CREATE TABLE gen_marker_tub2_sequences ( id INTEGER PRIMARY KEY AUTOINCREMENT, sequence_id INTEGER NOT NULL, species_id INTEGER, specimen_id INTEGER, trimmed_length_bp INTEGER, aligned_length_bp INTEGER, is_reference INTEGER NOT NULL DEFAULT 0, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (sequence_id) REFERENCES gen_sequences (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE TABLE gen_marker_tub2_alignments ( id INTEGER PRIMARY KEY AUTOINCREMENT, alignment_code TEXT NOT NULL, software_id INTEGER, software_version TEXT, n_sequences INTEGER, alignment_length_bp INTEGER, trimmed_with TEXT, created_by_person_id INTEGER, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (software_id) REFERENCES gen_alignment_software (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (alignment_code) ); CREATE TABLE gen_marker_tub2_alignment_members ( alignment_id INTEGER NOT NULL, marker_sequence_id INTEGER NOT NULL, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, PRIMARY KEY (alignment_id, marker_sequence_id), FOREIGN KEY (alignment_id) REFERENCES gen_marker_tub2_alignments (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (marker_sequence_id) REFERENCES gen_marker_tub2_sequences (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_gen_marker_tub2_alignment_members_marker_sequence_id ON gen_marker_tub2_alignment_members (marker_sequence_id); CREATE TABLE gen_marker_tub2_consensus ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, alignment_id INTEGER, consensus_length_bp INTEGER, consensus_sequence TEXT NOT NULL, ambiguity_threshold_pct REAL, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (alignment_id) REFERENCES gen_marker_tub2_alignments (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (species_id, alignment_id) ); CREATE TABLE gen_marker_mcm7_sequences ( id INTEGER PRIMARY KEY AUTOINCREMENT, sequence_id INTEGER NOT NULL, species_id INTEGER, specimen_id INTEGER, trimmed_length_bp INTEGER, aligned_length_bp INTEGER, is_reference INTEGER NOT NULL DEFAULT 0, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (sequence_id) REFERENCES gen_sequences (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE TABLE gen_marker_mcm7_alignments ( id INTEGER PRIMARY KEY AUTOINCREMENT, alignment_code TEXT NOT NULL, software_id INTEGER, software_version TEXT, n_sequences INTEGER, alignment_length_bp INTEGER, trimmed_with TEXT, created_by_person_id INTEGER, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (software_id) REFERENCES gen_alignment_software (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (alignment_code) ); CREATE TABLE gen_marker_mcm7_alignment_members ( alignment_id INTEGER NOT NULL, marker_sequence_id INTEGER NOT NULL, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, PRIMARY KEY (alignment_id, marker_sequence_id), FOREIGN KEY (alignment_id) REFERENCES gen_marker_mcm7_alignments (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (marker_sequence_id) REFERENCES gen_marker_mcm7_sequences (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_gen_marker_mcm7_alignment_members_marker_sequence_id ON gen_marker_mcm7_alignment_members (marker_sequence_id); CREATE TABLE gen_marker_mcm7_consensus ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, alignment_id INTEGER, consensus_length_bp INTEGER, consensus_sequence TEXT NOT NULL, ambiguity_threshold_pct REAL, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (alignment_id) REFERENCES gen_marker_mcm7_alignments (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (species_id, alignment_id) ); CREATE TABLE gen_marker_act_sequences ( id INTEGER PRIMARY KEY AUTOINCREMENT, sequence_id INTEGER NOT NULL, species_id INTEGER, specimen_id INTEGER, trimmed_length_bp INTEGER, aligned_length_bp INTEGER, is_reference INTEGER NOT NULL DEFAULT 0, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (sequence_id) REFERENCES gen_sequences (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE TABLE gen_marker_act_alignments ( id INTEGER PRIMARY KEY AUTOINCREMENT, alignment_code TEXT NOT NULL, software_id INTEGER, software_version TEXT, n_sequences INTEGER, alignment_length_bp INTEGER, trimmed_with TEXT, created_by_person_id INTEGER, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (software_id) REFERENCES gen_alignment_software (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (alignment_code) ); CREATE TABLE gen_marker_act_alignment_members ( alignment_id INTEGER NOT NULL, marker_sequence_id INTEGER NOT NULL, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, PRIMARY KEY (alignment_id, marker_sequence_id), FOREIGN KEY (alignment_id) REFERENCES gen_marker_act_alignments (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (marker_sequence_id) REFERENCES gen_marker_act_sequences (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_gen_marker_act_alignment_members_marker_sequence_id ON gen_marker_act_alignment_members (marker_sequence_id); CREATE TABLE gen_marker_act_consensus ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, alignment_id INTEGER, consensus_length_bp INTEGER, consensus_sequence TEXT NOT NULL, ambiguity_threshold_pct REAL, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (alignment_id) REFERENCES gen_marker_act_alignments (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (species_id, alignment_id) ); CREATE TABLE gen_marker_cal_sequences ( id INTEGER PRIMARY KEY AUTOINCREMENT, sequence_id INTEGER NOT NULL, species_id INTEGER, specimen_id INTEGER, trimmed_length_bp INTEGER, aligned_length_bp INTEGER, is_reference INTEGER NOT NULL DEFAULT 0, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (sequence_id) REFERENCES gen_sequences (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE TABLE gen_marker_cal_alignments ( id INTEGER PRIMARY KEY AUTOINCREMENT, alignment_code TEXT NOT NULL, software_id INTEGER, software_version TEXT, n_sequences INTEGER, alignment_length_bp INTEGER, trimmed_with TEXT, created_by_person_id INTEGER, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (software_id) REFERENCES gen_alignment_software (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (alignment_code) ); CREATE TABLE gen_marker_cal_alignment_members ( alignment_id INTEGER NOT NULL, marker_sequence_id INTEGER NOT NULL, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, PRIMARY KEY (alignment_id, marker_sequence_id), FOREIGN KEY (alignment_id) REFERENCES gen_marker_cal_alignments (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (marker_sequence_id) REFERENCES gen_marker_cal_sequences (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_gen_marker_cal_alignment_members_marker_sequence_id ON gen_marker_cal_alignment_members (marker_sequence_id); CREATE TABLE gen_marker_cal_consensus ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, alignment_id INTEGER, consensus_length_bp INTEGER, consensus_sequence TEXT NOT NULL, ambiguity_threshold_pct REAL, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (alignment_id) REFERENCES gen_marker_cal_alignments (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (species_id, alignment_id) ); CREATE TABLE gen_marker_gpd_sequences ( id INTEGER PRIMARY KEY AUTOINCREMENT, sequence_id INTEGER NOT NULL, species_id INTEGER, specimen_id INTEGER, trimmed_length_bp INTEGER, aligned_length_bp INTEGER, is_reference INTEGER NOT NULL DEFAULT 0, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (sequence_id) REFERENCES gen_sequences (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE TABLE gen_marker_gpd_alignments ( id INTEGER PRIMARY KEY AUTOINCREMENT, alignment_code TEXT NOT NULL, software_id INTEGER, software_version TEXT, n_sequences INTEGER, alignment_length_bp INTEGER, trimmed_with TEXT, created_by_person_id INTEGER, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (software_id) REFERENCES gen_alignment_software (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (alignment_code) ); CREATE TABLE gen_marker_gpd_alignment_members ( alignment_id INTEGER NOT NULL, marker_sequence_id INTEGER NOT NULL, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, PRIMARY KEY (alignment_id, marker_sequence_id), FOREIGN KEY (alignment_id) REFERENCES gen_marker_gpd_alignments (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (marker_sequence_id) REFERENCES gen_marker_gpd_sequences (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_gen_marker_gpd_alignment_members_marker_sequence_id ON gen_marker_gpd_alignment_members (marker_sequence_id); CREATE TABLE gen_marker_gpd_consensus ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, alignment_id INTEGER, consensus_length_bp INTEGER, consensus_sequence TEXT NOT NULL, ambiguity_threshold_pct REAL, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (alignment_id) REFERENCES gen_marker_gpd_alignments (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (species_id, alignment_id) ); CREATE TABLE gen_marker_atp6_sequences ( id INTEGER PRIMARY KEY AUTOINCREMENT, sequence_id INTEGER NOT NULL, species_id INTEGER, specimen_id INTEGER, trimmed_length_bp INTEGER, aligned_length_bp INTEGER, is_reference INTEGER NOT NULL DEFAULT 0, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (sequence_id) REFERENCES gen_sequences (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE TABLE gen_marker_atp6_alignments ( id INTEGER PRIMARY KEY AUTOINCREMENT, alignment_code TEXT NOT NULL, software_id INTEGER, software_version TEXT, n_sequences INTEGER, alignment_length_bp INTEGER, trimmed_with TEXT, created_by_person_id INTEGER, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (software_id) REFERENCES gen_alignment_software (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (alignment_code) ); CREATE TABLE gen_marker_atp6_alignment_members ( alignment_id INTEGER NOT NULL, marker_sequence_id INTEGER NOT NULL, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, PRIMARY KEY (alignment_id, marker_sequence_id), FOREIGN KEY (alignment_id) REFERENCES gen_marker_atp6_alignments (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (marker_sequence_id) REFERENCES gen_marker_atp6_sequences (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_gen_marker_atp6_alignment_members_marker_sequence_id ON gen_marker_atp6_alignment_members (marker_sequence_id); CREATE TABLE gen_marker_atp6_consensus ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, alignment_id INTEGER, consensus_length_bp INTEGER, consensus_sequence TEXT NOT NULL, ambiguity_threshold_pct REAL, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (alignment_id) REFERENCES gen_marker_atp6_alignments (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (species_id, alignment_id) ); CREATE TABLE gen_marker_cox1_sequences ( id INTEGER PRIMARY KEY AUTOINCREMENT, sequence_id INTEGER NOT NULL, species_id INTEGER, specimen_id INTEGER, trimmed_length_bp INTEGER, aligned_length_bp INTEGER, is_reference INTEGER NOT NULL DEFAULT 0, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (sequence_id) REFERENCES gen_sequences (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE TABLE gen_marker_cox1_alignments ( id INTEGER PRIMARY KEY AUTOINCREMENT, alignment_code TEXT NOT NULL, software_id INTEGER, software_version TEXT, n_sequences INTEGER, alignment_length_bp INTEGER, trimmed_with TEXT, created_by_person_id INTEGER, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (software_id) REFERENCES gen_alignment_software (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (alignment_code) ); CREATE TABLE gen_marker_cox1_alignment_members ( alignment_id INTEGER NOT NULL, marker_sequence_id INTEGER NOT NULL, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, PRIMARY KEY (alignment_id, marker_sequence_id), FOREIGN KEY (alignment_id) REFERENCES gen_marker_cox1_alignments (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (marker_sequence_id) REFERENCES gen_marker_cox1_sequences (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_gen_marker_cox1_alignment_members_marker_sequence_id ON gen_marker_cox1_alignment_members (marker_sequence_id); CREATE TABLE gen_marker_cox1_consensus ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, alignment_id INTEGER, consensus_length_bp INTEGER, consensus_sequence TEXT NOT NULL, ambiguity_threshold_pct REAL, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (alignment_id) REFERENCES gen_marker_cox1_alignments (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (species_id, alignment_id) ); CREATE TABLE gen_marker_cox3_sequences ( id INTEGER PRIMARY KEY AUTOINCREMENT, sequence_id INTEGER NOT NULL, species_id INTEGER, specimen_id INTEGER, trimmed_length_bp INTEGER, aligned_length_bp INTEGER, is_reference INTEGER NOT NULL DEFAULT 0, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (sequence_id) REFERENCES gen_sequences (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE TABLE gen_marker_cox3_alignments ( id INTEGER PRIMARY KEY AUTOINCREMENT, alignment_code TEXT NOT NULL, software_id INTEGER, software_version TEXT, n_sequences INTEGER, alignment_length_bp INTEGER, trimmed_with TEXT, created_by_person_id INTEGER, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (software_id) REFERENCES gen_alignment_software (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (alignment_code) ); CREATE TABLE gen_marker_cox3_alignment_members ( alignment_id INTEGER NOT NULL, marker_sequence_id INTEGER NOT NULL, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, PRIMARY KEY (alignment_id, marker_sequence_id), FOREIGN KEY (alignment_id) REFERENCES gen_marker_cox3_alignments (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (marker_sequence_id) REFERENCES gen_marker_cox3_sequences (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_gen_marker_cox3_alignment_members_marker_sequence_id ON gen_marker_cox3_alignment_members (marker_sequence_id); CREATE TABLE gen_marker_cox3_consensus ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, alignment_id INTEGER, consensus_length_bp INTEGER, consensus_sequence TEXT NOT NULL, ambiguity_threshold_pct REAL, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (alignment_id) REFERENCES gen_marker_cox3_alignments (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (species_id, alignment_id) ); CREATE TABLE gen_marker_nadh_sequences ( id INTEGER PRIMARY KEY AUTOINCREMENT, sequence_id INTEGER NOT NULL, species_id INTEGER, specimen_id INTEGER, trimmed_length_bp INTEGER, aligned_length_bp INTEGER, is_reference INTEGER NOT NULL DEFAULT 0, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (sequence_id) REFERENCES gen_sequences (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE TABLE gen_marker_nadh_alignments ( id INTEGER PRIMARY KEY AUTOINCREMENT, alignment_code TEXT NOT NULL, software_id INTEGER, software_version TEXT, n_sequences INTEGER, alignment_length_bp INTEGER, trimmed_with TEXT, created_by_person_id INTEGER, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (software_id) REFERENCES gen_alignment_software (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (alignment_code) ); CREATE TABLE gen_marker_nadh_alignment_members ( alignment_id INTEGER NOT NULL, marker_sequence_id INTEGER NOT NULL, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, PRIMARY KEY (alignment_id, marker_sequence_id), FOREIGN KEY (alignment_id) REFERENCES gen_marker_nadh_alignments (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (marker_sequence_id) REFERENCES gen_marker_nadh_sequences (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_gen_marker_nadh_alignment_members_marker_sequence_id ON gen_marker_nadh_alignment_members (marker_sequence_id); CREATE TABLE gen_marker_nadh_consensus ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, alignment_id INTEGER, consensus_length_bp INTEGER, consensus_sequence TEXT NOT NULL, ambiguity_threshold_pct REAL, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (alignment_id) REFERENCES gen_marker_nadh_alignments (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (species_id, alignment_id) ); CREATE TABLE bio_compound_classes ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_bio_compound_classes_is_active ON bio_compound_classes (is_active); CREATE INDEX ix_bio_compound_classes_label ON bio_compound_classes (label); CREATE TABLE bio_compounds ( id INTEGER PRIMARY KEY AUTOINCREMENT, compound_class_id INTEGER, preferred_name TEXT NOT NULL, iupac_name TEXT, inchi TEXT, inchi_key TEXT, smiles TEXT, cas_number TEXT, molecular_formula TEXT, monoisotopic_mass_da REAL, logp REAL, is_secondary_metabolite INTEGER NOT NULL DEFAULT 0, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (compound_class_id) REFERENCES bio_compound_classes (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (inchi_key), UNIQUE (cas_number) ); CREATE INDEX ix_bio_compounds_preferred_name ON bio_compounds (preferred_name); CREATE INDEX ix_bio_compounds_compound_class_id ON bio_compounds (compound_class_id); CREATE TABLE bio_compound_synonyms ( id INTEGER PRIMARY KEY AUTOINCREMENT, compound_id INTEGER NOT NULL, synonym TEXT NOT NULL, is_preferred INTEGER NOT NULL DEFAULT 0, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_bio_compound_synonyms_compound_id ON bio_compound_synonyms (compound_id); CREATE INDEX ix_bio_compound_synonyms_synonym ON bio_compound_synonyms (synonym); CREATE TABLE bio_species_compound_occurrences ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, specimen_id INTEGER, concentration_mg_per_g REAL, detection_method TEXT, publication_id INTEGER, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_bio_species_compound_occurrences_species_id ON bio_species_compound_occurrences (species_id); CREATE INDEX ix_bio_species_compound_occurrences_compound_id ON bio_species_compound_occurrences (compound_id); CREATE TABLE bio_biosynthetic_gene_clusters ( id INTEGER PRIMARY KEY AUTOINCREMENT, assembly_id INTEGER NOT NULL, scaffold_name TEXT, start_bp INTEGER, end_bp INTEGER, cluster_type TEXT, predicted_product_compound_id INTEGER, antismash_version TEXT, similarity_to_known_pct REAL, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (assembly_id) REFERENCES gen_assemblies (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (predicted_product_compound_id) REFERENCES bio_compounds (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_bio_biosynthetic_gene_clusters_assembly_id ON bio_biosynthetic_gene_clusters (assembly_id); CREATE INDEX ix_bio_biosynthetic_gene_clusters_cluster_type ON bio_biosynthetic_gene_clusters (cluster_type); CREATE TABLE bio_enzymes ( id INTEGER PRIMARY KEY AUTOINCREMENT, ec_number TEXT NOT NULL, recommended_name TEXT NOT NULL, reaction_summary TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (ec_number) ); CREATE TABLE bio_protein_enzymes ( protein_id INTEGER NOT NULL, enzyme_id INTEGER NOT NULL, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, PRIMARY KEY (protein_id, enzyme_id), FOREIGN KEY (protein_id) REFERENCES gen_proteins (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (enzyme_id) REFERENCES bio_enzymes (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_bio_protein_enzymes_enzyme_id ON bio_protein_enzymes (enzyme_id); CREATE TABLE bio_toxin_amatoxins ( id INTEGER PRIMARY KEY AUTOINCREMENT, compound_id INTEGER NOT NULL, ld50_mg_per_kg_mouse REAL, primary_target_organ TEXT, symptom_onset_hours_min REAL, symptom_onset_hours_max REAL, antidote_summary TEXT, publication_id INTEGER, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE TABLE bio_toxin_phallotoxins ( id INTEGER PRIMARY KEY AUTOINCREMENT, compound_id INTEGER NOT NULL, ld50_mg_per_kg_mouse REAL, primary_target_organ TEXT, symptom_onset_hours_min REAL, symptom_onset_hours_max REAL, antidote_summary TEXT, publication_id INTEGER, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE TABLE bio_toxin_orellanines ( id INTEGER PRIMARY KEY AUTOINCREMENT, compound_id INTEGER NOT NULL, ld50_mg_per_kg_mouse REAL, primary_target_organ TEXT, symptom_onset_hours_min REAL, symptom_onset_hours_max REAL, antidote_summary TEXT, publication_id INTEGER, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE TABLE bio_toxin_gyromitrins ( id INTEGER PRIMARY KEY AUTOINCREMENT, compound_id INTEGER NOT NULL, ld50_mg_per_kg_mouse REAL, primary_target_organ TEXT, symptom_onset_hours_min REAL, symptom_onset_hours_max REAL, antidote_summary TEXT, publication_id INTEGER, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE TABLE bio_toxin_muscarines ( id INTEGER PRIMARY KEY AUTOINCREMENT, compound_id INTEGER NOT NULL, ld50_mg_per_kg_mouse REAL, primary_target_organ TEXT, symptom_onset_hours_min REAL, symptom_onset_hours_max REAL, antidote_summary TEXT, publication_id INTEGER, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE TABLE bio_toxin_ibotenic_acids ( id INTEGER PRIMARY KEY AUTOINCREMENT, compound_id INTEGER NOT NULL, ld50_mg_per_kg_mouse REAL, primary_target_organ TEXT, symptom_onset_hours_min REAL, symptom_onset_hours_max REAL, antidote_summary TEXT, publication_id INTEGER, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE TABLE bio_toxin_psilocybins ( id INTEGER PRIMARY KEY AUTOINCREMENT, compound_id INTEGER NOT NULL, ld50_mg_per_kg_mouse REAL, primary_target_organ TEXT, symptom_onset_hours_min REAL, symptom_onset_hours_max REAL, antidote_summary TEXT, publication_id INTEGER, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE TABLE bio_toxin_coprines ( id INTEGER PRIMARY KEY AUTOINCREMENT, compound_id INTEGER NOT NULL, ld50_mg_per_kg_mouse REAL, primary_target_organ TEXT, symptom_onset_hours_min REAL, symptom_onset_hours_max REAL, antidote_summary TEXT, publication_id INTEGER, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE TABLE bio_pigments ( id INTEGER PRIMARY KEY AUTOINCREMENT, compound_id INTEGER NOT NULL, absorption_max_nm REAL, color_label TEXT, known_function TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE TABLE bio_antimicrobial_assays ( id INTEGER PRIMARY KEY AUTOINCREMENT, compound_id INTEGER NOT NULL, target_organism TEXT NOT NULL, assay_type TEXT, value REAL, value_unit TEXT, publication_id INTEGER, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_bio_antimicrobial_assays_compound_id ON bio_antimicrobial_assays (compound_id); CREATE INDEX ix_bio_antimicrobial_assays_target_organism ON bio_antimicrobial_assays (target_organism); CREATE TABLE phy_software ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_phy_software_is_active ON phy_software (is_active); CREATE INDEX ix_phy_software_label ON phy_software (label); CREATE TABLE phy_substitution_models ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_phy_substitution_models_is_active ON phy_substitution_models (is_active); CREATE INDEX ix_phy_substitution_models_label ON phy_substitution_models (label); CREATE TABLE phy_trees ( id INTEGER PRIMARY KEY AUTOINCREMENT, uuid TEXT NOT NULL DEFAULT (lower(hex(randomblob(4))) || '-' || lower(hex(randomblob(2))) || '-4' || substr(lower(hex(randomblob(2))),2) || '-' || substr('89ab',abs(random()) % 4 + 1, 1) || substr(lower(hex(randomblob(2))),2) || '-' || lower(hex(randomblob(6)))), tree_code TEXT NOT NULL, scope_summary TEXT, focal_rank TEXT, focal_taxon_id INTEGER, software_id INTEGER, model_id INTEGER, n_tips INTEGER, inference_method TEXT CHECK (inference_method IN ('ML','BAYESIAN','MP','NJ','UPGMA','SPLITS')), bootstrap_replicates INTEGER, created_by_person_id INTEGER, publication_id INTEGER, newick_file_uri TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (software_id) REFERENCES phy_software (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (model_id) REFERENCES phy_substitution_models (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (tree_code) ); CREATE TABLE phy_tree_inputs ( id INTEGER PRIMARY KEY AUTOINCREMENT, tree_id INTEGER NOT NULL, alignment_table TEXT NOT NULL, alignment_id INTEGER NOT NULL, partition_label TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (tree_id) REFERENCES phy_trees (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_phy_tree_inputs_tree_id ON phy_tree_inputs (tree_id); CREATE INDEX ix_phy_tree_inputs_alignment_table_alignment_id ON phy_tree_inputs (alignment_table, alignment_id); CREATE TABLE phy_tree_tips ( id INTEGER PRIMARY KEY AUTOINCREMENT, tree_id INTEGER NOT NULL, tip_label TEXT NOT NULL, species_id INTEGER, specimen_id INTEGER, branch_length REAL, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (tree_id) REFERENCES phy_trees (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_phy_tree_tips_tree_id ON phy_tree_tips (tree_id); CREATE INDEX ix_phy_tree_tips_species_id ON phy_tree_tips (species_id); CREATE TABLE phy_node_supports ( id INTEGER PRIMARY KEY AUTOINCREMENT, tree_id INTEGER NOT NULL, node_label TEXT, support_type TEXT NOT NULL CHECK (support_type IN ('BS','UFBS','aLRT','PP','TBE','SH-aLRT')), support_value REAL NOT NULL, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (tree_id) REFERENCES phy_trees (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_phy_node_supports_tree_id ON phy_node_supports (tree_id); CREATE TABLE phy_divergence_estimates ( id INTEGER PRIMARY KEY AUTOINCREMENT, tree_id INTEGER NOT NULL, clade_label TEXT NOT NULL, estimated_age_mya REAL, hpd_lower_mya REAL, hpd_upper_mya REAL, calibration_basis TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (tree_id) REFERENCES phy_trees (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE TABLE cul_media_types ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_cul_media_types_is_active ON cul_media_types (is_active); CREATE INDEX ix_cul_media_types_label ON cul_media_types (label); CREATE TABLE cul_media_recipes ( id INTEGER PRIMARY KEY AUTOINCREMENT, media_type_id INTEGER NOT NULL, name TEXT NOT NULL, ph_target REAL, agar_pct REAL, recipe_text TEXT NOT NULL, source_publication_id INTEGER, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (media_type_id) REFERENCES cul_media_types (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (source_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE TABLE cul_strains ( id INTEGER PRIMARY KEY AUTOINCREMENT, uuid TEXT NOT NULL DEFAULT (lower(hex(randomblob(4))) || '-' || lower(hex(randomblob(2))) || '-4' || substr(lower(hex(randomblob(2))),2) || '-' || substr('89ab',abs(random()) % 4 + 1, 1) || substr(lower(hex(randomblob(2))),2) || '-' || lower(hex(randomblob(6)))), strain_code TEXT NOT NULL, species_id INTEGER, source_specimen_id INTEGER, isolation_method TEXT, isolated_at TEXT, isolated_by_person_id INTEGER, holding_collection_id INTEGER, public_accession TEXT, is_living INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (source_specimen_id) REFERENCES spc_specimens (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (isolated_by_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (holding_collection_id) REFERENCES people_institutions (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (strain_code), UNIQUE (public_accession) ); CREATE INDEX ix_cul_strains_species_id ON cul_strains (species_id); CREATE INDEX ix_cul_strains_public_accession ON cul_strains (public_accession); CREATE TABLE cul_growth_experiments ( id INTEGER PRIMARY KEY AUTOINCREMENT, strain_id INTEGER NOT NULL, media_recipe_id INTEGER NOT NULL, temperature_c REAL, photoperiod_hours_light REAL, relative_humidity_pct REAL, inoculation_at TEXT, scored_at TEXT, colony_diameter_mm REAL, growth_rate_mm_per_day REAL, colony_morphology_text TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (media_recipe_id) REFERENCES cul_media_recipes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_cul_growth_experiments_strain_id ON cul_growth_experiments (strain_id); CREATE TABLE cul_fruiting_protocols ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, substrate_recipe TEXT NOT NULL, spawn_run_temperature_c REAL, pinning_humidity_pct REAL, fruiting_temperature_c REAL, co2_ppm_target INTEGER, first_flush_days INTEGER, biological_efficiency_pct REAL, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE TABLE cul_strain_storage_events ( id INTEGER PRIMARY KEY AUTOINCREMENT, strain_id INTEGER NOT NULL, storage_method TEXT NOT NULL, stored_at TEXT NOT NULL, revived_at TEXT, viability_after_revival TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE TABLE pat_host_organism_kingdoms ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_pat_host_organism_kingdoms_is_active ON pat_host_organism_kingdoms (is_active); CREATE INDEX ix_pat_host_organism_kingdoms_label ON pat_host_organism_kingdoms (label); CREATE TABLE pat_host_organisms ( id INTEGER PRIMARY KEY AUTOINCREMENT, host_kingdom_id INTEGER NOT NULL, host_family TEXT, host_genus TEXT, host_species TEXT, common_name TEXT, economic_importance_note TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (host_kingdom_id) REFERENCES pat_host_organism_kingdoms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_pat_host_organisms_host_family ON pat_host_organisms (host_family); CREATE INDEX ix_pat_host_organisms_host_genus ON pat_host_organisms (host_genus); CREATE TABLE pat_diseases ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_pat_diseases_is_active ON pat_diseases (is_active); CREATE INDEX ix_pat_diseases_label ON pat_diseases (label); CREATE TABLE pat_disease_associations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, disease_id INTEGER NOT NULL, infection_mode TEXT, first_reported_year INTEGER, primary_evidence_publication_id INTEGER, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (disease_id) REFERENCES pat_diseases (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (primary_evidence_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (species_id, host_id, disease_id) ); CREATE TABLE pat_clinical_isolates ( id INTEGER PRIMARY KEY AUTOINCREMENT, strain_id INTEGER, species_id INTEGER, patient_age_years INTEGER, patient_sex TEXT CHECK (patient_sex IN ('M','F','O','U')), isolation_body_site TEXT, clinical_outcome TEXT, hospital_country_id INTEGER, isolated_at TEXT, publication_id INTEGER, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (hospital_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_pat_clinical_isolates_species_id ON pat_clinical_isolates (species_id); CREATE TABLE pat_antifungal_susceptibility ( id INTEGER PRIMARY KEY AUTOINCREMENT, isolate_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, mic_value REAL, mic_unit TEXT, susceptibility_call TEXT CHECK (susceptibility_call IN ('S','I','R','SDD')), method TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (isolate_id) REFERENCES pat_clinical_isolates (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_pat_antifungal_susceptibility_isolate_id ON pat_antifungal_susceptibility (isolate_id); CREATE TABLE lic_growth_forms ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_lic_growth_forms_is_active ON lic_growth_forms (is_active); CREATE INDEX ix_lic_growth_forms_label ON lic_growth_forms (label); CREATE TABLE lic_photobiont_groups ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_lic_photobiont_groups_is_active ON lic_photobiont_groups (is_active); CREATE INDEX ix_lic_photobiont_groups_label ON lic_photobiont_groups (label); CREATE TABLE lic_lichens ( id INTEGER PRIMARY KEY AUTOINCREMENT, mycobiont_species_id INTEGER NOT NULL, primary_photobiont_id INTEGER, growth_form_id INTEGER, upper_cortex_pigment TEXT, medulla_compounds_summary TEXT, specific_conductance_response TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (mycobiont_species_id) REFERENCES tax_species (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (primary_photobiont_id) REFERENCES lic_photobiont_groups (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (growth_form_id) REFERENCES lic_growth_forms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (mycobiont_species_id) ); CREATE TABLE lic_secondary_substances ( id INTEGER PRIMARY KEY AUTOINCREMENT, lichen_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, anatomical_layer TEXT, detection_method TEXT, publication_id INTEGER, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (lichen_id) REFERENCES lic_lichens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE TABLE lic_spot_tests ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, anatomical_layer TEXT NOT NULL, reagent_id INTEGER NOT NULL, reaction_color TEXT, reaction_kind TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (reagent_id) REFERENCES mor_chemical_reagents (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE TABLE field_expeditions ( id INTEGER PRIMARY KEY AUTOINCREMENT, uuid TEXT NOT NULL DEFAULT (lower(hex(randomblob(4))) || '-' || lower(hex(randomblob(2))) || '-4' || substr(lower(hex(randomblob(2))),2) || '-' || substr('89ab',abs(random()) % 4 + 1, 1) || substr(lower(hex(randomblob(2))),2) || '-' || lower(hex(randomblob(6)))), name TEXT NOT NULL, acronym TEXT, country_id INTEGER, start_date TEXT, end_date TEXT, lead_person_id INTEGER, funding_source TEXT, description TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (lead_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_field_expeditions_country_id ON field_expeditions (country_id); CREATE INDEX ix_field_expeditions_start_date ON field_expeditions (start_date); CREATE TABLE field_plots ( id INTEGER PRIMARY KEY AUTOINCREMENT, expedition_id INTEGER NOT NULL, plot_code TEXT NOT NULL, locality_id INTEGER, area_m2 REAL, vegetation_type_id INTEGER, soil_order_id INTEGER, established_date TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (expedition_id) REFERENCES field_expeditions (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (locality_id) REFERENCES geo_localities (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (vegetation_type_id) REFERENCES geo_vegetation_types (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (soil_order_id) REFERENCES geo_soil_orders (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (expedition_id, plot_code) ); CREATE INDEX ix_field_plots_expedition_id ON field_plots (expedition_id); CREATE TABLE field_transects ( id INTEGER PRIMARY KEY AUTOINCREMENT, plot_id INTEGER NOT NULL, transect_code TEXT NOT NULL, length_m REAL, bearing_deg REAL, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (plot_id) REFERENCES field_plots (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (plot_id, transect_code) ); CREATE TABLE field_weather_logs ( id INTEGER PRIMARY KEY AUTOINCREMENT, plot_id INTEGER NOT NULL, logged_at TEXT NOT NULL, temperature_c REAL, relative_humidity_pct REAL, rainfall_mm REAL, wind_speed_ms REAL, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (plot_id) REFERENCES field_plots (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_field_weather_logs_plot_id_logged_at ON field_weather_logs (plot_id, logged_at); CREATE TABLE field_observations ( id INTEGER PRIMARY KEY AUTOINCREMENT, plot_id INTEGER NOT NULL, observed_at TEXT NOT NULL, species_id INTEGER, count_individuals INTEGER, biomass_g REAL, specimen_id INTEGER, observer_person_id INTEGER, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (plot_id) REFERENCES field_plots (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (observer_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_field_observations_plot_id ON field_observations (plot_id); CREATE INDEX ix_field_observations_species_id ON field_observations (species_id); CREATE INDEX ix_field_observations_observed_at ON field_observations (observed_at); CREATE TABLE cur_quality_flag_types ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_cur_quality_flag_types_is_active ON cur_quality_flag_types (is_active); CREATE INDEX ix_cur_quality_flag_types_label ON cur_quality_flag_types (label); CREATE TABLE cur_quality_flags ( id INTEGER PRIMARY KEY AUTOINCREMENT, flag_type_id INTEGER NOT NULL, target_table TEXT NOT NULL, target_id INTEGER NOT NULL, severity TEXT NOT NULL DEFAULT 'warning' CHECK (severity IN ('info','warning','error')), opened_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, opened_by_user_id INTEGER, resolved_at TEXT, resolved_by_user_id INTEGER, resolution_note TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (flag_type_id) REFERENCES cur_quality_flag_types (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (opened_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (resolved_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_cur_quality_flags_target_table_target_id ON cur_quality_flags (target_table, target_id); CREATE INDEX ix_cur_quality_flags_severity ON cur_quality_flags (severity); CREATE TABLE cur_workflow_states ( id INTEGER PRIMARY KEY AUTOINCREMENT, entity_table TEXT NOT NULL, entity_id INTEGER NOT NULL, state TEXT NOT NULL, entered_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, entered_by_user_id INTEGER, note TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (entered_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_cur_workflow_states_entity_table_entity_id ON cur_workflow_states (entity_table, entity_id); CREATE INDEX ix_cur_workflow_states_state ON cur_workflow_states (state); CREATE TABLE cur_data_sources ( id INTEGER PRIMARY KEY AUTOINCREMENT, source_code TEXT NOT NULL, source_name TEXT NOT NULL, source_url TEXT, license TEXT, last_synced_at TEXT, description TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (source_code) ); CREATE TABLE cur_provenance ( id INTEGER PRIMARY KEY AUTOINCREMENT, entity_table TEXT NOT NULL, entity_id INTEGER NOT NULL, source_id INTEGER NOT NULL, external_id TEXT, imported_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (source_id) REFERENCES cur_data_sources (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_cur_provenance_entity_table_entity_id ON cur_provenance (entity_table, entity_id); CREATE INDEX ix_cur_provenance_source_id ON cur_provenance (source_id); CREATE TABLE img_image_kinds ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_img_image_kinds_is_active ON img_image_kinds (is_active); CREATE INDEX ix_img_image_kinds_label ON img_image_kinds (label); CREATE TABLE img_licenses ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL, label TEXT NOT NULL, description TEXT, display_order INTEGER NOT NULL DEFAULT 0, is_active INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (code) ); CREATE INDEX ix_img_licenses_is_active ON img_licenses (is_active); CREATE INDEX ix_img_licenses_label ON img_licenses (label); CREATE TABLE img_images ( id INTEGER PRIMARY KEY AUTOINCREMENT, uuid TEXT NOT NULL DEFAULT (lower(hex(randomblob(4))) || '-' || lower(hex(randomblob(2))) || '-4' || substr(lower(hex(randomblob(2))),2) || '-' || substr('89ab',abs(random()) % 4 + 1, 1) || substr(lower(hex(randomblob(2))),2) || '-' || lower(hex(randomblob(6)))), file_uri TEXT NOT NULL, kind_id INTEGER NOT NULL, license_id INTEGER, photographer_person_id INTEGER, captured_at TEXT, width_px INTEGER, height_px INTEGER, file_size_bytes INTEGER, md5_checksum TEXT, caption TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (kind_id) REFERENCES img_image_kinds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (license_id) REFERENCES img_licenses (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (photographer_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, UNIQUE (uuid) ); CREATE INDEX ix_img_images_kind_id ON img_images (kind_id); CREATE INDEX ix_img_images_captured_at ON img_images (captured_at); CREATE TABLE img_image_links ( id INTEGER PRIMARY KEY AUTOINCREMENT, image_id INTEGER NOT NULL, entity_table TEXT NOT NULL, entity_id INTEGER NOT NULL, link_role TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (image_id) REFERENCES img_images (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_img_image_links_image_id ON img_image_links (image_id); CREATE INDEX ix_img_image_links_entity_table_entity_id ON img_image_links (entity_table, entity_id); CREATE TABLE img_image_annotations ( id INTEGER PRIMARY KEY AUTOINCREMENT, image_id INTEGER NOT NULL, annotator_person_id INTEGER, annotation_kind TEXT NOT NULL, geometry_json TEXT, label_text TEXT, confidence REAL, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (image_id) REFERENCES img_images (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (annotator_person_id) REFERENCES people_persons (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_img_image_annotations_image_id ON img_image_annotations (image_id); CREATE TABLE ord_agaricales_morphology ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, hymenium_color_at_maturity TEXT, context_color_at_maturity TEXT, characteristic_microstructure TEXT, diagnostic_features_text TEXT, notes_kohler_reaction TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_agaricales_morphology_specimen_id ON ord_agaricales_morphology (specimen_id); CREATE INDEX ix_ord_agaricales_morphology_species_id ON ord_agaricales_morphology (species_id); CREATE TABLE ord_agaricales_ecology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, dominant_habitat_id INTEGER, dominant_substrate_id INTEGER, dominant_biome_id INTEGER, trophic_strategy TEXT, typical_fruiting_period TEXT, known_distribution_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_habitat_id) REFERENCES eco_habitat_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_substrate_id) REFERENCES eco_substrate_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_biome_id) REFERENCES geo_biomes (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_agaricales_ecology_species_id ON ord_agaricales_ecology (species_id); CREATE INDEX ix_ord_agaricales_ecology_dominant_habitat_id ON ord_agaricales_ecology (dominant_habitat_id); CREATE TABLE ord_agaricales_phenology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, season_name TEXT, region_country_id INTEGER, first_doy INTEGER, peak_doy INTEGER, last_doy INTEGER, years_observed INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_agaricales_phenology_species_id ON ord_agaricales_phenology (species_id); CREATE INDEX ix_ord_agaricales_phenology_region_country_id ON ord_agaricales_phenology (region_country_id); CREATE TABLE ord_agaricales_host_associations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, association_type TEXT, specificity TEXT, evidence_publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (evidence_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_agaricales_host_associations_species_id ON ord_agaricales_host_associations (species_id); CREATE INDEX ix_ord_agaricales_host_associations_host_id ON ord_agaricales_host_associations (host_id); CREATE TABLE ord_agaricales_substrate_preferences ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, substrate_id INTEGER NOT NULL, preference_score REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (substrate_id) REFERENCES eco_substrate_types (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_agaricales_substrate_preferences_species_id ON ord_agaricales_substrate_preferences (species_id); CREATE INDEX ix_ord_agaricales_substrate_preferences_substrate_id ON ord_agaricales_substrate_preferences (substrate_id); CREATE TABLE ord_agaricales_geographic_distribution ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, occurrence_status TEXT, first_record_year INTEGER, record_count INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_agaricales_geographic_distribution_species_id ON ord_agaricales_geographic_distribution (species_id); CREATE INDEX ix_ord_agaricales_geographic_distribution_country_id ON ord_agaricales_geographic_distribution (country_id); CREATE TABLE ord_agaricales_phylogeny ( id INTEGER PRIMARY KEY AUTOINCREMENT, tree_id INTEGER NOT NULL, focal_genus_id INTEGER, publication_id INTEGER, notes_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (tree_id) REFERENCES phy_trees (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_agaricales_phylogeny_tree_id ON ord_agaricales_phylogeny (tree_id); CREATE INDEX ix_ord_agaricales_phylogeny_focal_genus_id ON ord_agaricales_phylogeny (focal_genus_id); CREATE TABLE ord_agaricales_genomics ( id INTEGER PRIMARY KEY AUTOINCREMENT, assembly_id INTEGER NOT NULL, species_id INTEGER, avg_genome_size_mb REAL, avg_gene_count INTEGER, avg_busco_complete_pct REAL, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (assembly_id) REFERENCES gen_assemblies (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_agaricales_genomics_assembly_id ON ord_agaricales_genomics (assembly_id); CREATE INDEX ix_ord_agaricales_genomics_species_id ON ord_agaricales_genomics (species_id); CREATE TABLE ord_agaricales_biochemistry ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, typicality TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_agaricales_biochemistry_species_id ON ord_agaricales_biochemistry (species_id); CREATE INDEX ix_ord_agaricales_biochemistry_compound_id ON ord_agaricales_biochemistry (compound_id); CREATE TABLE ord_agaricales_cultivation_notes ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, typical_growth_rate_mm_per_day REAL, preferred_media_type_id INTEGER, optimal_temperature_c REAL, difficulty_score INTEGER CHECK (difficulty_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (preferred_media_type_id) REFERENCES cul_media_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_agaricales_cultivation_notes_species_id ON ord_agaricales_cultivation_notes (species_id); CREATE INDEX ix_ord_agaricales_cultivation_notes_strain_id ON ord_agaricales_cultivation_notes (strain_id); CREATE TABLE ord_agaricales_pathogenicity ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, disease_id INTEGER, severity_score INTEGER CHECK (severity_score BETWEEN 1 AND 5), publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (disease_id) REFERENCES pat_diseases (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_agaricales_pathogenicity_species_id ON ord_agaricales_pathogenicity (species_id); CREATE INDEX ix_ord_agaricales_pathogenicity_host_id ON ord_agaricales_pathogenicity (host_id); CREATE TABLE ord_agaricales_edibility ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, edibility_class TEXT, preparation_notes TEXT, regional_tradition_country_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (regional_tradition_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_agaricales_edibility_species_id ON ord_agaricales_edibility (species_id); CREATE INDEX ix_ord_agaricales_edibility_regional_tradition_country_id ON ord_agaricales_edibility (regional_tradition_country_id); CREATE TABLE ord_agaricales_medicinal_uses ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, traditional_use_text TEXT, modern_evidence_level TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_agaricales_medicinal_uses_species_id ON ord_agaricales_medicinal_uses (species_id); CREATE INDEX ix_ord_agaricales_medicinal_uses_publication_id ON ord_agaricales_medicinal_uses (publication_id); CREATE TABLE ord_agaricales_taxonomic_revisions ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER NOT NULL, affected_family_id INTEGER, affected_genus_id INTEGER, revision_summary TEXT, revision_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_family_id) REFERENCES tax_families (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_agaricales_taxonomic_revisions_publication_id ON ord_agaricales_taxonomic_revisions (publication_id); CREATE INDEX ix_ord_agaricales_taxonomic_revisions_affected_family_id ON ord_agaricales_taxonomic_revisions (affected_family_id); CREATE TABLE ord_agaricales_conservation_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, national_redlist_category TEXT, habitat_pressure_text TEXT, last_assessment_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_agaricales_conservation_status_species_id ON ord_agaricales_conservation_status (species_id); CREATE INDEX ix_ord_agaricales_conservation_status_country_id ON ord_agaricales_conservation_status (country_id); CREATE TABLE ord_agaricales_diagnostic_keys ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER, key_title TEXT NOT NULL, region_country_id INTEGER, n_taxa_covered INTEGER, key_format TEXT, includes_microscopy INTEGER NOT NULL DEFAULT 0, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_agaricales_diagnostic_keys_publication_id ON ord_agaricales_diagnostic_keys (publication_id); CREATE INDEX ix_ord_agaricales_diagnostic_keys_region_country_id ON ord_agaricales_diagnostic_keys (region_country_id); CREATE TABLE ord_agaricales_type_species_register ( id INTEGER PRIMARY KEY AUTOINCREMENT, focal_genus_id INTEGER NOT NULL, type_species_id INTEGER, designation_publication_id INTEGER, designation_year INTEGER, designated_by_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (designation_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_agaricales_type_species_register_focal_genus_id ON ord_agaricales_type_species_register (focal_genus_id); CREATE INDEX ix_ord_agaricales_type_species_register_type_species_id ON ord_agaricales_type_species_register (type_species_id); CREATE TABLE ord_agaricales_distribution_grids ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, grid_cell_code TEXT NOT NULL, centroid_lat REAL, centroid_lon REAL, record_count INTEGER, first_record_year INTEGER, most_recent_record_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_agaricales_distribution_grids_species_id ON ord_agaricales_distribution_grids (species_id); CREATE INDEX ix_ord_agaricales_distribution_grids_country_id ON ord_agaricales_distribution_grids (country_id); CREATE TABLE ord_agaricales_microclimate_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER, publication_id INTEGER, substrate_temperature_c REAL, substrate_moisture_pct REAL, canopy_closure_pct REAL, photosynthetic_par_umol_m2_s REAL, days_post_rainfall INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_agaricales_microclimate_studies_species_id ON ord_agaricales_microclimate_studies (species_id); CREATE INDEX ix_ord_agaricales_microclimate_studies_publication_id ON ord_agaricales_microclimate_studies (publication_id); CREATE TABLE ord_agaricales_dna_barcoding_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, its_sequenced INTEGER NOT NULL DEFAULT 0, lsu_sequenced INTEGER NOT NULL DEFAULT 0, rpb2_sequenced INTEGER NOT NULL DEFAULT 0, ef1a_sequenced INTEGER NOT NULL DEFAULT 0, genome_assembled INTEGER NOT NULL DEFAULT 0, priority_for_sequencing_score INTEGER CHECK (priority_for_sequencing_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_agaricales_dna_barcoding_status_species_id ON ord_agaricales_dna_barcoding_status (species_id); CREATE TABLE ord_agaricales_spore_print_data ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, specimen_id INTEGER, print_color_label TEXT, print_color_chip_id INTEGER, spore_density_per_mm2 REAL, collection_substrate TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (print_color_chip_id) REFERENCES mor_color_chips (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_agaricales_spore_print_data_species_id ON ord_agaricales_spore_print_data (species_id); CREATE INDEX ix_ord_agaricales_spore_print_data_specimen_id ON ord_agaricales_spore_print_data (specimen_id); CREATE TABLE ord_agaricales_mating_systems ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, system_type TEXT, mating_loci_count INTEGER, publication_id INTEGER, notes_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_agaricales_mating_systems_species_id ON ord_agaricales_mating_systems (species_id); CREATE INDEX ix_ord_agaricales_mating_systems_publication_id ON ord_agaricales_mating_systems (publication_id); CREATE TABLE ord_agaricales_nutrient_uptake_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, nitrogen_source TEXT, carbon_source TEXT, growth_response TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_agaricales_nutrient_uptake_studies_species_id ON ord_agaricales_nutrient_uptake_studies (species_id); CREATE INDEX ix_ord_agaricales_nutrient_uptake_studies_strain_id ON ord_agaricales_nutrient_uptake_studies (strain_id); CREATE TABLE ord_agaricales_range_maps ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, polygon_file_uri TEXT NOT NULL, source_methodology TEXT, area_km2 REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_agaricales_range_maps_species_id ON ord_agaricales_range_maps (species_id); CREATE INDEX ix_ord_agaricales_range_maps_publication_id ON ord_agaricales_range_maps (publication_id); CREATE TABLE ord_agaricales_abundance_estimates ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, estimate_kind TEXT, value_min REAL, value_max REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_agaricales_abundance_estimates_species_id ON ord_agaricales_abundance_estimates (species_id); CREATE INDEX ix_ord_agaricales_abundance_estimates_country_id ON ord_agaricales_abundance_estimates (country_id); CREATE TABLE ord_agaricales_toxin_profiles ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, presence TEXT, typical_concentration_mg_per_kg REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_agaricales_toxin_profiles_species_id ON ord_agaricales_toxin_profiles (species_id); CREATE INDEX ix_ord_agaricales_toxin_profiles_compound_id ON ord_agaricales_toxin_profiles (compound_id); CREATE TABLE ord_agaricales_enzyme_activity_assays ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, enzyme_id INTEGER NOT NULL, strain_id INTEGER, activity_u_per_mg REAL, temperature_c REAL, ph REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (enzyme_id) REFERENCES bio_enzymes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_agaricales_enzyme_activity_assays_species_id ON ord_agaricales_enzyme_activity_assays (species_id); CREATE INDEX ix_ord_agaricales_enzyme_activity_assays_enzyme_id ON ord_agaricales_enzyme_activity_assays (enzyme_id); CREATE TABLE ord_agaricales_biocontrol_evaluations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, target_pest_text TEXT NOT NULL, efficacy_pct REAL, trial_setting TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_agaricales_biocontrol_evaluations_species_id ON ord_agaricales_biocontrol_evaluations (species_id); CREATE INDEX ix_ord_agaricales_biocontrol_evaluations_publication_id ON ord_agaricales_biocontrol_evaluations (publication_id); CREATE TABLE ord_agaricales_regional_checklists ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, checklist_publication_id INTEGER, status TEXT, checklist_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (checklist_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_agaricales_regional_checklists_species_id ON ord_agaricales_regional_checklists (species_id); CREATE INDEX ix_ord_agaricales_regional_checklists_country_id ON ord_agaricales_regional_checklists (country_id); CREATE TABLE ord_boletales_morphology ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, hymenium_color_at_maturity TEXT, context_color_at_maturity TEXT, characteristic_microstructure TEXT, diagnostic_features_text TEXT, notes_kohler_reaction TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_boletales_morphology_specimen_id ON ord_boletales_morphology (specimen_id); CREATE INDEX ix_ord_boletales_morphology_species_id ON ord_boletales_morphology (species_id); CREATE TABLE ord_boletales_ecology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, dominant_habitat_id INTEGER, dominant_substrate_id INTEGER, dominant_biome_id INTEGER, trophic_strategy TEXT, typical_fruiting_period TEXT, known_distribution_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_habitat_id) REFERENCES eco_habitat_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_substrate_id) REFERENCES eco_substrate_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_biome_id) REFERENCES geo_biomes (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_boletales_ecology_species_id ON ord_boletales_ecology (species_id); CREATE INDEX ix_ord_boletales_ecology_dominant_habitat_id ON ord_boletales_ecology (dominant_habitat_id); CREATE TABLE ord_boletales_phenology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, season_name TEXT, region_country_id INTEGER, first_doy INTEGER, peak_doy INTEGER, last_doy INTEGER, years_observed INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_boletales_phenology_species_id ON ord_boletales_phenology (species_id); CREATE INDEX ix_ord_boletales_phenology_region_country_id ON ord_boletales_phenology (region_country_id); CREATE TABLE ord_boletales_host_associations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, association_type TEXT, specificity TEXT, evidence_publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (evidence_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_boletales_host_associations_species_id ON ord_boletales_host_associations (species_id); CREATE INDEX ix_ord_boletales_host_associations_host_id ON ord_boletales_host_associations (host_id); CREATE TABLE ord_boletales_substrate_preferences ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, substrate_id INTEGER NOT NULL, preference_score REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (substrate_id) REFERENCES eco_substrate_types (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_boletales_substrate_preferences_species_id ON ord_boletales_substrate_preferences (species_id); CREATE INDEX ix_ord_boletales_substrate_preferences_substrate_id ON ord_boletales_substrate_preferences (substrate_id); CREATE TABLE ord_boletales_geographic_distribution ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, occurrence_status TEXT, first_record_year INTEGER, record_count INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_boletales_geographic_distribution_species_id ON ord_boletales_geographic_distribution (species_id); CREATE INDEX ix_ord_boletales_geographic_distribution_country_id ON ord_boletales_geographic_distribution (country_id); CREATE TABLE ord_boletales_phylogeny ( id INTEGER PRIMARY KEY AUTOINCREMENT, tree_id INTEGER NOT NULL, focal_genus_id INTEGER, publication_id INTEGER, notes_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (tree_id) REFERENCES phy_trees (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_boletales_phylogeny_tree_id ON ord_boletales_phylogeny (tree_id); CREATE INDEX ix_ord_boletales_phylogeny_focal_genus_id ON ord_boletales_phylogeny (focal_genus_id); CREATE TABLE ord_boletales_genomics ( id INTEGER PRIMARY KEY AUTOINCREMENT, assembly_id INTEGER NOT NULL, species_id INTEGER, avg_genome_size_mb REAL, avg_gene_count INTEGER, avg_busco_complete_pct REAL, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (assembly_id) REFERENCES gen_assemblies (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_boletales_genomics_assembly_id ON ord_boletales_genomics (assembly_id); CREATE INDEX ix_ord_boletales_genomics_species_id ON ord_boletales_genomics (species_id); CREATE TABLE ord_boletales_biochemistry ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, typicality TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_boletales_biochemistry_species_id ON ord_boletales_biochemistry (species_id); CREATE INDEX ix_ord_boletales_biochemistry_compound_id ON ord_boletales_biochemistry (compound_id); CREATE TABLE ord_boletales_cultivation_notes ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, typical_growth_rate_mm_per_day REAL, preferred_media_type_id INTEGER, optimal_temperature_c REAL, difficulty_score INTEGER CHECK (difficulty_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (preferred_media_type_id) REFERENCES cul_media_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_boletales_cultivation_notes_species_id ON ord_boletales_cultivation_notes (species_id); CREATE INDEX ix_ord_boletales_cultivation_notes_strain_id ON ord_boletales_cultivation_notes (strain_id); CREATE TABLE ord_boletales_pathogenicity ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, disease_id INTEGER, severity_score INTEGER CHECK (severity_score BETWEEN 1 AND 5), publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (disease_id) REFERENCES pat_diseases (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_boletales_pathogenicity_species_id ON ord_boletales_pathogenicity (species_id); CREATE INDEX ix_ord_boletales_pathogenicity_host_id ON ord_boletales_pathogenicity (host_id); CREATE TABLE ord_boletales_edibility ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, edibility_class TEXT, preparation_notes TEXT, regional_tradition_country_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (regional_tradition_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_boletales_edibility_species_id ON ord_boletales_edibility (species_id); CREATE INDEX ix_ord_boletales_edibility_regional_tradition_country_id ON ord_boletales_edibility (regional_tradition_country_id); CREATE TABLE ord_boletales_medicinal_uses ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, traditional_use_text TEXT, modern_evidence_level TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_boletales_medicinal_uses_species_id ON ord_boletales_medicinal_uses (species_id); CREATE INDEX ix_ord_boletales_medicinal_uses_publication_id ON ord_boletales_medicinal_uses (publication_id); CREATE TABLE ord_boletales_taxonomic_revisions ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER NOT NULL, affected_family_id INTEGER, affected_genus_id INTEGER, revision_summary TEXT, revision_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_family_id) REFERENCES tax_families (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_boletales_taxonomic_revisions_publication_id ON ord_boletales_taxonomic_revisions (publication_id); CREATE INDEX ix_ord_boletales_taxonomic_revisions_affected_family_id ON ord_boletales_taxonomic_revisions (affected_family_id); CREATE TABLE ord_boletales_conservation_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, national_redlist_category TEXT, habitat_pressure_text TEXT, last_assessment_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_boletales_conservation_status_species_id ON ord_boletales_conservation_status (species_id); CREATE INDEX ix_ord_boletales_conservation_status_country_id ON ord_boletales_conservation_status (country_id); CREATE TABLE ord_boletales_diagnostic_keys ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER, key_title TEXT NOT NULL, region_country_id INTEGER, n_taxa_covered INTEGER, key_format TEXT, includes_microscopy INTEGER NOT NULL DEFAULT 0, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_boletales_diagnostic_keys_publication_id ON ord_boletales_diagnostic_keys (publication_id); CREATE INDEX ix_ord_boletales_diagnostic_keys_region_country_id ON ord_boletales_diagnostic_keys (region_country_id); CREATE TABLE ord_boletales_type_species_register ( id INTEGER PRIMARY KEY AUTOINCREMENT, focal_genus_id INTEGER NOT NULL, type_species_id INTEGER, designation_publication_id INTEGER, designation_year INTEGER, designated_by_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (designation_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_boletales_type_species_register_focal_genus_id ON ord_boletales_type_species_register (focal_genus_id); CREATE INDEX ix_ord_boletales_type_species_register_type_species_id ON ord_boletales_type_species_register (type_species_id); CREATE TABLE ord_boletales_distribution_grids ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, grid_cell_code TEXT NOT NULL, centroid_lat REAL, centroid_lon REAL, record_count INTEGER, first_record_year INTEGER, most_recent_record_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_boletales_distribution_grids_species_id ON ord_boletales_distribution_grids (species_id); CREATE INDEX ix_ord_boletales_distribution_grids_country_id ON ord_boletales_distribution_grids (country_id); CREATE TABLE ord_boletales_microclimate_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER, publication_id INTEGER, substrate_temperature_c REAL, substrate_moisture_pct REAL, canopy_closure_pct REAL, photosynthetic_par_umol_m2_s REAL, days_post_rainfall INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_boletales_microclimate_studies_species_id ON ord_boletales_microclimate_studies (species_id); CREATE INDEX ix_ord_boletales_microclimate_studies_publication_id ON ord_boletales_microclimate_studies (publication_id); CREATE TABLE ord_boletales_dna_barcoding_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, its_sequenced INTEGER NOT NULL DEFAULT 0, lsu_sequenced INTEGER NOT NULL DEFAULT 0, rpb2_sequenced INTEGER NOT NULL DEFAULT 0, ef1a_sequenced INTEGER NOT NULL DEFAULT 0, genome_assembled INTEGER NOT NULL DEFAULT 0, priority_for_sequencing_score INTEGER CHECK (priority_for_sequencing_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_boletales_dna_barcoding_status_species_id ON ord_boletales_dna_barcoding_status (species_id); CREATE TABLE ord_boletales_spore_print_data ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, specimen_id INTEGER, print_color_label TEXT, print_color_chip_id INTEGER, spore_density_per_mm2 REAL, collection_substrate TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (print_color_chip_id) REFERENCES mor_color_chips (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_boletales_spore_print_data_species_id ON ord_boletales_spore_print_data (species_id); CREATE INDEX ix_ord_boletales_spore_print_data_specimen_id ON ord_boletales_spore_print_data (specimen_id); CREATE TABLE ord_boletales_mating_systems ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, system_type TEXT, mating_loci_count INTEGER, publication_id INTEGER, notes_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_boletales_mating_systems_species_id ON ord_boletales_mating_systems (species_id); CREATE INDEX ix_ord_boletales_mating_systems_publication_id ON ord_boletales_mating_systems (publication_id); CREATE TABLE ord_boletales_nutrient_uptake_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, nitrogen_source TEXT, carbon_source TEXT, growth_response TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_boletales_nutrient_uptake_studies_species_id ON ord_boletales_nutrient_uptake_studies (species_id); CREATE INDEX ix_ord_boletales_nutrient_uptake_studies_strain_id ON ord_boletales_nutrient_uptake_studies (strain_id); CREATE TABLE ord_boletales_range_maps ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, polygon_file_uri TEXT NOT NULL, source_methodology TEXT, area_km2 REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_boletales_range_maps_species_id ON ord_boletales_range_maps (species_id); CREATE INDEX ix_ord_boletales_range_maps_publication_id ON ord_boletales_range_maps (publication_id); CREATE TABLE ord_boletales_abundance_estimates ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, estimate_kind TEXT, value_min REAL, value_max REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_boletales_abundance_estimates_species_id ON ord_boletales_abundance_estimates (species_id); CREATE INDEX ix_ord_boletales_abundance_estimates_country_id ON ord_boletales_abundance_estimates (country_id); CREATE TABLE ord_boletales_toxin_profiles ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, presence TEXT, typical_concentration_mg_per_kg REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_boletales_toxin_profiles_species_id ON ord_boletales_toxin_profiles (species_id); CREATE INDEX ix_ord_boletales_toxin_profiles_compound_id ON ord_boletales_toxin_profiles (compound_id); CREATE TABLE ord_boletales_enzyme_activity_assays ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, enzyme_id INTEGER NOT NULL, strain_id INTEGER, activity_u_per_mg REAL, temperature_c REAL, ph REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (enzyme_id) REFERENCES bio_enzymes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_boletales_enzyme_activity_assays_species_id ON ord_boletales_enzyme_activity_assays (species_id); CREATE INDEX ix_ord_boletales_enzyme_activity_assays_enzyme_id ON ord_boletales_enzyme_activity_assays (enzyme_id); CREATE TABLE ord_boletales_biocontrol_evaluations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, target_pest_text TEXT NOT NULL, efficacy_pct REAL, trial_setting TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_boletales_biocontrol_evaluations_species_id ON ord_boletales_biocontrol_evaluations (species_id); CREATE INDEX ix_ord_boletales_biocontrol_evaluations_publication_id ON ord_boletales_biocontrol_evaluations (publication_id); CREATE TABLE ord_boletales_regional_checklists ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, checklist_publication_id INTEGER, status TEXT, checklist_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (checklist_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_boletales_regional_checklists_species_id ON ord_boletales_regional_checklists (species_id); CREATE INDEX ix_ord_boletales_regional_checklists_country_id ON ord_boletales_regional_checklists (country_id); CREATE TABLE ord_russulales_morphology ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, hymenium_color_at_maturity TEXT, context_color_at_maturity TEXT, characteristic_microstructure TEXT, diagnostic_features_text TEXT, notes_kohler_reaction TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_russulales_morphology_specimen_id ON ord_russulales_morphology (specimen_id); CREATE INDEX ix_ord_russulales_morphology_species_id ON ord_russulales_morphology (species_id); CREATE TABLE ord_russulales_ecology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, dominant_habitat_id INTEGER, dominant_substrate_id INTEGER, dominant_biome_id INTEGER, trophic_strategy TEXT, typical_fruiting_period TEXT, known_distribution_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_habitat_id) REFERENCES eco_habitat_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_substrate_id) REFERENCES eco_substrate_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_biome_id) REFERENCES geo_biomes (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_russulales_ecology_species_id ON ord_russulales_ecology (species_id); CREATE INDEX ix_ord_russulales_ecology_dominant_habitat_id ON ord_russulales_ecology (dominant_habitat_id); CREATE TABLE ord_russulales_phenology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, season_name TEXT, region_country_id INTEGER, first_doy INTEGER, peak_doy INTEGER, last_doy INTEGER, years_observed INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_russulales_phenology_species_id ON ord_russulales_phenology (species_id); CREATE INDEX ix_ord_russulales_phenology_region_country_id ON ord_russulales_phenology (region_country_id); CREATE TABLE ord_russulales_host_associations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, association_type TEXT, specificity TEXT, evidence_publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (evidence_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_russulales_host_associations_species_id ON ord_russulales_host_associations (species_id); CREATE INDEX ix_ord_russulales_host_associations_host_id ON ord_russulales_host_associations (host_id); CREATE TABLE ord_russulales_substrate_preferences ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, substrate_id INTEGER NOT NULL, preference_score REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (substrate_id) REFERENCES eco_substrate_types (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_russulales_substrate_preferences_species_id ON ord_russulales_substrate_preferences (species_id); CREATE INDEX ix_ord_russulales_substrate_preferences_substrate_id ON ord_russulales_substrate_preferences (substrate_id); CREATE TABLE ord_russulales_geographic_distribution ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, occurrence_status TEXT, first_record_year INTEGER, record_count INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_russulales_geographic_distribution_species_id ON ord_russulales_geographic_distribution (species_id); CREATE INDEX ix_ord_russulales_geographic_distribution_country_id ON ord_russulales_geographic_distribution (country_id); CREATE TABLE ord_russulales_phylogeny ( id INTEGER PRIMARY KEY AUTOINCREMENT, tree_id INTEGER NOT NULL, focal_genus_id INTEGER, publication_id INTEGER, notes_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (tree_id) REFERENCES phy_trees (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_russulales_phylogeny_tree_id ON ord_russulales_phylogeny (tree_id); CREATE INDEX ix_ord_russulales_phylogeny_focal_genus_id ON ord_russulales_phylogeny (focal_genus_id); CREATE TABLE ord_russulales_genomics ( id INTEGER PRIMARY KEY AUTOINCREMENT, assembly_id INTEGER NOT NULL, species_id INTEGER, avg_genome_size_mb REAL, avg_gene_count INTEGER, avg_busco_complete_pct REAL, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (assembly_id) REFERENCES gen_assemblies (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_russulales_genomics_assembly_id ON ord_russulales_genomics (assembly_id); CREATE INDEX ix_ord_russulales_genomics_species_id ON ord_russulales_genomics (species_id); CREATE TABLE ord_russulales_biochemistry ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, typicality TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_russulales_biochemistry_species_id ON ord_russulales_biochemistry (species_id); CREATE INDEX ix_ord_russulales_biochemistry_compound_id ON ord_russulales_biochemistry (compound_id); CREATE TABLE ord_russulales_cultivation_notes ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, typical_growth_rate_mm_per_day REAL, preferred_media_type_id INTEGER, optimal_temperature_c REAL, difficulty_score INTEGER CHECK (difficulty_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (preferred_media_type_id) REFERENCES cul_media_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_russulales_cultivation_notes_species_id ON ord_russulales_cultivation_notes (species_id); CREATE INDEX ix_ord_russulales_cultivation_notes_strain_id ON ord_russulales_cultivation_notes (strain_id); CREATE TABLE ord_russulales_pathogenicity ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, disease_id INTEGER, severity_score INTEGER CHECK (severity_score BETWEEN 1 AND 5), publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (disease_id) REFERENCES pat_diseases (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_russulales_pathogenicity_species_id ON ord_russulales_pathogenicity (species_id); CREATE INDEX ix_ord_russulales_pathogenicity_host_id ON ord_russulales_pathogenicity (host_id); CREATE TABLE ord_russulales_edibility ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, edibility_class TEXT, preparation_notes TEXT, regional_tradition_country_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (regional_tradition_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_russulales_edibility_species_id ON ord_russulales_edibility (species_id); CREATE INDEX ix_ord_russulales_edibility_regional_tradition_country_id ON ord_russulales_edibility (regional_tradition_country_id); CREATE TABLE ord_russulales_medicinal_uses ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, traditional_use_text TEXT, modern_evidence_level TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_russulales_medicinal_uses_species_id ON ord_russulales_medicinal_uses (species_id); CREATE INDEX ix_ord_russulales_medicinal_uses_publication_id ON ord_russulales_medicinal_uses (publication_id); CREATE TABLE ord_russulales_taxonomic_revisions ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER NOT NULL, affected_family_id INTEGER, affected_genus_id INTEGER, revision_summary TEXT, revision_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_family_id) REFERENCES tax_families (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_russulales_taxonomic_revisions_publication_id ON ord_russulales_taxonomic_revisions (publication_id); CREATE INDEX ix_ord_russulales_taxonomic_revisions_affected_family_id ON ord_russulales_taxonomic_revisions (affected_family_id); CREATE TABLE ord_russulales_conservation_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, national_redlist_category TEXT, habitat_pressure_text TEXT, last_assessment_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_russulales_conservation_status_species_id ON ord_russulales_conservation_status (species_id); CREATE INDEX ix_ord_russulales_conservation_status_country_id ON ord_russulales_conservation_status (country_id); CREATE TABLE ord_russulales_diagnostic_keys ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER, key_title TEXT NOT NULL, region_country_id INTEGER, n_taxa_covered INTEGER, key_format TEXT, includes_microscopy INTEGER NOT NULL DEFAULT 0, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_russulales_diagnostic_keys_publication_id ON ord_russulales_diagnostic_keys (publication_id); CREATE INDEX ix_ord_russulales_diagnostic_keys_region_country_id ON ord_russulales_diagnostic_keys (region_country_id); CREATE TABLE ord_russulales_type_species_register ( id INTEGER PRIMARY KEY AUTOINCREMENT, focal_genus_id INTEGER NOT NULL, type_species_id INTEGER, designation_publication_id INTEGER, designation_year INTEGER, designated_by_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (designation_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_russulales_type_species_register_focal_genus_id ON ord_russulales_type_species_register (focal_genus_id); CREATE INDEX ix_ord_russulales_type_species_register_type_species_id ON ord_russulales_type_species_register (type_species_id); CREATE TABLE ord_russulales_distribution_grids ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, grid_cell_code TEXT NOT NULL, centroid_lat REAL, centroid_lon REAL, record_count INTEGER, first_record_year INTEGER, most_recent_record_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_russulales_distribution_grids_species_id ON ord_russulales_distribution_grids (species_id); CREATE INDEX ix_ord_russulales_distribution_grids_country_id ON ord_russulales_distribution_grids (country_id); CREATE TABLE ord_russulales_microclimate_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER, publication_id INTEGER, substrate_temperature_c REAL, substrate_moisture_pct REAL, canopy_closure_pct REAL, photosynthetic_par_umol_m2_s REAL, days_post_rainfall INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_russulales_microclimate_studies_species_id ON ord_russulales_microclimate_studies (species_id); CREATE INDEX ix_ord_russulales_microclimate_studies_publication_id ON ord_russulales_microclimate_studies (publication_id); CREATE TABLE ord_russulales_dna_barcoding_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, its_sequenced INTEGER NOT NULL DEFAULT 0, lsu_sequenced INTEGER NOT NULL DEFAULT 0, rpb2_sequenced INTEGER NOT NULL DEFAULT 0, ef1a_sequenced INTEGER NOT NULL DEFAULT 0, genome_assembled INTEGER NOT NULL DEFAULT 0, priority_for_sequencing_score INTEGER CHECK (priority_for_sequencing_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_russulales_dna_barcoding_status_species_id ON ord_russulales_dna_barcoding_status (species_id); CREATE TABLE ord_russulales_spore_print_data ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, specimen_id INTEGER, print_color_label TEXT, print_color_chip_id INTEGER, spore_density_per_mm2 REAL, collection_substrate TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (print_color_chip_id) REFERENCES mor_color_chips (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_russulales_spore_print_data_species_id ON ord_russulales_spore_print_data (species_id); CREATE INDEX ix_ord_russulales_spore_print_data_specimen_id ON ord_russulales_spore_print_data (specimen_id); CREATE TABLE ord_russulales_mating_systems ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, system_type TEXT, mating_loci_count INTEGER, publication_id INTEGER, notes_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_russulales_mating_systems_species_id ON ord_russulales_mating_systems (species_id); CREATE INDEX ix_ord_russulales_mating_systems_publication_id ON ord_russulales_mating_systems (publication_id); CREATE TABLE ord_russulales_nutrient_uptake_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, nitrogen_source TEXT, carbon_source TEXT, growth_response TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_russulales_nutrient_uptake_studies_species_id ON ord_russulales_nutrient_uptake_studies (species_id); CREATE INDEX ix_ord_russulales_nutrient_uptake_studies_strain_id ON ord_russulales_nutrient_uptake_studies (strain_id); CREATE TABLE ord_russulales_range_maps ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, polygon_file_uri TEXT NOT NULL, source_methodology TEXT, area_km2 REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_russulales_range_maps_species_id ON ord_russulales_range_maps (species_id); CREATE INDEX ix_ord_russulales_range_maps_publication_id ON ord_russulales_range_maps (publication_id); CREATE TABLE ord_russulales_abundance_estimates ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, estimate_kind TEXT, value_min REAL, value_max REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_russulales_abundance_estimates_species_id ON ord_russulales_abundance_estimates (species_id); CREATE INDEX ix_ord_russulales_abundance_estimates_country_id ON ord_russulales_abundance_estimates (country_id); CREATE TABLE ord_russulales_toxin_profiles ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, presence TEXT, typical_concentration_mg_per_kg REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_russulales_toxin_profiles_species_id ON ord_russulales_toxin_profiles (species_id); CREATE INDEX ix_ord_russulales_toxin_profiles_compound_id ON ord_russulales_toxin_profiles (compound_id); CREATE TABLE ord_russulales_enzyme_activity_assays ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, enzyme_id INTEGER NOT NULL, strain_id INTEGER, activity_u_per_mg REAL, temperature_c REAL, ph REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (enzyme_id) REFERENCES bio_enzymes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_russulales_enzyme_activity_assays_species_id ON ord_russulales_enzyme_activity_assays (species_id); CREATE INDEX ix_ord_russulales_enzyme_activity_assays_enzyme_id ON ord_russulales_enzyme_activity_assays (enzyme_id); CREATE TABLE ord_russulales_biocontrol_evaluations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, target_pest_text TEXT NOT NULL, efficacy_pct REAL, trial_setting TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_russulales_biocontrol_evaluations_species_id ON ord_russulales_biocontrol_evaluations (species_id); CREATE INDEX ix_ord_russulales_biocontrol_evaluations_publication_id ON ord_russulales_biocontrol_evaluations (publication_id); CREATE TABLE ord_russulales_regional_checklists ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, checklist_publication_id INTEGER, status TEXT, checklist_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (checklist_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_russulales_regional_checklists_species_id ON ord_russulales_regional_checklists (species_id); CREATE INDEX ix_ord_russulales_regional_checklists_country_id ON ord_russulales_regional_checklists (country_id); CREATE TABLE ord_polyporales_morphology ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, hymenium_color_at_maturity TEXT, context_color_at_maturity TEXT, characteristic_microstructure TEXT, diagnostic_features_text TEXT, notes_kohler_reaction TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_polyporales_morphology_specimen_id ON ord_polyporales_morphology (specimen_id); CREATE INDEX ix_ord_polyporales_morphology_species_id ON ord_polyporales_morphology (species_id); CREATE TABLE ord_polyporales_ecology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, dominant_habitat_id INTEGER, dominant_substrate_id INTEGER, dominant_biome_id INTEGER, trophic_strategy TEXT, typical_fruiting_period TEXT, known_distribution_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_habitat_id) REFERENCES eco_habitat_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_substrate_id) REFERENCES eco_substrate_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_biome_id) REFERENCES geo_biomes (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_polyporales_ecology_species_id ON ord_polyporales_ecology (species_id); CREATE INDEX ix_ord_polyporales_ecology_dominant_habitat_id ON ord_polyporales_ecology (dominant_habitat_id); CREATE TABLE ord_polyporales_phenology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, season_name TEXT, region_country_id INTEGER, first_doy INTEGER, peak_doy INTEGER, last_doy INTEGER, years_observed INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_polyporales_phenology_species_id ON ord_polyporales_phenology (species_id); CREATE INDEX ix_ord_polyporales_phenology_region_country_id ON ord_polyporales_phenology (region_country_id); CREATE TABLE ord_polyporales_host_associations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, association_type TEXT, specificity TEXT, evidence_publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (evidence_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_polyporales_host_associations_species_id ON ord_polyporales_host_associations (species_id); CREATE INDEX ix_ord_polyporales_host_associations_host_id ON ord_polyporales_host_associations (host_id); CREATE TABLE ord_polyporales_substrate_preferences ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, substrate_id INTEGER NOT NULL, preference_score REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (substrate_id) REFERENCES eco_substrate_types (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_polyporales_substrate_preferences_species_id ON ord_polyporales_substrate_preferences (species_id); CREATE INDEX ix_ord_polyporales_substrate_preferences_substrate_id ON ord_polyporales_substrate_preferences (substrate_id); CREATE TABLE ord_polyporales_geographic_distribution ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, occurrence_status TEXT, first_record_year INTEGER, record_count INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_polyporales_geographic_distribution_species_id ON ord_polyporales_geographic_distribution (species_id); CREATE INDEX ix_ord_polyporales_geographic_distribution_country_id ON ord_polyporales_geographic_distribution (country_id); CREATE TABLE ord_polyporales_phylogeny ( id INTEGER PRIMARY KEY AUTOINCREMENT, tree_id INTEGER NOT NULL, focal_genus_id INTEGER, publication_id INTEGER, notes_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (tree_id) REFERENCES phy_trees (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_polyporales_phylogeny_tree_id ON ord_polyporales_phylogeny (tree_id); CREATE INDEX ix_ord_polyporales_phylogeny_focal_genus_id ON ord_polyporales_phylogeny (focal_genus_id); CREATE TABLE ord_polyporales_genomics ( id INTEGER PRIMARY KEY AUTOINCREMENT, assembly_id INTEGER NOT NULL, species_id INTEGER, avg_genome_size_mb REAL, avg_gene_count INTEGER, avg_busco_complete_pct REAL, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (assembly_id) REFERENCES gen_assemblies (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_polyporales_genomics_assembly_id ON ord_polyporales_genomics (assembly_id); CREATE INDEX ix_ord_polyporales_genomics_species_id ON ord_polyporales_genomics (species_id); CREATE TABLE ord_polyporales_biochemistry ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, typicality TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_polyporales_biochemistry_species_id ON ord_polyporales_biochemistry (species_id); CREATE INDEX ix_ord_polyporales_biochemistry_compound_id ON ord_polyporales_biochemistry (compound_id); CREATE TABLE ord_polyporales_cultivation_notes ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, typical_growth_rate_mm_per_day REAL, preferred_media_type_id INTEGER, optimal_temperature_c REAL, difficulty_score INTEGER CHECK (difficulty_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (preferred_media_type_id) REFERENCES cul_media_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_polyporales_cultivation_notes_species_id ON ord_polyporales_cultivation_notes (species_id); CREATE INDEX ix_ord_polyporales_cultivation_notes_strain_id ON ord_polyporales_cultivation_notes (strain_id); CREATE TABLE ord_polyporales_pathogenicity ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, disease_id INTEGER, severity_score INTEGER CHECK (severity_score BETWEEN 1 AND 5), publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (disease_id) REFERENCES pat_diseases (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_polyporales_pathogenicity_species_id ON ord_polyporales_pathogenicity (species_id); CREATE INDEX ix_ord_polyporales_pathogenicity_host_id ON ord_polyporales_pathogenicity (host_id); CREATE TABLE ord_polyporales_edibility ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, edibility_class TEXT, preparation_notes TEXT, regional_tradition_country_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (regional_tradition_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_polyporales_edibility_species_id ON ord_polyporales_edibility (species_id); CREATE INDEX ix_ord_polyporales_edibility_regional_tradition_country_id ON ord_polyporales_edibility (regional_tradition_country_id); CREATE TABLE ord_polyporales_medicinal_uses ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, traditional_use_text TEXT, modern_evidence_level TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_polyporales_medicinal_uses_species_id ON ord_polyporales_medicinal_uses (species_id); CREATE INDEX ix_ord_polyporales_medicinal_uses_publication_id ON ord_polyporales_medicinal_uses (publication_id); CREATE TABLE ord_polyporales_taxonomic_revisions ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER NOT NULL, affected_family_id INTEGER, affected_genus_id INTEGER, revision_summary TEXT, revision_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_family_id) REFERENCES tax_families (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_polyporales_taxonomic_revisions_publication_id ON ord_polyporales_taxonomic_revisions (publication_id); CREATE INDEX ix_ord_polyporales_taxonomic_revisions_affected_family_id ON ord_polyporales_taxonomic_revisions (affected_family_id); CREATE TABLE ord_polyporales_conservation_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, national_redlist_category TEXT, habitat_pressure_text TEXT, last_assessment_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_polyporales_conservation_status_species_id ON ord_polyporales_conservation_status (species_id); CREATE INDEX ix_ord_polyporales_conservation_status_country_id ON ord_polyporales_conservation_status (country_id); CREATE TABLE ord_polyporales_diagnostic_keys ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER, key_title TEXT NOT NULL, region_country_id INTEGER, n_taxa_covered INTEGER, key_format TEXT, includes_microscopy INTEGER NOT NULL DEFAULT 0, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_polyporales_diagnostic_keys_publication_id ON ord_polyporales_diagnostic_keys (publication_id); CREATE INDEX ix_ord_polyporales_diagnostic_keys_region_country_id ON ord_polyporales_diagnostic_keys (region_country_id); CREATE TABLE ord_polyporales_type_species_register ( id INTEGER PRIMARY KEY AUTOINCREMENT, focal_genus_id INTEGER NOT NULL, type_species_id INTEGER, designation_publication_id INTEGER, designation_year INTEGER, designated_by_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (designation_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_polyporales_type_species_register_focal_genus_id ON ord_polyporales_type_species_register (focal_genus_id); CREATE INDEX ix_ord_polyporales_type_species_register_type_species_id ON ord_polyporales_type_species_register (type_species_id); CREATE TABLE ord_polyporales_distribution_grids ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, grid_cell_code TEXT NOT NULL, centroid_lat REAL, centroid_lon REAL, record_count INTEGER, first_record_year INTEGER, most_recent_record_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_polyporales_distribution_grids_species_id ON ord_polyporales_distribution_grids (species_id); CREATE INDEX ix_ord_polyporales_distribution_grids_country_id ON ord_polyporales_distribution_grids (country_id); CREATE TABLE ord_polyporales_microclimate_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER, publication_id INTEGER, substrate_temperature_c REAL, substrate_moisture_pct REAL, canopy_closure_pct REAL, photosynthetic_par_umol_m2_s REAL, days_post_rainfall INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_polyporales_microclimate_studies_species_id ON ord_polyporales_microclimate_studies (species_id); CREATE INDEX ix_ord_polyporales_microclimate_studies_publication_id ON ord_polyporales_microclimate_studies (publication_id); CREATE TABLE ord_polyporales_dna_barcoding_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, its_sequenced INTEGER NOT NULL DEFAULT 0, lsu_sequenced INTEGER NOT NULL DEFAULT 0, rpb2_sequenced INTEGER NOT NULL DEFAULT 0, ef1a_sequenced INTEGER NOT NULL DEFAULT 0, genome_assembled INTEGER NOT NULL DEFAULT 0, priority_for_sequencing_score INTEGER CHECK (priority_for_sequencing_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_polyporales_dna_barcoding_status_species_id ON ord_polyporales_dna_barcoding_status (species_id); CREATE TABLE ord_polyporales_spore_print_data ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, specimen_id INTEGER, print_color_label TEXT, print_color_chip_id INTEGER, spore_density_per_mm2 REAL, collection_substrate TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (print_color_chip_id) REFERENCES mor_color_chips (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_polyporales_spore_print_data_species_id ON ord_polyporales_spore_print_data (species_id); CREATE INDEX ix_ord_polyporales_spore_print_data_specimen_id ON ord_polyporales_spore_print_data (specimen_id); CREATE TABLE ord_polyporales_mating_systems ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, system_type TEXT, mating_loci_count INTEGER, publication_id INTEGER, notes_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_polyporales_mating_systems_species_id ON ord_polyporales_mating_systems (species_id); CREATE INDEX ix_ord_polyporales_mating_systems_publication_id ON ord_polyporales_mating_systems (publication_id); CREATE TABLE ord_polyporales_nutrient_uptake_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, nitrogen_source TEXT, carbon_source TEXT, growth_response TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_polyporales_nutrient_uptake_studies_species_id ON ord_polyporales_nutrient_uptake_studies (species_id); CREATE INDEX ix_ord_polyporales_nutrient_uptake_studies_strain_id ON ord_polyporales_nutrient_uptake_studies (strain_id); CREATE TABLE ord_polyporales_range_maps ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, polygon_file_uri TEXT NOT NULL, source_methodology TEXT, area_km2 REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_polyporales_range_maps_species_id ON ord_polyporales_range_maps (species_id); CREATE INDEX ix_ord_polyporales_range_maps_publication_id ON ord_polyporales_range_maps (publication_id); CREATE TABLE ord_polyporales_abundance_estimates ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, estimate_kind TEXT, value_min REAL, value_max REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_polyporales_abundance_estimates_species_id ON ord_polyporales_abundance_estimates (species_id); CREATE INDEX ix_ord_polyporales_abundance_estimates_country_id ON ord_polyporales_abundance_estimates (country_id); CREATE TABLE ord_polyporales_toxin_profiles ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, presence TEXT, typical_concentration_mg_per_kg REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_polyporales_toxin_profiles_species_id ON ord_polyporales_toxin_profiles (species_id); CREATE INDEX ix_ord_polyporales_toxin_profiles_compound_id ON ord_polyporales_toxin_profiles (compound_id); CREATE TABLE ord_polyporales_enzyme_activity_assays ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, enzyme_id INTEGER NOT NULL, strain_id INTEGER, activity_u_per_mg REAL, temperature_c REAL, ph REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (enzyme_id) REFERENCES bio_enzymes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_polyporales_enzyme_activity_assays_species_id ON ord_polyporales_enzyme_activity_assays (species_id); CREATE INDEX ix_ord_polyporales_enzyme_activity_assays_enzyme_id ON ord_polyporales_enzyme_activity_assays (enzyme_id); CREATE TABLE ord_polyporales_biocontrol_evaluations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, target_pest_text TEXT NOT NULL, efficacy_pct REAL, trial_setting TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_polyporales_biocontrol_evaluations_species_id ON ord_polyporales_biocontrol_evaluations (species_id); CREATE INDEX ix_ord_polyporales_biocontrol_evaluations_publication_id ON ord_polyporales_biocontrol_evaluations (publication_id); CREATE TABLE ord_polyporales_regional_checklists ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, checklist_publication_id INTEGER, status TEXT, checklist_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (checklist_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_polyporales_regional_checklists_species_id ON ord_polyporales_regional_checklists (species_id); CREATE INDEX ix_ord_polyporales_regional_checklists_country_id ON ord_polyporales_regional_checklists (country_id); CREATE TABLE ord_thelephorales_morphology ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, hymenium_color_at_maturity TEXT, context_color_at_maturity TEXT, characteristic_microstructure TEXT, diagnostic_features_text TEXT, notes_kohler_reaction TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_thelephorales_morphology_specimen_id ON ord_thelephorales_morphology (specimen_id); CREATE INDEX ix_ord_thelephorales_morphology_species_id ON ord_thelephorales_morphology (species_id); CREATE TABLE ord_thelephorales_ecology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, dominant_habitat_id INTEGER, dominant_substrate_id INTEGER, dominant_biome_id INTEGER, trophic_strategy TEXT, typical_fruiting_period TEXT, known_distribution_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_habitat_id) REFERENCES eco_habitat_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_substrate_id) REFERENCES eco_substrate_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_biome_id) REFERENCES geo_biomes (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_thelephorales_ecology_species_id ON ord_thelephorales_ecology (species_id); CREATE INDEX ix_ord_thelephorales_ecology_dominant_habitat_id ON ord_thelephorales_ecology (dominant_habitat_id); CREATE TABLE ord_thelephorales_phenology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, season_name TEXT, region_country_id INTEGER, first_doy INTEGER, peak_doy INTEGER, last_doy INTEGER, years_observed INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_thelephorales_phenology_species_id ON ord_thelephorales_phenology (species_id); CREATE INDEX ix_ord_thelephorales_phenology_region_country_id ON ord_thelephorales_phenology (region_country_id); CREATE TABLE ord_thelephorales_host_associations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, association_type TEXT, specificity TEXT, evidence_publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (evidence_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_thelephorales_host_associations_species_id ON ord_thelephorales_host_associations (species_id); CREATE INDEX ix_ord_thelephorales_host_associations_host_id ON ord_thelephorales_host_associations (host_id); CREATE TABLE ord_thelephorales_substrate_preferences ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, substrate_id INTEGER NOT NULL, preference_score REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (substrate_id) REFERENCES eco_substrate_types (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_thelephorales_substrate_preferences_species_id ON ord_thelephorales_substrate_preferences (species_id); CREATE INDEX ix_ord_thelephorales_substrate_preferences_substrate_id ON ord_thelephorales_substrate_preferences (substrate_id); CREATE TABLE ord_thelephorales_geographic_distribution ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, occurrence_status TEXT, first_record_year INTEGER, record_count INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_thelephorales_geographic_distribution_species_id ON ord_thelephorales_geographic_distribution (species_id); CREATE INDEX ix_ord_thelephorales_geographic_distribution_country_id ON ord_thelephorales_geographic_distribution (country_id); CREATE TABLE ord_thelephorales_phylogeny ( id INTEGER PRIMARY KEY AUTOINCREMENT, tree_id INTEGER NOT NULL, focal_genus_id INTEGER, publication_id INTEGER, notes_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (tree_id) REFERENCES phy_trees (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_thelephorales_phylogeny_tree_id ON ord_thelephorales_phylogeny (tree_id); CREATE INDEX ix_ord_thelephorales_phylogeny_focal_genus_id ON ord_thelephorales_phylogeny (focal_genus_id); CREATE TABLE ord_thelephorales_genomics ( id INTEGER PRIMARY KEY AUTOINCREMENT, assembly_id INTEGER NOT NULL, species_id INTEGER, avg_genome_size_mb REAL, avg_gene_count INTEGER, avg_busco_complete_pct REAL, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (assembly_id) REFERENCES gen_assemblies (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_thelephorales_genomics_assembly_id ON ord_thelephorales_genomics (assembly_id); CREATE INDEX ix_ord_thelephorales_genomics_species_id ON ord_thelephorales_genomics (species_id); CREATE TABLE ord_thelephorales_biochemistry ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, typicality TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_thelephorales_biochemistry_species_id ON ord_thelephorales_biochemistry (species_id); CREATE INDEX ix_ord_thelephorales_biochemistry_compound_id ON ord_thelephorales_biochemistry (compound_id); CREATE TABLE ord_thelephorales_cultivation_notes ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, typical_growth_rate_mm_per_day REAL, preferred_media_type_id INTEGER, optimal_temperature_c REAL, difficulty_score INTEGER CHECK (difficulty_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (preferred_media_type_id) REFERENCES cul_media_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_thelephorales_cultivation_notes_species_id ON ord_thelephorales_cultivation_notes (species_id); CREATE INDEX ix_ord_thelephorales_cultivation_notes_strain_id ON ord_thelephorales_cultivation_notes (strain_id); CREATE TABLE ord_thelephorales_pathogenicity ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, disease_id INTEGER, severity_score INTEGER CHECK (severity_score BETWEEN 1 AND 5), publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (disease_id) REFERENCES pat_diseases (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_thelephorales_pathogenicity_species_id ON ord_thelephorales_pathogenicity (species_id); CREATE INDEX ix_ord_thelephorales_pathogenicity_host_id ON ord_thelephorales_pathogenicity (host_id); CREATE TABLE ord_thelephorales_edibility ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, edibility_class TEXT, preparation_notes TEXT, regional_tradition_country_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (regional_tradition_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_thelephorales_edibility_species_id ON ord_thelephorales_edibility (species_id); CREATE INDEX ix_ord_thelephorales_edibility_regional_tradition_country_id ON ord_thelephorales_edibility (regional_tradition_country_id); CREATE TABLE ord_thelephorales_medicinal_uses ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, traditional_use_text TEXT, modern_evidence_level TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_thelephorales_medicinal_uses_species_id ON ord_thelephorales_medicinal_uses (species_id); CREATE INDEX ix_ord_thelephorales_medicinal_uses_publication_id ON ord_thelephorales_medicinal_uses (publication_id); CREATE TABLE ord_thelephorales_taxonomic_revisions ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER NOT NULL, affected_family_id INTEGER, affected_genus_id INTEGER, revision_summary TEXT, revision_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_family_id) REFERENCES tax_families (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_thelephorales_taxonomic_revisions_publication_id ON ord_thelephorales_taxonomic_revisions (publication_id); CREATE INDEX ix_ord_thelephorales_taxonomic_revisions_affected_family_id ON ord_thelephorales_taxonomic_revisions (affected_family_id); CREATE TABLE ord_thelephorales_conservation_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, national_redlist_category TEXT, habitat_pressure_text TEXT, last_assessment_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_thelephorales_conservation_status_species_id ON ord_thelephorales_conservation_status (species_id); CREATE INDEX ix_ord_thelephorales_conservation_status_country_id ON ord_thelephorales_conservation_status (country_id); CREATE TABLE ord_thelephorales_diagnostic_keys ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER, key_title TEXT NOT NULL, region_country_id INTEGER, n_taxa_covered INTEGER, key_format TEXT, includes_microscopy INTEGER NOT NULL DEFAULT 0, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_thelephorales_diagnostic_keys_publication_id ON ord_thelephorales_diagnostic_keys (publication_id); CREATE INDEX ix_ord_thelephorales_diagnostic_keys_region_country_id ON ord_thelephorales_diagnostic_keys (region_country_id); CREATE TABLE ord_thelephorales_type_species_register ( id INTEGER PRIMARY KEY AUTOINCREMENT, focal_genus_id INTEGER NOT NULL, type_species_id INTEGER, designation_publication_id INTEGER, designation_year INTEGER, designated_by_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (designation_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_thelephorales_type_species_register_focal_genus_id ON ord_thelephorales_type_species_register (focal_genus_id); CREATE INDEX ix_ord_thelephorales_type_species_register_type_species_id ON ord_thelephorales_type_species_register (type_species_id); CREATE TABLE ord_thelephorales_distribution_grids ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, grid_cell_code TEXT NOT NULL, centroid_lat REAL, centroid_lon REAL, record_count INTEGER, first_record_year INTEGER, most_recent_record_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_thelephorales_distribution_grids_species_id ON ord_thelephorales_distribution_grids (species_id); CREATE INDEX ix_ord_thelephorales_distribution_grids_country_id ON ord_thelephorales_distribution_grids (country_id); CREATE TABLE ord_thelephorales_microclimate_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER, publication_id INTEGER, substrate_temperature_c REAL, substrate_moisture_pct REAL, canopy_closure_pct REAL, photosynthetic_par_umol_m2_s REAL, days_post_rainfall INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_thelephorales_microclimate_studies_species_id ON ord_thelephorales_microclimate_studies (species_id); CREATE INDEX ix_ord_thelephorales_microclimate_studies_publication_id ON ord_thelephorales_microclimate_studies (publication_id); CREATE TABLE ord_thelephorales_dna_barcoding_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, its_sequenced INTEGER NOT NULL DEFAULT 0, lsu_sequenced INTEGER NOT NULL DEFAULT 0, rpb2_sequenced INTEGER NOT NULL DEFAULT 0, ef1a_sequenced INTEGER NOT NULL DEFAULT 0, genome_assembled INTEGER NOT NULL DEFAULT 0, priority_for_sequencing_score INTEGER CHECK (priority_for_sequencing_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_thelephorales_dna_barcoding_status_species_id ON ord_thelephorales_dna_barcoding_status (species_id); CREATE TABLE ord_thelephorales_spore_print_data ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, specimen_id INTEGER, print_color_label TEXT, print_color_chip_id INTEGER, spore_density_per_mm2 REAL, collection_substrate TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (print_color_chip_id) REFERENCES mor_color_chips (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_thelephorales_spore_print_data_species_id ON ord_thelephorales_spore_print_data (species_id); CREATE INDEX ix_ord_thelephorales_spore_print_data_specimen_id ON ord_thelephorales_spore_print_data (specimen_id); CREATE TABLE ord_thelephorales_mating_systems ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, system_type TEXT, mating_loci_count INTEGER, publication_id INTEGER, notes_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_thelephorales_mating_systems_species_id ON ord_thelephorales_mating_systems (species_id); CREATE INDEX ix_ord_thelephorales_mating_systems_publication_id ON ord_thelephorales_mating_systems (publication_id); CREATE TABLE ord_thelephorales_nutrient_uptake_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, nitrogen_source TEXT, carbon_source TEXT, growth_response TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_thelephorales_nutrient_uptake_studies_species_id ON ord_thelephorales_nutrient_uptake_studies (species_id); CREATE INDEX ix_ord_thelephorales_nutrient_uptake_studies_strain_id ON ord_thelephorales_nutrient_uptake_studies (strain_id); CREATE TABLE ord_thelephorales_range_maps ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, polygon_file_uri TEXT NOT NULL, source_methodology TEXT, area_km2 REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_thelephorales_range_maps_species_id ON ord_thelephorales_range_maps (species_id); CREATE INDEX ix_ord_thelephorales_range_maps_publication_id ON ord_thelephorales_range_maps (publication_id); CREATE TABLE ord_thelephorales_abundance_estimates ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, estimate_kind TEXT, value_min REAL, value_max REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_thelephorales_abundance_estimates_species_id ON ord_thelephorales_abundance_estimates (species_id); CREATE INDEX ix_ord_thelephorales_abundance_estimates_country_id ON ord_thelephorales_abundance_estimates (country_id); CREATE TABLE ord_thelephorales_toxin_profiles ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, presence TEXT, typical_concentration_mg_per_kg REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_thelephorales_toxin_profiles_species_id ON ord_thelephorales_toxin_profiles (species_id); CREATE INDEX ix_ord_thelephorales_toxin_profiles_compound_id ON ord_thelephorales_toxin_profiles (compound_id); CREATE TABLE ord_thelephorales_enzyme_activity_assays ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, enzyme_id INTEGER NOT NULL, strain_id INTEGER, activity_u_per_mg REAL, temperature_c REAL, ph REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (enzyme_id) REFERENCES bio_enzymes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_thelephorales_enzyme_activity_assays_species_id ON ord_thelephorales_enzyme_activity_assays (species_id); CREATE INDEX ix_ord_thelephorales_enzyme_activity_assays_enzyme_id ON ord_thelephorales_enzyme_activity_assays (enzyme_id); CREATE TABLE ord_thelephorales_biocontrol_evaluations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, target_pest_text TEXT NOT NULL, efficacy_pct REAL, trial_setting TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_thelephorales_biocontrol_evaluations_species_id ON ord_thelephorales_biocontrol_evaluations (species_id); CREATE INDEX ix_ord_thelephorales_biocontrol_evaluations_publication_id ON ord_thelephorales_biocontrol_evaluations (publication_id); CREATE TABLE ord_thelephorales_regional_checklists ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, checklist_publication_id INTEGER, status TEXT, checklist_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (checklist_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_thelephorales_regional_checklists_species_id ON ord_thelephorales_regional_checklists (species_id); CREATE INDEX ix_ord_thelephorales_regional_checklists_country_id ON ord_thelephorales_regional_checklists (country_id); CREATE TABLE ord_cantharellales_morphology ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, hymenium_color_at_maturity TEXT, context_color_at_maturity TEXT, characteristic_microstructure TEXT, diagnostic_features_text TEXT, notes_kohler_reaction TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_cantharellales_morphology_specimen_id ON ord_cantharellales_morphology (specimen_id); CREATE INDEX ix_ord_cantharellales_morphology_species_id ON ord_cantharellales_morphology (species_id); CREATE TABLE ord_cantharellales_ecology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, dominant_habitat_id INTEGER, dominant_substrate_id INTEGER, dominant_biome_id INTEGER, trophic_strategy TEXT, typical_fruiting_period TEXT, known_distribution_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_habitat_id) REFERENCES eco_habitat_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_substrate_id) REFERENCES eco_substrate_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_biome_id) REFERENCES geo_biomes (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_cantharellales_ecology_species_id ON ord_cantharellales_ecology (species_id); CREATE INDEX ix_ord_cantharellales_ecology_dominant_habitat_id ON ord_cantharellales_ecology (dominant_habitat_id); CREATE TABLE ord_cantharellales_phenology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, season_name TEXT, region_country_id INTEGER, first_doy INTEGER, peak_doy INTEGER, last_doy INTEGER, years_observed INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_cantharellales_phenology_species_id ON ord_cantharellales_phenology (species_id); CREATE INDEX ix_ord_cantharellales_phenology_region_country_id ON ord_cantharellales_phenology (region_country_id); CREATE TABLE ord_cantharellales_host_associations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, association_type TEXT, specificity TEXT, evidence_publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (evidence_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_cantharellales_host_associations_species_id ON ord_cantharellales_host_associations (species_id); CREATE INDEX ix_ord_cantharellales_host_associations_host_id ON ord_cantharellales_host_associations (host_id); CREATE TABLE ord_cantharellales_substrate_preferences ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, substrate_id INTEGER NOT NULL, preference_score REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (substrate_id) REFERENCES eco_substrate_types (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_cantharellales_substrate_preferences_species_id ON ord_cantharellales_substrate_preferences (species_id); CREATE INDEX ix_ord_cantharellales_substrate_preferences_substrate_id ON ord_cantharellales_substrate_preferences (substrate_id); CREATE TABLE ord_cantharellales_geographic_distribution ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, occurrence_status TEXT, first_record_year INTEGER, record_count INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_cantharellales_geographic_distribution_species_id ON ord_cantharellales_geographic_distribution (species_id); CREATE INDEX ix_ord_cantharellales_geographic_distribution_country_id ON ord_cantharellales_geographic_distribution (country_id); CREATE TABLE ord_cantharellales_phylogeny ( id INTEGER PRIMARY KEY AUTOINCREMENT, tree_id INTEGER NOT NULL, focal_genus_id INTEGER, publication_id INTEGER, notes_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (tree_id) REFERENCES phy_trees (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_cantharellales_phylogeny_tree_id ON ord_cantharellales_phylogeny (tree_id); CREATE INDEX ix_ord_cantharellales_phylogeny_focal_genus_id ON ord_cantharellales_phylogeny (focal_genus_id); CREATE TABLE ord_cantharellales_genomics ( id INTEGER PRIMARY KEY AUTOINCREMENT, assembly_id INTEGER NOT NULL, species_id INTEGER, avg_genome_size_mb REAL, avg_gene_count INTEGER, avg_busco_complete_pct REAL, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (assembly_id) REFERENCES gen_assemblies (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_cantharellales_genomics_assembly_id ON ord_cantharellales_genomics (assembly_id); CREATE INDEX ix_ord_cantharellales_genomics_species_id ON ord_cantharellales_genomics (species_id); CREATE TABLE ord_cantharellales_biochemistry ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, typicality TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_cantharellales_biochemistry_species_id ON ord_cantharellales_biochemistry (species_id); CREATE INDEX ix_ord_cantharellales_biochemistry_compound_id ON ord_cantharellales_biochemistry (compound_id); CREATE TABLE ord_cantharellales_cultivation_notes ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, typical_growth_rate_mm_per_day REAL, preferred_media_type_id INTEGER, optimal_temperature_c REAL, difficulty_score INTEGER CHECK (difficulty_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (preferred_media_type_id) REFERENCES cul_media_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_cantharellales_cultivation_notes_species_id ON ord_cantharellales_cultivation_notes (species_id); CREATE INDEX ix_ord_cantharellales_cultivation_notes_strain_id ON ord_cantharellales_cultivation_notes (strain_id); CREATE TABLE ord_cantharellales_pathogenicity ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, disease_id INTEGER, severity_score INTEGER CHECK (severity_score BETWEEN 1 AND 5), publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (disease_id) REFERENCES pat_diseases (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_cantharellales_pathogenicity_species_id ON ord_cantharellales_pathogenicity (species_id); CREATE INDEX ix_ord_cantharellales_pathogenicity_host_id ON ord_cantharellales_pathogenicity (host_id); CREATE TABLE ord_cantharellales_edibility ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, edibility_class TEXT, preparation_notes TEXT, regional_tradition_country_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (regional_tradition_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_cantharellales_edibility_species_id ON ord_cantharellales_edibility (species_id); CREATE INDEX ix_ord_cantharellales_edibility_1 ON ord_cantharellales_edibility (regional_tradition_country_id); CREATE TABLE ord_cantharellales_medicinal_uses ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, traditional_use_text TEXT, modern_evidence_level TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_cantharellales_medicinal_uses_species_id ON ord_cantharellales_medicinal_uses (species_id); CREATE INDEX ix_ord_cantharellales_medicinal_uses_publication_id ON ord_cantharellales_medicinal_uses (publication_id); CREATE TABLE ord_cantharellales_taxonomic_revisions ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER NOT NULL, affected_family_id INTEGER, affected_genus_id INTEGER, revision_summary TEXT, revision_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_family_id) REFERENCES tax_families (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_cantharellales_taxonomic_revisions_publication_id ON ord_cantharellales_taxonomic_revisions (publication_id); CREATE INDEX ix_ord_cantharellales_taxonomic_revisions_affected_family_id ON ord_cantharellales_taxonomic_revisions (affected_family_id); CREATE TABLE ord_cantharellales_conservation_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, national_redlist_category TEXT, habitat_pressure_text TEXT, last_assessment_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_cantharellales_conservation_status_species_id ON ord_cantharellales_conservation_status (species_id); CREATE INDEX ix_ord_cantharellales_conservation_status_country_id ON ord_cantharellales_conservation_status (country_id); CREATE TABLE ord_cantharellales_diagnostic_keys ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER, key_title TEXT NOT NULL, region_country_id INTEGER, n_taxa_covered INTEGER, key_format TEXT, includes_microscopy INTEGER NOT NULL DEFAULT 0, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_cantharellales_diagnostic_keys_publication_id ON ord_cantharellales_diagnostic_keys (publication_id); CREATE INDEX ix_ord_cantharellales_diagnostic_keys_region_country_id ON ord_cantharellales_diagnostic_keys (region_country_id); CREATE TABLE ord_cantharellales_type_species_register ( id INTEGER PRIMARY KEY AUTOINCREMENT, focal_genus_id INTEGER NOT NULL, type_species_id INTEGER, designation_publication_id INTEGER, designation_year INTEGER, designated_by_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (designation_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_cantharellales_type_species_register_focal_genus_id ON ord_cantharellales_type_species_register (focal_genus_id); CREATE INDEX ix_ord_cantharellales_type_species_register_type_species_id ON ord_cantharellales_type_species_register (type_species_id); CREATE TABLE ord_cantharellales_distribution_grids ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, grid_cell_code TEXT NOT NULL, centroid_lat REAL, centroid_lon REAL, record_count INTEGER, first_record_year INTEGER, most_recent_record_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_cantharellales_distribution_grids_species_id ON ord_cantharellales_distribution_grids (species_id); CREATE INDEX ix_ord_cantharellales_distribution_grids_country_id ON ord_cantharellales_distribution_grids (country_id); CREATE TABLE ord_cantharellales_microclimate_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER, publication_id INTEGER, substrate_temperature_c REAL, substrate_moisture_pct REAL, canopy_closure_pct REAL, photosynthetic_par_umol_m2_s REAL, days_post_rainfall INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_cantharellales_microclimate_studies_species_id ON ord_cantharellales_microclimate_studies (species_id); CREATE INDEX ix_ord_cantharellales_microclimate_studies_publication_id ON ord_cantharellales_microclimate_studies (publication_id); CREATE TABLE ord_cantharellales_dna_barcoding_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, its_sequenced INTEGER NOT NULL DEFAULT 0, lsu_sequenced INTEGER NOT NULL DEFAULT 0, rpb2_sequenced INTEGER NOT NULL DEFAULT 0, ef1a_sequenced INTEGER NOT NULL DEFAULT 0, genome_assembled INTEGER NOT NULL DEFAULT 0, priority_for_sequencing_score INTEGER CHECK (priority_for_sequencing_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_cantharellales_dna_barcoding_status_species_id ON ord_cantharellales_dna_barcoding_status (species_id); CREATE TABLE ord_cantharellales_spore_print_data ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, specimen_id INTEGER, print_color_label TEXT, print_color_chip_id INTEGER, spore_density_per_mm2 REAL, collection_substrate TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (print_color_chip_id) REFERENCES mor_color_chips (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_cantharellales_spore_print_data_species_id ON ord_cantharellales_spore_print_data (species_id); CREATE INDEX ix_ord_cantharellales_spore_print_data_specimen_id ON ord_cantharellales_spore_print_data (specimen_id); CREATE TABLE ord_cantharellales_mating_systems ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, system_type TEXT, mating_loci_count INTEGER, publication_id INTEGER, notes_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_cantharellales_mating_systems_species_id ON ord_cantharellales_mating_systems (species_id); CREATE INDEX ix_ord_cantharellales_mating_systems_publication_id ON ord_cantharellales_mating_systems (publication_id); CREATE TABLE ord_cantharellales_nutrient_uptake_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, nitrogen_source TEXT, carbon_source TEXT, growth_response TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_cantharellales_nutrient_uptake_studies_species_id ON ord_cantharellales_nutrient_uptake_studies (species_id); CREATE INDEX ix_ord_cantharellales_nutrient_uptake_studies_strain_id ON ord_cantharellales_nutrient_uptake_studies (strain_id); CREATE TABLE ord_cantharellales_range_maps ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, polygon_file_uri TEXT NOT NULL, source_methodology TEXT, area_km2 REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_cantharellales_range_maps_species_id ON ord_cantharellales_range_maps (species_id); CREATE INDEX ix_ord_cantharellales_range_maps_publication_id ON ord_cantharellales_range_maps (publication_id); CREATE TABLE ord_cantharellales_abundance_estimates ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, estimate_kind TEXT, value_min REAL, value_max REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_cantharellales_abundance_estimates_species_id ON ord_cantharellales_abundance_estimates (species_id); CREATE INDEX ix_ord_cantharellales_abundance_estimates_country_id ON ord_cantharellales_abundance_estimates (country_id); CREATE TABLE ord_cantharellales_toxin_profiles ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, presence TEXT, typical_concentration_mg_per_kg REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_cantharellales_toxin_profiles_species_id ON ord_cantharellales_toxin_profiles (species_id); CREATE INDEX ix_ord_cantharellales_toxin_profiles_compound_id ON ord_cantharellales_toxin_profiles (compound_id); CREATE TABLE ord_cantharellales_enzyme_activity_assays ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, enzyme_id INTEGER NOT NULL, strain_id INTEGER, activity_u_per_mg REAL, temperature_c REAL, ph REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (enzyme_id) REFERENCES bio_enzymes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_cantharellales_enzyme_activity_assays_species_id ON ord_cantharellales_enzyme_activity_assays (species_id); CREATE INDEX ix_ord_cantharellales_enzyme_activity_assays_enzyme_id ON ord_cantharellales_enzyme_activity_assays (enzyme_id); CREATE TABLE ord_cantharellales_biocontrol_evaluations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, target_pest_text TEXT NOT NULL, efficacy_pct REAL, trial_setting TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_cantharellales_biocontrol_evaluations_species_id ON ord_cantharellales_biocontrol_evaluations (species_id); CREATE INDEX ix_ord_cantharellales_biocontrol_evaluations_publication_id ON ord_cantharellales_biocontrol_evaluations (publication_id); CREATE TABLE ord_cantharellales_regional_checklists ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, checklist_publication_id INTEGER, status TEXT, checklist_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (checklist_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_cantharellales_regional_checklists_species_id ON ord_cantharellales_regional_checklists (species_id); CREATE INDEX ix_ord_cantharellales_regional_checklists_country_id ON ord_cantharellales_regional_checklists (country_id); CREATE TABLE ord_hymenochaetales_morphology ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, hymenium_color_at_maturity TEXT, context_color_at_maturity TEXT, characteristic_microstructure TEXT, diagnostic_features_text TEXT, notes_kohler_reaction TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_hymenochaetales_morphology_specimen_id ON ord_hymenochaetales_morphology (specimen_id); CREATE INDEX ix_ord_hymenochaetales_morphology_species_id ON ord_hymenochaetales_morphology (species_id); CREATE TABLE ord_hymenochaetales_ecology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, dominant_habitat_id INTEGER, dominant_substrate_id INTEGER, dominant_biome_id INTEGER, trophic_strategy TEXT, typical_fruiting_period TEXT, known_distribution_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_habitat_id) REFERENCES eco_habitat_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_substrate_id) REFERENCES eco_substrate_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_biome_id) REFERENCES geo_biomes (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_hymenochaetales_ecology_species_id ON ord_hymenochaetales_ecology (species_id); CREATE INDEX ix_ord_hymenochaetales_ecology_dominant_habitat_id ON ord_hymenochaetales_ecology (dominant_habitat_id); CREATE TABLE ord_hymenochaetales_phenology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, season_name TEXT, region_country_id INTEGER, first_doy INTEGER, peak_doy INTEGER, last_doy INTEGER, years_observed INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_hymenochaetales_phenology_species_id ON ord_hymenochaetales_phenology (species_id); CREATE INDEX ix_ord_hymenochaetales_phenology_region_country_id ON ord_hymenochaetales_phenology (region_country_id); CREATE TABLE ord_hymenochaetales_host_associations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, association_type TEXT, specificity TEXT, evidence_publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (evidence_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_hymenochaetales_host_associations_species_id ON ord_hymenochaetales_host_associations (species_id); CREATE INDEX ix_ord_hymenochaetales_host_associations_host_id ON ord_hymenochaetales_host_associations (host_id); CREATE TABLE ord_hymenochaetales_substrate_preferences ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, substrate_id INTEGER NOT NULL, preference_score REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (substrate_id) REFERENCES eco_substrate_types (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_hymenochaetales_substrate_preferences_species_id ON ord_hymenochaetales_substrate_preferences (species_id); CREATE INDEX ix_ord_hymenochaetales_substrate_preferences_substrate_id ON ord_hymenochaetales_substrate_preferences (substrate_id); CREATE TABLE ord_hymenochaetales_geographic_distribution ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, occurrence_status TEXT, first_record_year INTEGER, record_count INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_hymenochaetales_geographic_distribution_species_id ON ord_hymenochaetales_geographic_distribution (species_id); CREATE INDEX ix_ord_hymenochaetales_geographic_distribution_country_id ON ord_hymenochaetales_geographic_distribution (country_id); CREATE TABLE ord_hymenochaetales_phylogeny ( id INTEGER PRIMARY KEY AUTOINCREMENT, tree_id INTEGER NOT NULL, focal_genus_id INTEGER, publication_id INTEGER, notes_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (tree_id) REFERENCES phy_trees (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_hymenochaetales_phylogeny_tree_id ON ord_hymenochaetales_phylogeny (tree_id); CREATE INDEX ix_ord_hymenochaetales_phylogeny_focal_genus_id ON ord_hymenochaetales_phylogeny (focal_genus_id); CREATE TABLE ord_hymenochaetales_genomics ( id INTEGER PRIMARY KEY AUTOINCREMENT, assembly_id INTEGER NOT NULL, species_id INTEGER, avg_genome_size_mb REAL, avg_gene_count INTEGER, avg_busco_complete_pct REAL, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (assembly_id) REFERENCES gen_assemblies (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_hymenochaetales_genomics_assembly_id ON ord_hymenochaetales_genomics (assembly_id); CREATE INDEX ix_ord_hymenochaetales_genomics_species_id ON ord_hymenochaetales_genomics (species_id); CREATE TABLE ord_hymenochaetales_biochemistry ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, typicality TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_hymenochaetales_biochemistry_species_id ON ord_hymenochaetales_biochemistry (species_id); CREATE INDEX ix_ord_hymenochaetales_biochemistry_compound_id ON ord_hymenochaetales_biochemistry (compound_id); CREATE TABLE ord_hymenochaetales_cultivation_notes ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, typical_growth_rate_mm_per_day REAL, preferred_media_type_id INTEGER, optimal_temperature_c REAL, difficulty_score INTEGER CHECK (difficulty_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (preferred_media_type_id) REFERENCES cul_media_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_hymenochaetales_cultivation_notes_species_id ON ord_hymenochaetales_cultivation_notes (species_id); CREATE INDEX ix_ord_hymenochaetales_cultivation_notes_strain_id ON ord_hymenochaetales_cultivation_notes (strain_id); CREATE TABLE ord_hymenochaetales_pathogenicity ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, disease_id INTEGER, severity_score INTEGER CHECK (severity_score BETWEEN 1 AND 5), publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (disease_id) REFERENCES pat_diseases (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_hymenochaetales_pathogenicity_species_id ON ord_hymenochaetales_pathogenicity (species_id); CREATE INDEX ix_ord_hymenochaetales_pathogenicity_host_id ON ord_hymenochaetales_pathogenicity (host_id); CREATE TABLE ord_hymenochaetales_edibility ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, edibility_class TEXT, preparation_notes TEXT, regional_tradition_country_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (regional_tradition_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_hymenochaetales_edibility_species_id ON ord_hymenochaetales_edibility (species_id); CREATE INDEX ix_ord_hymenochaetales_edibility_1 ON ord_hymenochaetales_edibility (regional_tradition_country_id); CREATE TABLE ord_hymenochaetales_medicinal_uses ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, traditional_use_text TEXT, modern_evidence_level TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_hymenochaetales_medicinal_uses_species_id ON ord_hymenochaetales_medicinal_uses (species_id); CREATE INDEX ix_ord_hymenochaetales_medicinal_uses_publication_id ON ord_hymenochaetales_medicinal_uses (publication_id); CREATE TABLE ord_hymenochaetales_taxonomic_revisions ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER NOT NULL, affected_family_id INTEGER, affected_genus_id INTEGER, revision_summary TEXT, revision_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_family_id) REFERENCES tax_families (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_hymenochaetales_taxonomic_revisions_publication_id ON ord_hymenochaetales_taxonomic_revisions (publication_id); CREATE INDEX ix_ord_hymenochaetales_taxonomic_revisions_1 ON ord_hymenochaetales_taxonomic_revisions (affected_family_id); CREATE TABLE ord_hymenochaetales_conservation_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, national_redlist_category TEXT, habitat_pressure_text TEXT, last_assessment_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_hymenochaetales_conservation_status_species_id ON ord_hymenochaetales_conservation_status (species_id); CREATE INDEX ix_ord_hymenochaetales_conservation_status_country_id ON ord_hymenochaetales_conservation_status (country_id); CREATE TABLE ord_hymenochaetales_diagnostic_keys ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER, key_title TEXT NOT NULL, region_country_id INTEGER, n_taxa_covered INTEGER, key_format TEXT, includes_microscopy INTEGER NOT NULL DEFAULT 0, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_hymenochaetales_diagnostic_keys_publication_id ON ord_hymenochaetales_diagnostic_keys (publication_id); CREATE INDEX ix_ord_hymenochaetales_diagnostic_keys_region_country_id ON ord_hymenochaetales_diagnostic_keys (region_country_id); CREATE TABLE ord_hymenochaetales_type_species_register ( id INTEGER PRIMARY KEY AUTOINCREMENT, focal_genus_id INTEGER NOT NULL, type_species_id INTEGER, designation_publication_id INTEGER, designation_year INTEGER, designated_by_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (designation_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_hymenochaetales_type_species_register_focal_genus_id ON ord_hymenochaetales_type_species_register (focal_genus_id); CREATE INDEX ix_ord_hymenochaetales_type_species_register_type_species_id ON ord_hymenochaetales_type_species_register (type_species_id); CREATE TABLE ord_hymenochaetales_distribution_grids ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, grid_cell_code TEXT NOT NULL, centroid_lat REAL, centroid_lon REAL, record_count INTEGER, first_record_year INTEGER, most_recent_record_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_hymenochaetales_distribution_grids_species_id ON ord_hymenochaetales_distribution_grids (species_id); CREATE INDEX ix_ord_hymenochaetales_distribution_grids_country_id ON ord_hymenochaetales_distribution_grids (country_id); CREATE TABLE ord_hymenochaetales_microclimate_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER, publication_id INTEGER, substrate_temperature_c REAL, substrate_moisture_pct REAL, canopy_closure_pct REAL, photosynthetic_par_umol_m2_s REAL, days_post_rainfall INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_hymenochaetales_microclimate_studies_species_id ON ord_hymenochaetales_microclimate_studies (species_id); CREATE INDEX ix_ord_hymenochaetales_microclimate_studies_publication_id ON ord_hymenochaetales_microclimate_studies (publication_id); CREATE TABLE ord_hymenochaetales_dna_barcoding_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, its_sequenced INTEGER NOT NULL DEFAULT 0, lsu_sequenced INTEGER NOT NULL DEFAULT 0, rpb2_sequenced INTEGER NOT NULL DEFAULT 0, ef1a_sequenced INTEGER NOT NULL DEFAULT 0, genome_assembled INTEGER NOT NULL DEFAULT 0, priority_for_sequencing_score INTEGER CHECK (priority_for_sequencing_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_hymenochaetales_dna_barcoding_status_species_id ON ord_hymenochaetales_dna_barcoding_status (species_id); CREATE TABLE ord_hymenochaetales_spore_print_data ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, specimen_id INTEGER, print_color_label TEXT, print_color_chip_id INTEGER, spore_density_per_mm2 REAL, collection_substrate TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (print_color_chip_id) REFERENCES mor_color_chips (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_hymenochaetales_spore_print_data_species_id ON ord_hymenochaetales_spore_print_data (species_id); CREATE INDEX ix_ord_hymenochaetales_spore_print_data_specimen_id ON ord_hymenochaetales_spore_print_data (specimen_id); CREATE TABLE ord_hymenochaetales_mating_systems ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, system_type TEXT, mating_loci_count INTEGER, publication_id INTEGER, notes_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_hymenochaetales_mating_systems_species_id ON ord_hymenochaetales_mating_systems (species_id); CREATE INDEX ix_ord_hymenochaetales_mating_systems_publication_id ON ord_hymenochaetales_mating_systems (publication_id); CREATE TABLE ord_hymenochaetales_nutrient_uptake_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, nitrogen_source TEXT, carbon_source TEXT, growth_response TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_hymenochaetales_nutrient_uptake_studies_species_id ON ord_hymenochaetales_nutrient_uptake_studies (species_id); CREATE INDEX ix_ord_hymenochaetales_nutrient_uptake_studies_strain_id ON ord_hymenochaetales_nutrient_uptake_studies (strain_id); CREATE TABLE ord_hymenochaetales_range_maps ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, polygon_file_uri TEXT NOT NULL, source_methodology TEXT, area_km2 REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_hymenochaetales_range_maps_species_id ON ord_hymenochaetales_range_maps (species_id); CREATE INDEX ix_ord_hymenochaetales_range_maps_publication_id ON ord_hymenochaetales_range_maps (publication_id); CREATE TABLE ord_hymenochaetales_abundance_estimates ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, estimate_kind TEXT, value_min REAL, value_max REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_hymenochaetales_abundance_estimates_species_id ON ord_hymenochaetales_abundance_estimates (species_id); CREATE INDEX ix_ord_hymenochaetales_abundance_estimates_country_id ON ord_hymenochaetales_abundance_estimates (country_id); CREATE TABLE ord_hymenochaetales_toxin_profiles ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, presence TEXT, typical_concentration_mg_per_kg REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_hymenochaetales_toxin_profiles_species_id ON ord_hymenochaetales_toxin_profiles (species_id); CREATE INDEX ix_ord_hymenochaetales_toxin_profiles_compound_id ON ord_hymenochaetales_toxin_profiles (compound_id); CREATE TABLE ord_hymenochaetales_enzyme_activity_assays ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, enzyme_id INTEGER NOT NULL, strain_id INTEGER, activity_u_per_mg REAL, temperature_c REAL, ph REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (enzyme_id) REFERENCES bio_enzymes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_hymenochaetales_enzyme_activity_assays_species_id ON ord_hymenochaetales_enzyme_activity_assays (species_id); CREATE INDEX ix_ord_hymenochaetales_enzyme_activity_assays_enzyme_id ON ord_hymenochaetales_enzyme_activity_assays (enzyme_id); CREATE TABLE ord_hymenochaetales_biocontrol_evaluations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, target_pest_text TEXT NOT NULL, efficacy_pct REAL, trial_setting TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_hymenochaetales_biocontrol_evaluations_species_id ON ord_hymenochaetales_biocontrol_evaluations (species_id); CREATE INDEX ix_ord_hymenochaetales_biocontrol_evaluations_publication_id ON ord_hymenochaetales_biocontrol_evaluations (publication_id); CREATE TABLE ord_hymenochaetales_regional_checklists ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, checklist_publication_id INTEGER, status TEXT, checklist_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (checklist_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_hymenochaetales_regional_checklists_species_id ON ord_hymenochaetales_regional_checklists (species_id); CREATE INDEX ix_ord_hymenochaetales_regional_checklists_country_id ON ord_hymenochaetales_regional_checklists (country_id); CREATE TABLE ord_auriculariales_morphology ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, hymenium_color_at_maturity TEXT, context_color_at_maturity TEXT, characteristic_microstructure TEXT, diagnostic_features_text TEXT, notes_kohler_reaction TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_auriculariales_morphology_specimen_id ON ord_auriculariales_morphology (specimen_id); CREATE INDEX ix_ord_auriculariales_morphology_species_id ON ord_auriculariales_morphology (species_id); CREATE TABLE ord_auriculariales_ecology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, dominant_habitat_id INTEGER, dominant_substrate_id INTEGER, dominant_biome_id INTEGER, trophic_strategy TEXT, typical_fruiting_period TEXT, known_distribution_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_habitat_id) REFERENCES eco_habitat_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_substrate_id) REFERENCES eco_substrate_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_biome_id) REFERENCES geo_biomes (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_auriculariales_ecology_species_id ON ord_auriculariales_ecology (species_id); CREATE INDEX ix_ord_auriculariales_ecology_dominant_habitat_id ON ord_auriculariales_ecology (dominant_habitat_id); CREATE TABLE ord_auriculariales_phenology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, season_name TEXT, region_country_id INTEGER, first_doy INTEGER, peak_doy INTEGER, last_doy INTEGER, years_observed INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_auriculariales_phenology_species_id ON ord_auriculariales_phenology (species_id); CREATE INDEX ix_ord_auriculariales_phenology_region_country_id ON ord_auriculariales_phenology (region_country_id); CREATE TABLE ord_auriculariales_host_associations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, association_type TEXT, specificity TEXT, evidence_publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (evidence_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_auriculariales_host_associations_species_id ON ord_auriculariales_host_associations (species_id); CREATE INDEX ix_ord_auriculariales_host_associations_host_id ON ord_auriculariales_host_associations (host_id); CREATE TABLE ord_auriculariales_substrate_preferences ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, substrate_id INTEGER NOT NULL, preference_score REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (substrate_id) REFERENCES eco_substrate_types (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_auriculariales_substrate_preferences_species_id ON ord_auriculariales_substrate_preferences (species_id); CREATE INDEX ix_ord_auriculariales_substrate_preferences_substrate_id ON ord_auriculariales_substrate_preferences (substrate_id); CREATE TABLE ord_auriculariales_geographic_distribution ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, occurrence_status TEXT, first_record_year INTEGER, record_count INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_auriculariales_geographic_distribution_species_id ON ord_auriculariales_geographic_distribution (species_id); CREATE INDEX ix_ord_auriculariales_geographic_distribution_country_id ON ord_auriculariales_geographic_distribution (country_id); CREATE TABLE ord_auriculariales_phylogeny ( id INTEGER PRIMARY KEY AUTOINCREMENT, tree_id INTEGER NOT NULL, focal_genus_id INTEGER, publication_id INTEGER, notes_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (tree_id) REFERENCES phy_trees (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_auriculariales_phylogeny_tree_id ON ord_auriculariales_phylogeny (tree_id); CREATE INDEX ix_ord_auriculariales_phylogeny_focal_genus_id ON ord_auriculariales_phylogeny (focal_genus_id); CREATE TABLE ord_auriculariales_genomics ( id INTEGER PRIMARY KEY AUTOINCREMENT, assembly_id INTEGER NOT NULL, species_id INTEGER, avg_genome_size_mb REAL, avg_gene_count INTEGER, avg_busco_complete_pct REAL, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (assembly_id) REFERENCES gen_assemblies (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_auriculariales_genomics_assembly_id ON ord_auriculariales_genomics (assembly_id); CREATE INDEX ix_ord_auriculariales_genomics_species_id ON ord_auriculariales_genomics (species_id); CREATE TABLE ord_auriculariales_biochemistry ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, typicality TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_auriculariales_biochemistry_species_id ON ord_auriculariales_biochemistry (species_id); CREATE INDEX ix_ord_auriculariales_biochemistry_compound_id ON ord_auriculariales_biochemistry (compound_id); CREATE TABLE ord_auriculariales_cultivation_notes ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, typical_growth_rate_mm_per_day REAL, preferred_media_type_id INTEGER, optimal_temperature_c REAL, difficulty_score INTEGER CHECK (difficulty_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (preferred_media_type_id) REFERENCES cul_media_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_auriculariales_cultivation_notes_species_id ON ord_auriculariales_cultivation_notes (species_id); CREATE INDEX ix_ord_auriculariales_cultivation_notes_strain_id ON ord_auriculariales_cultivation_notes (strain_id); CREATE TABLE ord_auriculariales_pathogenicity ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, disease_id INTEGER, severity_score INTEGER CHECK (severity_score BETWEEN 1 AND 5), publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (disease_id) REFERENCES pat_diseases (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_auriculariales_pathogenicity_species_id ON ord_auriculariales_pathogenicity (species_id); CREATE INDEX ix_ord_auriculariales_pathogenicity_host_id ON ord_auriculariales_pathogenicity (host_id); CREATE TABLE ord_auriculariales_edibility ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, edibility_class TEXT, preparation_notes TEXT, regional_tradition_country_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (regional_tradition_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_auriculariales_edibility_species_id ON ord_auriculariales_edibility (species_id); CREATE INDEX ix_ord_auriculariales_edibility_1 ON ord_auriculariales_edibility (regional_tradition_country_id); CREATE TABLE ord_auriculariales_medicinal_uses ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, traditional_use_text TEXT, modern_evidence_level TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_auriculariales_medicinal_uses_species_id ON ord_auriculariales_medicinal_uses (species_id); CREATE INDEX ix_ord_auriculariales_medicinal_uses_publication_id ON ord_auriculariales_medicinal_uses (publication_id); CREATE TABLE ord_auriculariales_taxonomic_revisions ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER NOT NULL, affected_family_id INTEGER, affected_genus_id INTEGER, revision_summary TEXT, revision_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_family_id) REFERENCES tax_families (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_auriculariales_taxonomic_revisions_publication_id ON ord_auriculariales_taxonomic_revisions (publication_id); CREATE INDEX ix_ord_auriculariales_taxonomic_revisions_affected_family_id ON ord_auriculariales_taxonomic_revisions (affected_family_id); CREATE TABLE ord_auriculariales_conservation_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, national_redlist_category TEXT, habitat_pressure_text TEXT, last_assessment_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_auriculariales_conservation_status_species_id ON ord_auriculariales_conservation_status (species_id); CREATE INDEX ix_ord_auriculariales_conservation_status_country_id ON ord_auriculariales_conservation_status (country_id); CREATE TABLE ord_auriculariales_diagnostic_keys ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER, key_title TEXT NOT NULL, region_country_id INTEGER, n_taxa_covered INTEGER, key_format TEXT, includes_microscopy INTEGER NOT NULL DEFAULT 0, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_auriculariales_diagnostic_keys_publication_id ON ord_auriculariales_diagnostic_keys (publication_id); CREATE INDEX ix_ord_auriculariales_diagnostic_keys_region_country_id ON ord_auriculariales_diagnostic_keys (region_country_id); CREATE TABLE ord_auriculariales_type_species_register ( id INTEGER PRIMARY KEY AUTOINCREMENT, focal_genus_id INTEGER NOT NULL, type_species_id INTEGER, designation_publication_id INTEGER, designation_year INTEGER, designated_by_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (designation_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_auriculariales_type_species_register_focal_genus_id ON ord_auriculariales_type_species_register (focal_genus_id); CREATE INDEX ix_ord_auriculariales_type_species_register_type_species_id ON ord_auriculariales_type_species_register (type_species_id); CREATE TABLE ord_auriculariales_distribution_grids ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, grid_cell_code TEXT NOT NULL, centroid_lat REAL, centroid_lon REAL, record_count INTEGER, first_record_year INTEGER, most_recent_record_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_auriculariales_distribution_grids_species_id ON ord_auriculariales_distribution_grids (species_id); CREATE INDEX ix_ord_auriculariales_distribution_grids_country_id ON ord_auriculariales_distribution_grids (country_id); CREATE TABLE ord_auriculariales_microclimate_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER, publication_id INTEGER, substrate_temperature_c REAL, substrate_moisture_pct REAL, canopy_closure_pct REAL, photosynthetic_par_umol_m2_s REAL, days_post_rainfall INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_auriculariales_microclimate_studies_species_id ON ord_auriculariales_microclimate_studies (species_id); CREATE INDEX ix_ord_auriculariales_microclimate_studies_publication_id ON ord_auriculariales_microclimate_studies (publication_id); CREATE TABLE ord_auriculariales_dna_barcoding_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, its_sequenced INTEGER NOT NULL DEFAULT 0, lsu_sequenced INTEGER NOT NULL DEFAULT 0, rpb2_sequenced INTEGER NOT NULL DEFAULT 0, ef1a_sequenced INTEGER NOT NULL DEFAULT 0, genome_assembled INTEGER NOT NULL DEFAULT 0, priority_for_sequencing_score INTEGER CHECK (priority_for_sequencing_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_auriculariales_dna_barcoding_status_species_id ON ord_auriculariales_dna_barcoding_status (species_id); CREATE TABLE ord_auriculariales_spore_print_data ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, specimen_id INTEGER, print_color_label TEXT, print_color_chip_id INTEGER, spore_density_per_mm2 REAL, collection_substrate TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (print_color_chip_id) REFERENCES mor_color_chips (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_auriculariales_spore_print_data_species_id ON ord_auriculariales_spore_print_data (species_id); CREATE INDEX ix_ord_auriculariales_spore_print_data_specimen_id ON ord_auriculariales_spore_print_data (specimen_id); CREATE TABLE ord_auriculariales_mating_systems ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, system_type TEXT, mating_loci_count INTEGER, publication_id INTEGER, notes_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_auriculariales_mating_systems_species_id ON ord_auriculariales_mating_systems (species_id); CREATE INDEX ix_ord_auriculariales_mating_systems_publication_id ON ord_auriculariales_mating_systems (publication_id); CREATE TABLE ord_auriculariales_nutrient_uptake_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, nitrogen_source TEXT, carbon_source TEXT, growth_response TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_auriculariales_nutrient_uptake_studies_species_id ON ord_auriculariales_nutrient_uptake_studies (species_id); CREATE INDEX ix_ord_auriculariales_nutrient_uptake_studies_strain_id ON ord_auriculariales_nutrient_uptake_studies (strain_id); CREATE TABLE ord_auriculariales_range_maps ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, polygon_file_uri TEXT NOT NULL, source_methodology TEXT, area_km2 REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_auriculariales_range_maps_species_id ON ord_auriculariales_range_maps (species_id); CREATE INDEX ix_ord_auriculariales_range_maps_publication_id ON ord_auriculariales_range_maps (publication_id); CREATE TABLE ord_auriculariales_abundance_estimates ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, estimate_kind TEXT, value_min REAL, value_max REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_auriculariales_abundance_estimates_species_id ON ord_auriculariales_abundance_estimates (species_id); CREATE INDEX ix_ord_auriculariales_abundance_estimates_country_id ON ord_auriculariales_abundance_estimates (country_id); CREATE TABLE ord_auriculariales_toxin_profiles ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, presence TEXT, typical_concentration_mg_per_kg REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_auriculariales_toxin_profiles_species_id ON ord_auriculariales_toxin_profiles (species_id); CREATE INDEX ix_ord_auriculariales_toxin_profiles_compound_id ON ord_auriculariales_toxin_profiles (compound_id); CREATE TABLE ord_auriculariales_enzyme_activity_assays ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, enzyme_id INTEGER NOT NULL, strain_id INTEGER, activity_u_per_mg REAL, temperature_c REAL, ph REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (enzyme_id) REFERENCES bio_enzymes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_auriculariales_enzyme_activity_assays_species_id ON ord_auriculariales_enzyme_activity_assays (species_id); CREATE INDEX ix_ord_auriculariales_enzyme_activity_assays_enzyme_id ON ord_auriculariales_enzyme_activity_assays (enzyme_id); CREATE TABLE ord_auriculariales_biocontrol_evaluations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, target_pest_text TEXT NOT NULL, efficacy_pct REAL, trial_setting TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_auriculariales_biocontrol_evaluations_species_id ON ord_auriculariales_biocontrol_evaluations (species_id); CREATE INDEX ix_ord_auriculariales_biocontrol_evaluations_publication_id ON ord_auriculariales_biocontrol_evaluations (publication_id); CREATE TABLE ord_auriculariales_regional_checklists ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, checklist_publication_id INTEGER, status TEXT, checklist_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (checklist_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_auriculariales_regional_checklists_species_id ON ord_auriculariales_regional_checklists (species_id); CREATE INDEX ix_ord_auriculariales_regional_checklists_country_id ON ord_auriculariales_regional_checklists (country_id); CREATE TABLE ord_tremellales_morphology ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, hymenium_color_at_maturity TEXT, context_color_at_maturity TEXT, characteristic_microstructure TEXT, diagnostic_features_text TEXT, notes_kohler_reaction TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_tremellales_morphology_specimen_id ON ord_tremellales_morphology (specimen_id); CREATE INDEX ix_ord_tremellales_morphology_species_id ON ord_tremellales_morphology (species_id); CREATE TABLE ord_tremellales_ecology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, dominant_habitat_id INTEGER, dominant_substrate_id INTEGER, dominant_biome_id INTEGER, trophic_strategy TEXT, typical_fruiting_period TEXT, known_distribution_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_habitat_id) REFERENCES eco_habitat_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_substrate_id) REFERENCES eco_substrate_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_biome_id) REFERENCES geo_biomes (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_tremellales_ecology_species_id ON ord_tremellales_ecology (species_id); CREATE INDEX ix_ord_tremellales_ecology_dominant_habitat_id ON ord_tremellales_ecology (dominant_habitat_id); CREATE TABLE ord_tremellales_phenology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, season_name TEXT, region_country_id INTEGER, first_doy INTEGER, peak_doy INTEGER, last_doy INTEGER, years_observed INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_tremellales_phenology_species_id ON ord_tremellales_phenology (species_id); CREATE INDEX ix_ord_tremellales_phenology_region_country_id ON ord_tremellales_phenology (region_country_id); CREATE TABLE ord_tremellales_host_associations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, association_type TEXT, specificity TEXT, evidence_publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (evidence_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_tremellales_host_associations_species_id ON ord_tremellales_host_associations (species_id); CREATE INDEX ix_ord_tremellales_host_associations_host_id ON ord_tremellales_host_associations (host_id); CREATE TABLE ord_tremellales_substrate_preferences ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, substrate_id INTEGER NOT NULL, preference_score REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (substrate_id) REFERENCES eco_substrate_types (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_tremellales_substrate_preferences_species_id ON ord_tremellales_substrate_preferences (species_id); CREATE INDEX ix_ord_tremellales_substrate_preferences_substrate_id ON ord_tremellales_substrate_preferences (substrate_id); CREATE TABLE ord_tremellales_geographic_distribution ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, occurrence_status TEXT, first_record_year INTEGER, record_count INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_tremellales_geographic_distribution_species_id ON ord_tremellales_geographic_distribution (species_id); CREATE INDEX ix_ord_tremellales_geographic_distribution_country_id ON ord_tremellales_geographic_distribution (country_id); CREATE TABLE ord_tremellales_phylogeny ( id INTEGER PRIMARY KEY AUTOINCREMENT, tree_id INTEGER NOT NULL, focal_genus_id INTEGER, publication_id INTEGER, notes_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (tree_id) REFERENCES phy_trees (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_tremellales_phylogeny_tree_id ON ord_tremellales_phylogeny (tree_id); CREATE INDEX ix_ord_tremellales_phylogeny_focal_genus_id ON ord_tremellales_phylogeny (focal_genus_id); CREATE TABLE ord_tremellales_genomics ( id INTEGER PRIMARY KEY AUTOINCREMENT, assembly_id INTEGER NOT NULL, species_id INTEGER, avg_genome_size_mb REAL, avg_gene_count INTEGER, avg_busco_complete_pct REAL, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (assembly_id) REFERENCES gen_assemblies (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_tremellales_genomics_assembly_id ON ord_tremellales_genomics (assembly_id); CREATE INDEX ix_ord_tremellales_genomics_species_id ON ord_tremellales_genomics (species_id); CREATE TABLE ord_tremellales_biochemistry ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, typicality TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_tremellales_biochemistry_species_id ON ord_tremellales_biochemistry (species_id); CREATE INDEX ix_ord_tremellales_biochemistry_compound_id ON ord_tremellales_biochemistry (compound_id); CREATE TABLE ord_tremellales_cultivation_notes ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, typical_growth_rate_mm_per_day REAL, preferred_media_type_id INTEGER, optimal_temperature_c REAL, difficulty_score INTEGER CHECK (difficulty_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (preferred_media_type_id) REFERENCES cul_media_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_tremellales_cultivation_notes_species_id ON ord_tremellales_cultivation_notes (species_id); CREATE INDEX ix_ord_tremellales_cultivation_notes_strain_id ON ord_tremellales_cultivation_notes (strain_id); CREATE TABLE ord_tremellales_pathogenicity ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, disease_id INTEGER, severity_score INTEGER CHECK (severity_score BETWEEN 1 AND 5), publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (disease_id) REFERENCES pat_diseases (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_tremellales_pathogenicity_species_id ON ord_tremellales_pathogenicity (species_id); CREATE INDEX ix_ord_tremellales_pathogenicity_host_id ON ord_tremellales_pathogenicity (host_id); CREATE TABLE ord_tremellales_edibility ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, edibility_class TEXT, preparation_notes TEXT, regional_tradition_country_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (regional_tradition_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_tremellales_edibility_species_id ON ord_tremellales_edibility (species_id); CREATE INDEX ix_ord_tremellales_edibility_regional_tradition_country_id ON ord_tremellales_edibility (regional_tradition_country_id); CREATE TABLE ord_tremellales_medicinal_uses ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, traditional_use_text TEXT, modern_evidence_level TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_tremellales_medicinal_uses_species_id ON ord_tremellales_medicinal_uses (species_id); CREATE INDEX ix_ord_tremellales_medicinal_uses_publication_id ON ord_tremellales_medicinal_uses (publication_id); CREATE TABLE ord_tremellales_taxonomic_revisions ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER NOT NULL, affected_family_id INTEGER, affected_genus_id INTEGER, revision_summary TEXT, revision_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_family_id) REFERENCES tax_families (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_tremellales_taxonomic_revisions_publication_id ON ord_tremellales_taxonomic_revisions (publication_id); CREATE INDEX ix_ord_tremellales_taxonomic_revisions_affected_family_id ON ord_tremellales_taxonomic_revisions (affected_family_id); CREATE TABLE ord_tremellales_conservation_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, national_redlist_category TEXT, habitat_pressure_text TEXT, last_assessment_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_tremellales_conservation_status_species_id ON ord_tremellales_conservation_status (species_id); CREATE INDEX ix_ord_tremellales_conservation_status_country_id ON ord_tremellales_conservation_status (country_id); CREATE TABLE ord_tremellales_diagnostic_keys ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER, key_title TEXT NOT NULL, region_country_id INTEGER, n_taxa_covered INTEGER, key_format TEXT, includes_microscopy INTEGER NOT NULL DEFAULT 0, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_tremellales_diagnostic_keys_publication_id ON ord_tremellales_diagnostic_keys (publication_id); CREATE INDEX ix_ord_tremellales_diagnostic_keys_region_country_id ON ord_tremellales_diagnostic_keys (region_country_id); CREATE TABLE ord_tremellales_type_species_register ( id INTEGER PRIMARY KEY AUTOINCREMENT, focal_genus_id INTEGER NOT NULL, type_species_id INTEGER, designation_publication_id INTEGER, designation_year INTEGER, designated_by_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (designation_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_tremellales_type_species_register_focal_genus_id ON ord_tremellales_type_species_register (focal_genus_id); CREATE INDEX ix_ord_tremellales_type_species_register_type_species_id ON ord_tremellales_type_species_register (type_species_id); CREATE TABLE ord_tremellales_distribution_grids ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, grid_cell_code TEXT NOT NULL, centroid_lat REAL, centroid_lon REAL, record_count INTEGER, first_record_year INTEGER, most_recent_record_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_tremellales_distribution_grids_species_id ON ord_tremellales_distribution_grids (species_id); CREATE INDEX ix_ord_tremellales_distribution_grids_country_id ON ord_tremellales_distribution_grids (country_id); CREATE TABLE ord_tremellales_microclimate_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER, publication_id INTEGER, substrate_temperature_c REAL, substrate_moisture_pct REAL, canopy_closure_pct REAL, photosynthetic_par_umol_m2_s REAL, days_post_rainfall INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_tremellales_microclimate_studies_species_id ON ord_tremellales_microclimate_studies (species_id); CREATE INDEX ix_ord_tremellales_microclimate_studies_publication_id ON ord_tremellales_microclimate_studies (publication_id); CREATE TABLE ord_tremellales_dna_barcoding_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, its_sequenced INTEGER NOT NULL DEFAULT 0, lsu_sequenced INTEGER NOT NULL DEFAULT 0, rpb2_sequenced INTEGER NOT NULL DEFAULT 0, ef1a_sequenced INTEGER NOT NULL DEFAULT 0, genome_assembled INTEGER NOT NULL DEFAULT 0, priority_for_sequencing_score INTEGER CHECK (priority_for_sequencing_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_tremellales_dna_barcoding_status_species_id ON ord_tremellales_dna_barcoding_status (species_id); CREATE TABLE ord_tremellales_spore_print_data ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, specimen_id INTEGER, print_color_label TEXT, print_color_chip_id INTEGER, spore_density_per_mm2 REAL, collection_substrate TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (print_color_chip_id) REFERENCES mor_color_chips (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_tremellales_spore_print_data_species_id ON ord_tremellales_spore_print_data (species_id); CREATE INDEX ix_ord_tremellales_spore_print_data_specimen_id ON ord_tremellales_spore_print_data (specimen_id); CREATE TABLE ord_tremellales_mating_systems ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, system_type TEXT, mating_loci_count INTEGER, publication_id INTEGER, notes_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_tremellales_mating_systems_species_id ON ord_tremellales_mating_systems (species_id); CREATE INDEX ix_ord_tremellales_mating_systems_publication_id ON ord_tremellales_mating_systems (publication_id); CREATE TABLE ord_tremellales_nutrient_uptake_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, nitrogen_source TEXT, carbon_source TEXT, growth_response TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_tremellales_nutrient_uptake_studies_species_id ON ord_tremellales_nutrient_uptake_studies (species_id); CREATE INDEX ix_ord_tremellales_nutrient_uptake_studies_strain_id ON ord_tremellales_nutrient_uptake_studies (strain_id); CREATE TABLE ord_tremellales_range_maps ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, polygon_file_uri TEXT NOT NULL, source_methodology TEXT, area_km2 REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_tremellales_range_maps_species_id ON ord_tremellales_range_maps (species_id); CREATE INDEX ix_ord_tremellales_range_maps_publication_id ON ord_tremellales_range_maps (publication_id); CREATE TABLE ord_tremellales_abundance_estimates ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, estimate_kind TEXT, value_min REAL, value_max REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_tremellales_abundance_estimates_species_id ON ord_tremellales_abundance_estimates (species_id); CREATE INDEX ix_ord_tremellales_abundance_estimates_country_id ON ord_tremellales_abundance_estimates (country_id); CREATE TABLE ord_tremellales_toxin_profiles ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, presence TEXT, typical_concentration_mg_per_kg REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_tremellales_toxin_profiles_species_id ON ord_tremellales_toxin_profiles (species_id); CREATE INDEX ix_ord_tremellales_toxin_profiles_compound_id ON ord_tremellales_toxin_profiles (compound_id); CREATE TABLE ord_tremellales_enzyme_activity_assays ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, enzyme_id INTEGER NOT NULL, strain_id INTEGER, activity_u_per_mg REAL, temperature_c REAL, ph REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (enzyme_id) REFERENCES bio_enzymes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_tremellales_enzyme_activity_assays_species_id ON ord_tremellales_enzyme_activity_assays (species_id); CREATE INDEX ix_ord_tremellales_enzyme_activity_assays_enzyme_id ON ord_tremellales_enzyme_activity_assays (enzyme_id); CREATE TABLE ord_tremellales_biocontrol_evaluations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, target_pest_text TEXT NOT NULL, efficacy_pct REAL, trial_setting TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_tremellales_biocontrol_evaluations_species_id ON ord_tremellales_biocontrol_evaluations (species_id); CREATE INDEX ix_ord_tremellales_biocontrol_evaluations_publication_id ON ord_tremellales_biocontrol_evaluations (publication_id); CREATE TABLE ord_tremellales_regional_checklists ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, checklist_publication_id INTEGER, status TEXT, checklist_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (checklist_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_tremellales_regional_checklists_species_id ON ord_tremellales_regional_checklists (species_id); CREATE INDEX ix_ord_tremellales_regional_checklists_country_id ON ord_tremellales_regional_checklists (country_id); CREATE TABLE ord_phallales_morphology ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, hymenium_color_at_maturity TEXT, context_color_at_maturity TEXT, characteristic_microstructure TEXT, diagnostic_features_text TEXT, notes_kohler_reaction TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_phallales_morphology_specimen_id ON ord_phallales_morphology (specimen_id); CREATE INDEX ix_ord_phallales_morphology_species_id ON ord_phallales_morphology (species_id); CREATE TABLE ord_phallales_ecology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, dominant_habitat_id INTEGER, dominant_substrate_id INTEGER, dominant_biome_id INTEGER, trophic_strategy TEXT, typical_fruiting_period TEXT, known_distribution_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_habitat_id) REFERENCES eco_habitat_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_substrate_id) REFERENCES eco_substrate_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_biome_id) REFERENCES geo_biomes (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_phallales_ecology_species_id ON ord_phallales_ecology (species_id); CREATE INDEX ix_ord_phallales_ecology_dominant_habitat_id ON ord_phallales_ecology (dominant_habitat_id); CREATE TABLE ord_phallales_phenology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, season_name TEXT, region_country_id INTEGER, first_doy INTEGER, peak_doy INTEGER, last_doy INTEGER, years_observed INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_phallales_phenology_species_id ON ord_phallales_phenology (species_id); CREATE INDEX ix_ord_phallales_phenology_region_country_id ON ord_phallales_phenology (region_country_id); CREATE TABLE ord_phallales_host_associations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, association_type TEXT, specificity TEXT, evidence_publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (evidence_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_phallales_host_associations_species_id ON ord_phallales_host_associations (species_id); CREATE INDEX ix_ord_phallales_host_associations_host_id ON ord_phallales_host_associations (host_id); CREATE TABLE ord_phallales_substrate_preferences ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, substrate_id INTEGER NOT NULL, preference_score REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (substrate_id) REFERENCES eco_substrate_types (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_phallales_substrate_preferences_species_id ON ord_phallales_substrate_preferences (species_id); CREATE INDEX ix_ord_phallales_substrate_preferences_substrate_id ON ord_phallales_substrate_preferences (substrate_id); CREATE TABLE ord_phallales_geographic_distribution ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, occurrence_status TEXT, first_record_year INTEGER, record_count INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_phallales_geographic_distribution_species_id ON ord_phallales_geographic_distribution (species_id); CREATE INDEX ix_ord_phallales_geographic_distribution_country_id ON ord_phallales_geographic_distribution (country_id); CREATE TABLE ord_phallales_phylogeny ( id INTEGER PRIMARY KEY AUTOINCREMENT, tree_id INTEGER NOT NULL, focal_genus_id INTEGER, publication_id INTEGER, notes_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (tree_id) REFERENCES phy_trees (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_phallales_phylogeny_tree_id ON ord_phallales_phylogeny (tree_id); CREATE INDEX ix_ord_phallales_phylogeny_focal_genus_id ON ord_phallales_phylogeny (focal_genus_id); CREATE TABLE ord_phallales_genomics ( id INTEGER PRIMARY KEY AUTOINCREMENT, assembly_id INTEGER NOT NULL, species_id INTEGER, avg_genome_size_mb REAL, avg_gene_count INTEGER, avg_busco_complete_pct REAL, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (assembly_id) REFERENCES gen_assemblies (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_phallales_genomics_assembly_id ON ord_phallales_genomics (assembly_id); CREATE INDEX ix_ord_phallales_genomics_species_id ON ord_phallales_genomics (species_id); CREATE TABLE ord_phallales_biochemistry ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, typicality TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_phallales_biochemistry_species_id ON ord_phallales_biochemistry (species_id); CREATE INDEX ix_ord_phallales_biochemistry_compound_id ON ord_phallales_biochemistry (compound_id); CREATE TABLE ord_phallales_cultivation_notes ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, typical_growth_rate_mm_per_day REAL, preferred_media_type_id INTEGER, optimal_temperature_c REAL, difficulty_score INTEGER CHECK (difficulty_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (preferred_media_type_id) REFERENCES cul_media_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_phallales_cultivation_notes_species_id ON ord_phallales_cultivation_notes (species_id); CREATE INDEX ix_ord_phallales_cultivation_notes_strain_id ON ord_phallales_cultivation_notes (strain_id); CREATE TABLE ord_phallales_pathogenicity ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, disease_id INTEGER, severity_score INTEGER CHECK (severity_score BETWEEN 1 AND 5), publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (disease_id) REFERENCES pat_diseases (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_phallales_pathogenicity_species_id ON ord_phallales_pathogenicity (species_id); CREATE INDEX ix_ord_phallales_pathogenicity_host_id ON ord_phallales_pathogenicity (host_id); CREATE TABLE ord_phallales_edibility ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, edibility_class TEXT, preparation_notes TEXT, regional_tradition_country_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (regional_tradition_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_phallales_edibility_species_id ON ord_phallales_edibility (species_id); CREATE INDEX ix_ord_phallales_edibility_regional_tradition_country_id ON ord_phallales_edibility (regional_tradition_country_id); CREATE TABLE ord_phallales_medicinal_uses ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, traditional_use_text TEXT, modern_evidence_level TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_phallales_medicinal_uses_species_id ON ord_phallales_medicinal_uses (species_id); CREATE INDEX ix_ord_phallales_medicinal_uses_publication_id ON ord_phallales_medicinal_uses (publication_id); CREATE TABLE ord_phallales_taxonomic_revisions ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER NOT NULL, affected_family_id INTEGER, affected_genus_id INTEGER, revision_summary TEXT, revision_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_family_id) REFERENCES tax_families (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_phallales_taxonomic_revisions_publication_id ON ord_phallales_taxonomic_revisions (publication_id); CREATE INDEX ix_ord_phallales_taxonomic_revisions_affected_family_id ON ord_phallales_taxonomic_revisions (affected_family_id); CREATE TABLE ord_phallales_conservation_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, national_redlist_category TEXT, habitat_pressure_text TEXT, last_assessment_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_phallales_conservation_status_species_id ON ord_phallales_conservation_status (species_id); CREATE INDEX ix_ord_phallales_conservation_status_country_id ON ord_phallales_conservation_status (country_id); CREATE TABLE ord_phallales_diagnostic_keys ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER, key_title TEXT NOT NULL, region_country_id INTEGER, n_taxa_covered INTEGER, key_format TEXT, includes_microscopy INTEGER NOT NULL DEFAULT 0, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_phallales_diagnostic_keys_publication_id ON ord_phallales_diagnostic_keys (publication_id); CREATE INDEX ix_ord_phallales_diagnostic_keys_region_country_id ON ord_phallales_diagnostic_keys (region_country_id); CREATE TABLE ord_phallales_type_species_register ( id INTEGER PRIMARY KEY AUTOINCREMENT, focal_genus_id INTEGER NOT NULL, type_species_id INTEGER, designation_publication_id INTEGER, designation_year INTEGER, designated_by_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (designation_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_phallales_type_species_register_focal_genus_id ON ord_phallales_type_species_register (focal_genus_id); CREATE INDEX ix_ord_phallales_type_species_register_type_species_id ON ord_phallales_type_species_register (type_species_id); CREATE TABLE ord_phallales_distribution_grids ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, grid_cell_code TEXT NOT NULL, centroid_lat REAL, centroid_lon REAL, record_count INTEGER, first_record_year INTEGER, most_recent_record_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_phallales_distribution_grids_species_id ON ord_phallales_distribution_grids (species_id); CREATE INDEX ix_ord_phallales_distribution_grids_country_id ON ord_phallales_distribution_grids (country_id); CREATE TABLE ord_phallales_microclimate_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER, publication_id INTEGER, substrate_temperature_c REAL, substrate_moisture_pct REAL, canopy_closure_pct REAL, photosynthetic_par_umol_m2_s REAL, days_post_rainfall INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_phallales_microclimate_studies_species_id ON ord_phallales_microclimate_studies (species_id); CREATE INDEX ix_ord_phallales_microclimate_studies_publication_id ON ord_phallales_microclimate_studies (publication_id); CREATE TABLE ord_phallales_dna_barcoding_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, its_sequenced INTEGER NOT NULL DEFAULT 0, lsu_sequenced INTEGER NOT NULL DEFAULT 0, rpb2_sequenced INTEGER NOT NULL DEFAULT 0, ef1a_sequenced INTEGER NOT NULL DEFAULT 0, genome_assembled INTEGER NOT NULL DEFAULT 0, priority_for_sequencing_score INTEGER CHECK (priority_for_sequencing_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_phallales_dna_barcoding_status_species_id ON ord_phallales_dna_barcoding_status (species_id); CREATE TABLE ord_phallales_spore_print_data ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, specimen_id INTEGER, print_color_label TEXT, print_color_chip_id INTEGER, spore_density_per_mm2 REAL, collection_substrate TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (print_color_chip_id) REFERENCES mor_color_chips (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_phallales_spore_print_data_species_id ON ord_phallales_spore_print_data (species_id); CREATE INDEX ix_ord_phallales_spore_print_data_specimen_id ON ord_phallales_spore_print_data (specimen_id); CREATE TABLE ord_phallales_mating_systems ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, system_type TEXT, mating_loci_count INTEGER, publication_id INTEGER, notes_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_phallales_mating_systems_species_id ON ord_phallales_mating_systems (species_id); CREATE INDEX ix_ord_phallales_mating_systems_publication_id ON ord_phallales_mating_systems (publication_id); CREATE TABLE ord_phallales_nutrient_uptake_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, nitrogen_source TEXT, carbon_source TEXT, growth_response TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_phallales_nutrient_uptake_studies_species_id ON ord_phallales_nutrient_uptake_studies (species_id); CREATE INDEX ix_ord_phallales_nutrient_uptake_studies_strain_id ON ord_phallales_nutrient_uptake_studies (strain_id); CREATE TABLE ord_phallales_range_maps ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, polygon_file_uri TEXT NOT NULL, source_methodology TEXT, area_km2 REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_phallales_range_maps_species_id ON ord_phallales_range_maps (species_id); CREATE INDEX ix_ord_phallales_range_maps_publication_id ON ord_phallales_range_maps (publication_id); CREATE TABLE ord_phallales_abundance_estimates ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, estimate_kind TEXT, value_min REAL, value_max REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_phallales_abundance_estimates_species_id ON ord_phallales_abundance_estimates (species_id); CREATE INDEX ix_ord_phallales_abundance_estimates_country_id ON ord_phallales_abundance_estimates (country_id); CREATE TABLE ord_phallales_toxin_profiles ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, presence TEXT, typical_concentration_mg_per_kg REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_phallales_toxin_profiles_species_id ON ord_phallales_toxin_profiles (species_id); CREATE INDEX ix_ord_phallales_toxin_profiles_compound_id ON ord_phallales_toxin_profiles (compound_id); CREATE TABLE ord_phallales_enzyme_activity_assays ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, enzyme_id INTEGER NOT NULL, strain_id INTEGER, activity_u_per_mg REAL, temperature_c REAL, ph REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (enzyme_id) REFERENCES bio_enzymes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_phallales_enzyme_activity_assays_species_id ON ord_phallales_enzyme_activity_assays (species_id); CREATE INDEX ix_ord_phallales_enzyme_activity_assays_enzyme_id ON ord_phallales_enzyme_activity_assays (enzyme_id); CREATE TABLE ord_phallales_biocontrol_evaluations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, target_pest_text TEXT NOT NULL, efficacy_pct REAL, trial_setting TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_phallales_biocontrol_evaluations_species_id ON ord_phallales_biocontrol_evaluations (species_id); CREATE INDEX ix_ord_phallales_biocontrol_evaluations_publication_id ON ord_phallales_biocontrol_evaluations (publication_id); CREATE TABLE ord_phallales_regional_checklists ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, checklist_publication_id INTEGER, status TEXT, checklist_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (checklist_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_phallales_regional_checklists_species_id ON ord_phallales_regional_checklists (species_id); CREATE INDEX ix_ord_phallales_regional_checklists_country_id ON ord_phallales_regional_checklists (country_id); CREATE TABLE ord_geastrales_morphology ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, hymenium_color_at_maturity TEXT, context_color_at_maturity TEXT, characteristic_microstructure TEXT, diagnostic_features_text TEXT, notes_kohler_reaction TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_geastrales_morphology_specimen_id ON ord_geastrales_morphology (specimen_id); CREATE INDEX ix_ord_geastrales_morphology_species_id ON ord_geastrales_morphology (species_id); CREATE TABLE ord_geastrales_ecology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, dominant_habitat_id INTEGER, dominant_substrate_id INTEGER, dominant_biome_id INTEGER, trophic_strategy TEXT, typical_fruiting_period TEXT, known_distribution_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_habitat_id) REFERENCES eco_habitat_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_substrate_id) REFERENCES eco_substrate_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_biome_id) REFERENCES geo_biomes (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_geastrales_ecology_species_id ON ord_geastrales_ecology (species_id); CREATE INDEX ix_ord_geastrales_ecology_dominant_habitat_id ON ord_geastrales_ecology (dominant_habitat_id); CREATE TABLE ord_geastrales_phenology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, season_name TEXT, region_country_id INTEGER, first_doy INTEGER, peak_doy INTEGER, last_doy INTEGER, years_observed INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_geastrales_phenology_species_id ON ord_geastrales_phenology (species_id); CREATE INDEX ix_ord_geastrales_phenology_region_country_id ON ord_geastrales_phenology (region_country_id); CREATE TABLE ord_geastrales_host_associations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, association_type TEXT, specificity TEXT, evidence_publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (evidence_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_geastrales_host_associations_species_id ON ord_geastrales_host_associations (species_id); CREATE INDEX ix_ord_geastrales_host_associations_host_id ON ord_geastrales_host_associations (host_id); CREATE TABLE ord_geastrales_substrate_preferences ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, substrate_id INTEGER NOT NULL, preference_score REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (substrate_id) REFERENCES eco_substrate_types (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_geastrales_substrate_preferences_species_id ON ord_geastrales_substrate_preferences (species_id); CREATE INDEX ix_ord_geastrales_substrate_preferences_substrate_id ON ord_geastrales_substrate_preferences (substrate_id); CREATE TABLE ord_geastrales_geographic_distribution ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, occurrence_status TEXT, first_record_year INTEGER, record_count INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_geastrales_geographic_distribution_species_id ON ord_geastrales_geographic_distribution (species_id); CREATE INDEX ix_ord_geastrales_geographic_distribution_country_id ON ord_geastrales_geographic_distribution (country_id); CREATE TABLE ord_geastrales_phylogeny ( id INTEGER PRIMARY KEY AUTOINCREMENT, tree_id INTEGER NOT NULL, focal_genus_id INTEGER, publication_id INTEGER, notes_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (tree_id) REFERENCES phy_trees (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_geastrales_phylogeny_tree_id ON ord_geastrales_phylogeny (tree_id); CREATE INDEX ix_ord_geastrales_phylogeny_focal_genus_id ON ord_geastrales_phylogeny (focal_genus_id); CREATE TABLE ord_geastrales_genomics ( id INTEGER PRIMARY KEY AUTOINCREMENT, assembly_id INTEGER NOT NULL, species_id INTEGER, avg_genome_size_mb REAL, avg_gene_count INTEGER, avg_busco_complete_pct REAL, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (assembly_id) REFERENCES gen_assemblies (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_geastrales_genomics_assembly_id ON ord_geastrales_genomics (assembly_id); CREATE INDEX ix_ord_geastrales_genomics_species_id ON ord_geastrales_genomics (species_id); CREATE TABLE ord_geastrales_biochemistry ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, typicality TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_geastrales_biochemistry_species_id ON ord_geastrales_biochemistry (species_id); CREATE INDEX ix_ord_geastrales_biochemistry_compound_id ON ord_geastrales_biochemistry (compound_id); CREATE TABLE ord_geastrales_cultivation_notes ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, typical_growth_rate_mm_per_day REAL, preferred_media_type_id INTEGER, optimal_temperature_c REAL, difficulty_score INTEGER CHECK (difficulty_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (preferred_media_type_id) REFERENCES cul_media_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_geastrales_cultivation_notes_species_id ON ord_geastrales_cultivation_notes (species_id); CREATE INDEX ix_ord_geastrales_cultivation_notes_strain_id ON ord_geastrales_cultivation_notes (strain_id); CREATE TABLE ord_geastrales_pathogenicity ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, disease_id INTEGER, severity_score INTEGER CHECK (severity_score BETWEEN 1 AND 5), publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (disease_id) REFERENCES pat_diseases (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_geastrales_pathogenicity_species_id ON ord_geastrales_pathogenicity (species_id); CREATE INDEX ix_ord_geastrales_pathogenicity_host_id ON ord_geastrales_pathogenicity (host_id); CREATE TABLE ord_geastrales_edibility ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, edibility_class TEXT, preparation_notes TEXT, regional_tradition_country_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (regional_tradition_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_geastrales_edibility_species_id ON ord_geastrales_edibility (species_id); CREATE INDEX ix_ord_geastrales_edibility_regional_tradition_country_id ON ord_geastrales_edibility (regional_tradition_country_id); CREATE TABLE ord_geastrales_medicinal_uses ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, traditional_use_text TEXT, modern_evidence_level TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_geastrales_medicinal_uses_species_id ON ord_geastrales_medicinal_uses (species_id); CREATE INDEX ix_ord_geastrales_medicinal_uses_publication_id ON ord_geastrales_medicinal_uses (publication_id); CREATE TABLE ord_geastrales_taxonomic_revisions ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER NOT NULL, affected_family_id INTEGER, affected_genus_id INTEGER, revision_summary TEXT, revision_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_family_id) REFERENCES tax_families (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_geastrales_taxonomic_revisions_publication_id ON ord_geastrales_taxonomic_revisions (publication_id); CREATE INDEX ix_ord_geastrales_taxonomic_revisions_affected_family_id ON ord_geastrales_taxonomic_revisions (affected_family_id); CREATE TABLE ord_geastrales_conservation_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, national_redlist_category TEXT, habitat_pressure_text TEXT, last_assessment_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_geastrales_conservation_status_species_id ON ord_geastrales_conservation_status (species_id); CREATE INDEX ix_ord_geastrales_conservation_status_country_id ON ord_geastrales_conservation_status (country_id); CREATE TABLE ord_geastrales_diagnostic_keys ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER, key_title TEXT NOT NULL, region_country_id INTEGER, n_taxa_covered INTEGER, key_format TEXT, includes_microscopy INTEGER NOT NULL DEFAULT 0, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_geastrales_diagnostic_keys_publication_id ON ord_geastrales_diagnostic_keys (publication_id); CREATE INDEX ix_ord_geastrales_diagnostic_keys_region_country_id ON ord_geastrales_diagnostic_keys (region_country_id); CREATE TABLE ord_geastrales_type_species_register ( id INTEGER PRIMARY KEY AUTOINCREMENT, focal_genus_id INTEGER NOT NULL, type_species_id INTEGER, designation_publication_id INTEGER, designation_year INTEGER, designated_by_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (designation_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_geastrales_type_species_register_focal_genus_id ON ord_geastrales_type_species_register (focal_genus_id); CREATE INDEX ix_ord_geastrales_type_species_register_type_species_id ON ord_geastrales_type_species_register (type_species_id); CREATE TABLE ord_geastrales_distribution_grids ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, grid_cell_code TEXT NOT NULL, centroid_lat REAL, centroid_lon REAL, record_count INTEGER, first_record_year INTEGER, most_recent_record_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_geastrales_distribution_grids_species_id ON ord_geastrales_distribution_grids (species_id); CREATE INDEX ix_ord_geastrales_distribution_grids_country_id ON ord_geastrales_distribution_grids (country_id); CREATE TABLE ord_geastrales_microclimate_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER, publication_id INTEGER, substrate_temperature_c REAL, substrate_moisture_pct REAL, canopy_closure_pct REAL, photosynthetic_par_umol_m2_s REAL, days_post_rainfall INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_geastrales_microclimate_studies_species_id ON ord_geastrales_microclimate_studies (species_id); CREATE INDEX ix_ord_geastrales_microclimate_studies_publication_id ON ord_geastrales_microclimate_studies (publication_id); CREATE TABLE ord_geastrales_dna_barcoding_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, its_sequenced INTEGER NOT NULL DEFAULT 0, lsu_sequenced INTEGER NOT NULL DEFAULT 0, rpb2_sequenced INTEGER NOT NULL DEFAULT 0, ef1a_sequenced INTEGER NOT NULL DEFAULT 0, genome_assembled INTEGER NOT NULL DEFAULT 0, priority_for_sequencing_score INTEGER CHECK (priority_for_sequencing_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_geastrales_dna_barcoding_status_species_id ON ord_geastrales_dna_barcoding_status (species_id); CREATE TABLE ord_geastrales_spore_print_data ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, specimen_id INTEGER, print_color_label TEXT, print_color_chip_id INTEGER, spore_density_per_mm2 REAL, collection_substrate TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (print_color_chip_id) REFERENCES mor_color_chips (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_geastrales_spore_print_data_species_id ON ord_geastrales_spore_print_data (species_id); CREATE INDEX ix_ord_geastrales_spore_print_data_specimen_id ON ord_geastrales_spore_print_data (specimen_id); CREATE TABLE ord_geastrales_mating_systems ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, system_type TEXT, mating_loci_count INTEGER, publication_id INTEGER, notes_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_geastrales_mating_systems_species_id ON ord_geastrales_mating_systems (species_id); CREATE INDEX ix_ord_geastrales_mating_systems_publication_id ON ord_geastrales_mating_systems (publication_id); CREATE TABLE ord_geastrales_nutrient_uptake_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, nitrogen_source TEXT, carbon_source TEXT, growth_response TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_geastrales_nutrient_uptake_studies_species_id ON ord_geastrales_nutrient_uptake_studies (species_id); CREATE INDEX ix_ord_geastrales_nutrient_uptake_studies_strain_id ON ord_geastrales_nutrient_uptake_studies (strain_id); CREATE TABLE ord_geastrales_range_maps ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, polygon_file_uri TEXT NOT NULL, source_methodology TEXT, area_km2 REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_geastrales_range_maps_species_id ON ord_geastrales_range_maps (species_id); CREATE INDEX ix_ord_geastrales_range_maps_publication_id ON ord_geastrales_range_maps (publication_id); CREATE TABLE ord_geastrales_abundance_estimates ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, estimate_kind TEXT, value_min REAL, value_max REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_geastrales_abundance_estimates_species_id ON ord_geastrales_abundance_estimates (species_id); CREATE INDEX ix_ord_geastrales_abundance_estimates_country_id ON ord_geastrales_abundance_estimates (country_id); CREATE TABLE ord_geastrales_toxin_profiles ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, presence TEXT, typical_concentration_mg_per_kg REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_geastrales_toxin_profiles_species_id ON ord_geastrales_toxin_profiles (species_id); CREATE INDEX ix_ord_geastrales_toxin_profiles_compound_id ON ord_geastrales_toxin_profiles (compound_id); CREATE TABLE ord_geastrales_enzyme_activity_assays ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, enzyme_id INTEGER NOT NULL, strain_id INTEGER, activity_u_per_mg REAL, temperature_c REAL, ph REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (enzyme_id) REFERENCES bio_enzymes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_geastrales_enzyme_activity_assays_species_id ON ord_geastrales_enzyme_activity_assays (species_id); CREATE INDEX ix_ord_geastrales_enzyme_activity_assays_enzyme_id ON ord_geastrales_enzyme_activity_assays (enzyme_id); CREATE TABLE ord_geastrales_biocontrol_evaluations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, target_pest_text TEXT NOT NULL, efficacy_pct REAL, trial_setting TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_geastrales_biocontrol_evaluations_species_id ON ord_geastrales_biocontrol_evaluations (species_id); CREATE INDEX ix_ord_geastrales_biocontrol_evaluations_publication_id ON ord_geastrales_biocontrol_evaluations (publication_id); CREATE TABLE ord_geastrales_regional_checklists ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, checklist_publication_id INTEGER, status TEXT, checklist_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (checklist_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_geastrales_regional_checklists_species_id ON ord_geastrales_regional_checklists (species_id); CREATE INDEX ix_ord_geastrales_regional_checklists_country_id ON ord_geastrales_regional_checklists (country_id); CREATE TABLE ord_lycoperdales_morphology ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, hymenium_color_at_maturity TEXT, context_color_at_maturity TEXT, characteristic_microstructure TEXT, diagnostic_features_text TEXT, notes_kohler_reaction TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lycoperdales_morphology_specimen_id ON ord_lycoperdales_morphology (specimen_id); CREATE INDEX ix_ord_lycoperdales_morphology_species_id ON ord_lycoperdales_morphology (species_id); CREATE TABLE ord_lycoperdales_ecology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, dominant_habitat_id INTEGER, dominant_substrate_id INTEGER, dominant_biome_id INTEGER, trophic_strategy TEXT, typical_fruiting_period TEXT, known_distribution_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_habitat_id) REFERENCES eco_habitat_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_substrate_id) REFERENCES eco_substrate_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_biome_id) REFERENCES geo_biomes (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lycoperdales_ecology_species_id ON ord_lycoperdales_ecology (species_id); CREATE INDEX ix_ord_lycoperdales_ecology_dominant_habitat_id ON ord_lycoperdales_ecology (dominant_habitat_id); CREATE TABLE ord_lycoperdales_phenology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, season_name TEXT, region_country_id INTEGER, first_doy INTEGER, peak_doy INTEGER, last_doy INTEGER, years_observed INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lycoperdales_phenology_species_id ON ord_lycoperdales_phenology (species_id); CREATE INDEX ix_ord_lycoperdales_phenology_region_country_id ON ord_lycoperdales_phenology (region_country_id); CREATE TABLE ord_lycoperdales_host_associations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, association_type TEXT, specificity TEXT, evidence_publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (evidence_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lycoperdales_host_associations_species_id ON ord_lycoperdales_host_associations (species_id); CREATE INDEX ix_ord_lycoperdales_host_associations_host_id ON ord_lycoperdales_host_associations (host_id); CREATE TABLE ord_lycoperdales_substrate_preferences ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, substrate_id INTEGER NOT NULL, preference_score REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (substrate_id) REFERENCES eco_substrate_types (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lycoperdales_substrate_preferences_species_id ON ord_lycoperdales_substrate_preferences (species_id); CREATE INDEX ix_ord_lycoperdales_substrate_preferences_substrate_id ON ord_lycoperdales_substrate_preferences (substrate_id); CREATE TABLE ord_lycoperdales_geographic_distribution ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, occurrence_status TEXT, first_record_year INTEGER, record_count INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lycoperdales_geographic_distribution_species_id ON ord_lycoperdales_geographic_distribution (species_id); CREATE INDEX ix_ord_lycoperdales_geographic_distribution_country_id ON ord_lycoperdales_geographic_distribution (country_id); CREATE TABLE ord_lycoperdales_phylogeny ( id INTEGER PRIMARY KEY AUTOINCREMENT, tree_id INTEGER NOT NULL, focal_genus_id INTEGER, publication_id INTEGER, notes_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (tree_id) REFERENCES phy_trees (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lycoperdales_phylogeny_tree_id ON ord_lycoperdales_phylogeny (tree_id); CREATE INDEX ix_ord_lycoperdales_phylogeny_focal_genus_id ON ord_lycoperdales_phylogeny (focal_genus_id); CREATE TABLE ord_lycoperdales_genomics ( id INTEGER PRIMARY KEY AUTOINCREMENT, assembly_id INTEGER NOT NULL, species_id INTEGER, avg_genome_size_mb REAL, avg_gene_count INTEGER, avg_busco_complete_pct REAL, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (assembly_id) REFERENCES gen_assemblies (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lycoperdales_genomics_assembly_id ON ord_lycoperdales_genomics (assembly_id); CREATE INDEX ix_ord_lycoperdales_genomics_species_id ON ord_lycoperdales_genomics (species_id); CREATE TABLE ord_lycoperdales_biochemistry ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, typicality TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lycoperdales_biochemistry_species_id ON ord_lycoperdales_biochemistry (species_id); CREATE INDEX ix_ord_lycoperdales_biochemistry_compound_id ON ord_lycoperdales_biochemistry (compound_id); CREATE TABLE ord_lycoperdales_cultivation_notes ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, typical_growth_rate_mm_per_day REAL, preferred_media_type_id INTEGER, optimal_temperature_c REAL, difficulty_score INTEGER CHECK (difficulty_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (preferred_media_type_id) REFERENCES cul_media_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lycoperdales_cultivation_notes_species_id ON ord_lycoperdales_cultivation_notes (species_id); CREATE INDEX ix_ord_lycoperdales_cultivation_notes_strain_id ON ord_lycoperdales_cultivation_notes (strain_id); CREATE TABLE ord_lycoperdales_pathogenicity ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, disease_id INTEGER, severity_score INTEGER CHECK (severity_score BETWEEN 1 AND 5), publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (disease_id) REFERENCES pat_diseases (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lycoperdales_pathogenicity_species_id ON ord_lycoperdales_pathogenicity (species_id); CREATE INDEX ix_ord_lycoperdales_pathogenicity_host_id ON ord_lycoperdales_pathogenicity (host_id); CREATE TABLE ord_lycoperdales_edibility ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, edibility_class TEXT, preparation_notes TEXT, regional_tradition_country_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (regional_tradition_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lycoperdales_edibility_species_id ON ord_lycoperdales_edibility (species_id); CREATE INDEX ix_ord_lycoperdales_edibility_regional_tradition_country_id ON ord_lycoperdales_edibility (regional_tradition_country_id); CREATE TABLE ord_lycoperdales_medicinal_uses ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, traditional_use_text TEXT, modern_evidence_level TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lycoperdales_medicinal_uses_species_id ON ord_lycoperdales_medicinal_uses (species_id); CREATE INDEX ix_ord_lycoperdales_medicinal_uses_publication_id ON ord_lycoperdales_medicinal_uses (publication_id); CREATE TABLE ord_lycoperdales_taxonomic_revisions ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER NOT NULL, affected_family_id INTEGER, affected_genus_id INTEGER, revision_summary TEXT, revision_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_family_id) REFERENCES tax_families (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lycoperdales_taxonomic_revisions_publication_id ON ord_lycoperdales_taxonomic_revisions (publication_id); CREATE INDEX ix_ord_lycoperdales_taxonomic_revisions_affected_family_id ON ord_lycoperdales_taxonomic_revisions (affected_family_id); CREATE TABLE ord_lycoperdales_conservation_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, national_redlist_category TEXT, habitat_pressure_text TEXT, last_assessment_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lycoperdales_conservation_status_species_id ON ord_lycoperdales_conservation_status (species_id); CREATE INDEX ix_ord_lycoperdales_conservation_status_country_id ON ord_lycoperdales_conservation_status (country_id); CREATE TABLE ord_lycoperdales_diagnostic_keys ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER, key_title TEXT NOT NULL, region_country_id INTEGER, n_taxa_covered INTEGER, key_format TEXT, includes_microscopy INTEGER NOT NULL DEFAULT 0, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lycoperdales_diagnostic_keys_publication_id ON ord_lycoperdales_diagnostic_keys (publication_id); CREATE INDEX ix_ord_lycoperdales_diagnostic_keys_region_country_id ON ord_lycoperdales_diagnostic_keys (region_country_id); CREATE TABLE ord_lycoperdales_type_species_register ( id INTEGER PRIMARY KEY AUTOINCREMENT, focal_genus_id INTEGER NOT NULL, type_species_id INTEGER, designation_publication_id INTEGER, designation_year INTEGER, designated_by_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (designation_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lycoperdales_type_species_register_focal_genus_id ON ord_lycoperdales_type_species_register (focal_genus_id); CREATE INDEX ix_ord_lycoperdales_type_species_register_type_species_id ON ord_lycoperdales_type_species_register (type_species_id); CREATE TABLE ord_lycoperdales_distribution_grids ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, grid_cell_code TEXT NOT NULL, centroid_lat REAL, centroid_lon REAL, record_count INTEGER, first_record_year INTEGER, most_recent_record_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lycoperdales_distribution_grids_species_id ON ord_lycoperdales_distribution_grids (species_id); CREATE INDEX ix_ord_lycoperdales_distribution_grids_country_id ON ord_lycoperdales_distribution_grids (country_id); CREATE TABLE ord_lycoperdales_microclimate_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER, publication_id INTEGER, substrate_temperature_c REAL, substrate_moisture_pct REAL, canopy_closure_pct REAL, photosynthetic_par_umol_m2_s REAL, days_post_rainfall INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lycoperdales_microclimate_studies_species_id ON ord_lycoperdales_microclimate_studies (species_id); CREATE INDEX ix_ord_lycoperdales_microclimate_studies_publication_id ON ord_lycoperdales_microclimate_studies (publication_id); CREATE TABLE ord_lycoperdales_dna_barcoding_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, its_sequenced INTEGER NOT NULL DEFAULT 0, lsu_sequenced INTEGER NOT NULL DEFAULT 0, rpb2_sequenced INTEGER NOT NULL DEFAULT 0, ef1a_sequenced INTEGER NOT NULL DEFAULT 0, genome_assembled INTEGER NOT NULL DEFAULT 0, priority_for_sequencing_score INTEGER CHECK (priority_for_sequencing_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lycoperdales_dna_barcoding_status_species_id ON ord_lycoperdales_dna_barcoding_status (species_id); CREATE TABLE ord_lycoperdales_spore_print_data ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, specimen_id INTEGER, print_color_label TEXT, print_color_chip_id INTEGER, spore_density_per_mm2 REAL, collection_substrate TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (print_color_chip_id) REFERENCES mor_color_chips (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lycoperdales_spore_print_data_species_id ON ord_lycoperdales_spore_print_data (species_id); CREATE INDEX ix_ord_lycoperdales_spore_print_data_specimen_id ON ord_lycoperdales_spore_print_data (specimen_id); CREATE TABLE ord_lycoperdales_mating_systems ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, system_type TEXT, mating_loci_count INTEGER, publication_id INTEGER, notes_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lycoperdales_mating_systems_species_id ON ord_lycoperdales_mating_systems (species_id); CREATE INDEX ix_ord_lycoperdales_mating_systems_publication_id ON ord_lycoperdales_mating_systems (publication_id); CREATE TABLE ord_lycoperdales_nutrient_uptake_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, nitrogen_source TEXT, carbon_source TEXT, growth_response TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lycoperdales_nutrient_uptake_studies_species_id ON ord_lycoperdales_nutrient_uptake_studies (species_id); CREATE INDEX ix_ord_lycoperdales_nutrient_uptake_studies_strain_id ON ord_lycoperdales_nutrient_uptake_studies (strain_id); CREATE TABLE ord_lycoperdales_range_maps ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, polygon_file_uri TEXT NOT NULL, source_methodology TEXT, area_km2 REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lycoperdales_range_maps_species_id ON ord_lycoperdales_range_maps (species_id); CREATE INDEX ix_ord_lycoperdales_range_maps_publication_id ON ord_lycoperdales_range_maps (publication_id); CREATE TABLE ord_lycoperdales_abundance_estimates ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, estimate_kind TEXT, value_min REAL, value_max REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lycoperdales_abundance_estimates_species_id ON ord_lycoperdales_abundance_estimates (species_id); CREATE INDEX ix_ord_lycoperdales_abundance_estimates_country_id ON ord_lycoperdales_abundance_estimates (country_id); CREATE TABLE ord_lycoperdales_toxin_profiles ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, presence TEXT, typical_concentration_mg_per_kg REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lycoperdales_toxin_profiles_species_id ON ord_lycoperdales_toxin_profiles (species_id); CREATE INDEX ix_ord_lycoperdales_toxin_profiles_compound_id ON ord_lycoperdales_toxin_profiles (compound_id); CREATE TABLE ord_lycoperdales_enzyme_activity_assays ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, enzyme_id INTEGER NOT NULL, strain_id INTEGER, activity_u_per_mg REAL, temperature_c REAL, ph REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (enzyme_id) REFERENCES bio_enzymes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lycoperdales_enzyme_activity_assays_species_id ON ord_lycoperdales_enzyme_activity_assays (species_id); CREATE INDEX ix_ord_lycoperdales_enzyme_activity_assays_enzyme_id ON ord_lycoperdales_enzyme_activity_assays (enzyme_id); CREATE TABLE ord_lycoperdales_biocontrol_evaluations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, target_pest_text TEXT NOT NULL, efficacy_pct REAL, trial_setting TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lycoperdales_biocontrol_evaluations_species_id ON ord_lycoperdales_biocontrol_evaluations (species_id); CREATE INDEX ix_ord_lycoperdales_biocontrol_evaluations_publication_id ON ord_lycoperdales_biocontrol_evaluations (publication_id); CREATE TABLE ord_lycoperdales_regional_checklists ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, checklist_publication_id INTEGER, status TEXT, checklist_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (checklist_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lycoperdales_regional_checklists_species_id ON ord_lycoperdales_regional_checklists (species_id); CREATE INDEX ix_ord_lycoperdales_regional_checklists_country_id ON ord_lycoperdales_regional_checklists (country_id); CREATE TABLE ord_sebacinales_morphology ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, hymenium_color_at_maturity TEXT, context_color_at_maturity TEXT, characteristic_microstructure TEXT, diagnostic_features_text TEXT, notes_kohler_reaction TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_sebacinales_morphology_specimen_id ON ord_sebacinales_morphology (specimen_id); CREATE INDEX ix_ord_sebacinales_morphology_species_id ON ord_sebacinales_morphology (species_id); CREATE TABLE ord_sebacinales_ecology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, dominant_habitat_id INTEGER, dominant_substrate_id INTEGER, dominant_biome_id INTEGER, trophic_strategy TEXT, typical_fruiting_period TEXT, known_distribution_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_habitat_id) REFERENCES eco_habitat_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_substrate_id) REFERENCES eco_substrate_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_biome_id) REFERENCES geo_biomes (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_sebacinales_ecology_species_id ON ord_sebacinales_ecology (species_id); CREATE INDEX ix_ord_sebacinales_ecology_dominant_habitat_id ON ord_sebacinales_ecology (dominant_habitat_id); CREATE TABLE ord_sebacinales_phenology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, season_name TEXT, region_country_id INTEGER, first_doy INTEGER, peak_doy INTEGER, last_doy INTEGER, years_observed INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_sebacinales_phenology_species_id ON ord_sebacinales_phenology (species_id); CREATE INDEX ix_ord_sebacinales_phenology_region_country_id ON ord_sebacinales_phenology (region_country_id); CREATE TABLE ord_sebacinales_host_associations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, association_type TEXT, specificity TEXT, evidence_publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (evidence_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_sebacinales_host_associations_species_id ON ord_sebacinales_host_associations (species_id); CREATE INDEX ix_ord_sebacinales_host_associations_host_id ON ord_sebacinales_host_associations (host_id); CREATE TABLE ord_sebacinales_substrate_preferences ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, substrate_id INTEGER NOT NULL, preference_score REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (substrate_id) REFERENCES eco_substrate_types (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_sebacinales_substrate_preferences_species_id ON ord_sebacinales_substrate_preferences (species_id); CREATE INDEX ix_ord_sebacinales_substrate_preferences_substrate_id ON ord_sebacinales_substrate_preferences (substrate_id); CREATE TABLE ord_sebacinales_geographic_distribution ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, occurrence_status TEXT, first_record_year INTEGER, record_count INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_sebacinales_geographic_distribution_species_id ON ord_sebacinales_geographic_distribution (species_id); CREATE INDEX ix_ord_sebacinales_geographic_distribution_country_id ON ord_sebacinales_geographic_distribution (country_id); CREATE TABLE ord_sebacinales_phylogeny ( id INTEGER PRIMARY KEY AUTOINCREMENT, tree_id INTEGER NOT NULL, focal_genus_id INTEGER, publication_id INTEGER, notes_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (tree_id) REFERENCES phy_trees (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_sebacinales_phylogeny_tree_id ON ord_sebacinales_phylogeny (tree_id); CREATE INDEX ix_ord_sebacinales_phylogeny_focal_genus_id ON ord_sebacinales_phylogeny (focal_genus_id); CREATE TABLE ord_sebacinales_genomics ( id INTEGER PRIMARY KEY AUTOINCREMENT, assembly_id INTEGER NOT NULL, species_id INTEGER, avg_genome_size_mb REAL, avg_gene_count INTEGER, avg_busco_complete_pct REAL, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (assembly_id) REFERENCES gen_assemblies (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_sebacinales_genomics_assembly_id ON ord_sebacinales_genomics (assembly_id); CREATE INDEX ix_ord_sebacinales_genomics_species_id ON ord_sebacinales_genomics (species_id); CREATE TABLE ord_sebacinales_biochemistry ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, typicality TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_sebacinales_biochemistry_species_id ON ord_sebacinales_biochemistry (species_id); CREATE INDEX ix_ord_sebacinales_biochemistry_compound_id ON ord_sebacinales_biochemistry (compound_id); CREATE TABLE ord_sebacinales_cultivation_notes ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, typical_growth_rate_mm_per_day REAL, preferred_media_type_id INTEGER, optimal_temperature_c REAL, difficulty_score INTEGER CHECK (difficulty_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (preferred_media_type_id) REFERENCES cul_media_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_sebacinales_cultivation_notes_species_id ON ord_sebacinales_cultivation_notes (species_id); CREATE INDEX ix_ord_sebacinales_cultivation_notes_strain_id ON ord_sebacinales_cultivation_notes (strain_id); CREATE TABLE ord_sebacinales_pathogenicity ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, disease_id INTEGER, severity_score INTEGER CHECK (severity_score BETWEEN 1 AND 5), publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (disease_id) REFERENCES pat_diseases (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_sebacinales_pathogenicity_species_id ON ord_sebacinales_pathogenicity (species_id); CREATE INDEX ix_ord_sebacinales_pathogenicity_host_id ON ord_sebacinales_pathogenicity (host_id); CREATE TABLE ord_sebacinales_edibility ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, edibility_class TEXT, preparation_notes TEXT, regional_tradition_country_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (regional_tradition_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_sebacinales_edibility_species_id ON ord_sebacinales_edibility (species_id); CREATE INDEX ix_ord_sebacinales_edibility_regional_tradition_country_id ON ord_sebacinales_edibility (regional_tradition_country_id); CREATE TABLE ord_sebacinales_medicinal_uses ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, traditional_use_text TEXT, modern_evidence_level TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_sebacinales_medicinal_uses_species_id ON ord_sebacinales_medicinal_uses (species_id); CREATE INDEX ix_ord_sebacinales_medicinal_uses_publication_id ON ord_sebacinales_medicinal_uses (publication_id); CREATE TABLE ord_sebacinales_taxonomic_revisions ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER NOT NULL, affected_family_id INTEGER, affected_genus_id INTEGER, revision_summary TEXT, revision_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_family_id) REFERENCES tax_families (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_sebacinales_taxonomic_revisions_publication_id ON ord_sebacinales_taxonomic_revisions (publication_id); CREATE INDEX ix_ord_sebacinales_taxonomic_revisions_affected_family_id ON ord_sebacinales_taxonomic_revisions (affected_family_id); CREATE TABLE ord_sebacinales_conservation_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, national_redlist_category TEXT, habitat_pressure_text TEXT, last_assessment_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_sebacinales_conservation_status_species_id ON ord_sebacinales_conservation_status (species_id); CREATE INDEX ix_ord_sebacinales_conservation_status_country_id ON ord_sebacinales_conservation_status (country_id); CREATE TABLE ord_sebacinales_diagnostic_keys ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER, key_title TEXT NOT NULL, region_country_id INTEGER, n_taxa_covered INTEGER, key_format TEXT, includes_microscopy INTEGER NOT NULL DEFAULT 0, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_sebacinales_diagnostic_keys_publication_id ON ord_sebacinales_diagnostic_keys (publication_id); CREATE INDEX ix_ord_sebacinales_diagnostic_keys_region_country_id ON ord_sebacinales_diagnostic_keys (region_country_id); CREATE TABLE ord_sebacinales_type_species_register ( id INTEGER PRIMARY KEY AUTOINCREMENT, focal_genus_id INTEGER NOT NULL, type_species_id INTEGER, designation_publication_id INTEGER, designation_year INTEGER, designated_by_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (designation_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_sebacinales_type_species_register_focal_genus_id ON ord_sebacinales_type_species_register (focal_genus_id); CREATE INDEX ix_ord_sebacinales_type_species_register_type_species_id ON ord_sebacinales_type_species_register (type_species_id); CREATE TABLE ord_sebacinales_distribution_grids ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, grid_cell_code TEXT NOT NULL, centroid_lat REAL, centroid_lon REAL, record_count INTEGER, first_record_year INTEGER, most_recent_record_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_sebacinales_distribution_grids_species_id ON ord_sebacinales_distribution_grids (species_id); CREATE INDEX ix_ord_sebacinales_distribution_grids_country_id ON ord_sebacinales_distribution_grids (country_id); CREATE TABLE ord_sebacinales_microclimate_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER, publication_id INTEGER, substrate_temperature_c REAL, substrate_moisture_pct REAL, canopy_closure_pct REAL, photosynthetic_par_umol_m2_s REAL, days_post_rainfall INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_sebacinales_microclimate_studies_species_id ON ord_sebacinales_microclimate_studies (species_id); CREATE INDEX ix_ord_sebacinales_microclimate_studies_publication_id ON ord_sebacinales_microclimate_studies (publication_id); CREATE TABLE ord_sebacinales_dna_barcoding_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, its_sequenced INTEGER NOT NULL DEFAULT 0, lsu_sequenced INTEGER NOT NULL DEFAULT 0, rpb2_sequenced INTEGER NOT NULL DEFAULT 0, ef1a_sequenced INTEGER NOT NULL DEFAULT 0, genome_assembled INTEGER NOT NULL DEFAULT 0, priority_for_sequencing_score INTEGER CHECK (priority_for_sequencing_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_sebacinales_dna_barcoding_status_species_id ON ord_sebacinales_dna_barcoding_status (species_id); CREATE TABLE ord_sebacinales_spore_print_data ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, specimen_id INTEGER, print_color_label TEXT, print_color_chip_id INTEGER, spore_density_per_mm2 REAL, collection_substrate TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (print_color_chip_id) REFERENCES mor_color_chips (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_sebacinales_spore_print_data_species_id ON ord_sebacinales_spore_print_data (species_id); CREATE INDEX ix_ord_sebacinales_spore_print_data_specimen_id ON ord_sebacinales_spore_print_data (specimen_id); CREATE TABLE ord_sebacinales_mating_systems ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, system_type TEXT, mating_loci_count INTEGER, publication_id INTEGER, notes_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_sebacinales_mating_systems_species_id ON ord_sebacinales_mating_systems (species_id); CREATE INDEX ix_ord_sebacinales_mating_systems_publication_id ON ord_sebacinales_mating_systems (publication_id); CREATE TABLE ord_sebacinales_nutrient_uptake_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, nitrogen_source TEXT, carbon_source TEXT, growth_response TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_sebacinales_nutrient_uptake_studies_species_id ON ord_sebacinales_nutrient_uptake_studies (species_id); CREATE INDEX ix_ord_sebacinales_nutrient_uptake_studies_strain_id ON ord_sebacinales_nutrient_uptake_studies (strain_id); CREATE TABLE ord_sebacinales_range_maps ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, polygon_file_uri TEXT NOT NULL, source_methodology TEXT, area_km2 REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_sebacinales_range_maps_species_id ON ord_sebacinales_range_maps (species_id); CREATE INDEX ix_ord_sebacinales_range_maps_publication_id ON ord_sebacinales_range_maps (publication_id); CREATE TABLE ord_sebacinales_abundance_estimates ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, estimate_kind TEXT, value_min REAL, value_max REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_sebacinales_abundance_estimates_species_id ON ord_sebacinales_abundance_estimates (species_id); CREATE INDEX ix_ord_sebacinales_abundance_estimates_country_id ON ord_sebacinales_abundance_estimates (country_id); CREATE TABLE ord_sebacinales_toxin_profiles ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, presence TEXT, typical_concentration_mg_per_kg REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_sebacinales_toxin_profiles_species_id ON ord_sebacinales_toxin_profiles (species_id); CREATE INDEX ix_ord_sebacinales_toxin_profiles_compound_id ON ord_sebacinales_toxin_profiles (compound_id); CREATE TABLE ord_sebacinales_enzyme_activity_assays ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, enzyme_id INTEGER NOT NULL, strain_id INTEGER, activity_u_per_mg REAL, temperature_c REAL, ph REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (enzyme_id) REFERENCES bio_enzymes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_sebacinales_enzyme_activity_assays_species_id ON ord_sebacinales_enzyme_activity_assays (species_id); CREATE INDEX ix_ord_sebacinales_enzyme_activity_assays_enzyme_id ON ord_sebacinales_enzyme_activity_assays (enzyme_id); CREATE TABLE ord_sebacinales_biocontrol_evaluations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, target_pest_text TEXT NOT NULL, efficacy_pct REAL, trial_setting TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_sebacinales_biocontrol_evaluations_species_id ON ord_sebacinales_biocontrol_evaluations (species_id); CREATE INDEX ix_ord_sebacinales_biocontrol_evaluations_publication_id ON ord_sebacinales_biocontrol_evaluations (publication_id); CREATE TABLE ord_sebacinales_regional_checklists ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, checklist_publication_id INTEGER, status TEXT, checklist_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (checklist_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_sebacinales_regional_checklists_species_id ON ord_sebacinales_regional_checklists (species_id); CREATE INDEX ix_ord_sebacinales_regional_checklists_country_id ON ord_sebacinales_regional_checklists (country_id); CREATE TABLE ord_atheliales_morphology ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, hymenium_color_at_maturity TEXT, context_color_at_maturity TEXT, characteristic_microstructure TEXT, diagnostic_features_text TEXT, notes_kohler_reaction TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_atheliales_morphology_specimen_id ON ord_atheliales_morphology (specimen_id); CREATE INDEX ix_ord_atheliales_morphology_species_id ON ord_atheliales_morphology (species_id); CREATE TABLE ord_atheliales_ecology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, dominant_habitat_id INTEGER, dominant_substrate_id INTEGER, dominant_biome_id INTEGER, trophic_strategy TEXT, typical_fruiting_period TEXT, known_distribution_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_habitat_id) REFERENCES eco_habitat_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_substrate_id) REFERENCES eco_substrate_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_biome_id) REFERENCES geo_biomes (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_atheliales_ecology_species_id ON ord_atheliales_ecology (species_id); CREATE INDEX ix_ord_atheliales_ecology_dominant_habitat_id ON ord_atheliales_ecology (dominant_habitat_id); CREATE TABLE ord_atheliales_phenology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, season_name TEXT, region_country_id INTEGER, first_doy INTEGER, peak_doy INTEGER, last_doy INTEGER, years_observed INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_atheliales_phenology_species_id ON ord_atheliales_phenology (species_id); CREATE INDEX ix_ord_atheliales_phenology_region_country_id ON ord_atheliales_phenology (region_country_id); CREATE TABLE ord_atheliales_host_associations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, association_type TEXT, specificity TEXT, evidence_publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (evidence_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_atheliales_host_associations_species_id ON ord_atheliales_host_associations (species_id); CREATE INDEX ix_ord_atheliales_host_associations_host_id ON ord_atheliales_host_associations (host_id); CREATE TABLE ord_atheliales_substrate_preferences ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, substrate_id INTEGER NOT NULL, preference_score REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (substrate_id) REFERENCES eco_substrate_types (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_atheliales_substrate_preferences_species_id ON ord_atheliales_substrate_preferences (species_id); CREATE INDEX ix_ord_atheliales_substrate_preferences_substrate_id ON ord_atheliales_substrate_preferences (substrate_id); CREATE TABLE ord_atheliales_geographic_distribution ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, occurrence_status TEXT, first_record_year INTEGER, record_count INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_atheliales_geographic_distribution_species_id ON ord_atheliales_geographic_distribution (species_id); CREATE INDEX ix_ord_atheliales_geographic_distribution_country_id ON ord_atheliales_geographic_distribution (country_id); CREATE TABLE ord_atheliales_phylogeny ( id INTEGER PRIMARY KEY AUTOINCREMENT, tree_id INTEGER NOT NULL, focal_genus_id INTEGER, publication_id INTEGER, notes_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (tree_id) REFERENCES phy_trees (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_atheliales_phylogeny_tree_id ON ord_atheliales_phylogeny (tree_id); CREATE INDEX ix_ord_atheliales_phylogeny_focal_genus_id ON ord_atheliales_phylogeny (focal_genus_id); CREATE TABLE ord_atheliales_genomics ( id INTEGER PRIMARY KEY AUTOINCREMENT, assembly_id INTEGER NOT NULL, species_id INTEGER, avg_genome_size_mb REAL, avg_gene_count INTEGER, avg_busco_complete_pct REAL, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (assembly_id) REFERENCES gen_assemblies (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_atheliales_genomics_assembly_id ON ord_atheliales_genomics (assembly_id); CREATE INDEX ix_ord_atheliales_genomics_species_id ON ord_atheliales_genomics (species_id); CREATE TABLE ord_atheliales_biochemistry ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, typicality TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_atheliales_biochemistry_species_id ON ord_atheliales_biochemistry (species_id); CREATE INDEX ix_ord_atheliales_biochemistry_compound_id ON ord_atheliales_biochemistry (compound_id); CREATE TABLE ord_atheliales_cultivation_notes ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, typical_growth_rate_mm_per_day REAL, preferred_media_type_id INTEGER, optimal_temperature_c REAL, difficulty_score INTEGER CHECK (difficulty_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (preferred_media_type_id) REFERENCES cul_media_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_atheliales_cultivation_notes_species_id ON ord_atheliales_cultivation_notes (species_id); CREATE INDEX ix_ord_atheliales_cultivation_notes_strain_id ON ord_atheliales_cultivation_notes (strain_id); CREATE TABLE ord_atheliales_pathogenicity ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, disease_id INTEGER, severity_score INTEGER CHECK (severity_score BETWEEN 1 AND 5), publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (disease_id) REFERENCES pat_diseases (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_atheliales_pathogenicity_species_id ON ord_atheliales_pathogenicity (species_id); CREATE INDEX ix_ord_atheliales_pathogenicity_host_id ON ord_atheliales_pathogenicity (host_id); CREATE TABLE ord_atheliales_edibility ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, edibility_class TEXT, preparation_notes TEXT, regional_tradition_country_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (regional_tradition_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_atheliales_edibility_species_id ON ord_atheliales_edibility (species_id); CREATE INDEX ix_ord_atheliales_edibility_regional_tradition_country_id ON ord_atheliales_edibility (regional_tradition_country_id); CREATE TABLE ord_atheliales_medicinal_uses ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, traditional_use_text TEXT, modern_evidence_level TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_atheliales_medicinal_uses_species_id ON ord_atheliales_medicinal_uses (species_id); CREATE INDEX ix_ord_atheliales_medicinal_uses_publication_id ON ord_atheliales_medicinal_uses (publication_id); CREATE TABLE ord_atheliales_taxonomic_revisions ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER NOT NULL, affected_family_id INTEGER, affected_genus_id INTEGER, revision_summary TEXT, revision_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_family_id) REFERENCES tax_families (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_atheliales_taxonomic_revisions_publication_id ON ord_atheliales_taxonomic_revisions (publication_id); CREATE INDEX ix_ord_atheliales_taxonomic_revisions_affected_family_id ON ord_atheliales_taxonomic_revisions (affected_family_id); CREATE TABLE ord_atheliales_conservation_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, national_redlist_category TEXT, habitat_pressure_text TEXT, last_assessment_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_atheliales_conservation_status_species_id ON ord_atheliales_conservation_status (species_id); CREATE INDEX ix_ord_atheliales_conservation_status_country_id ON ord_atheliales_conservation_status (country_id); CREATE TABLE ord_atheliales_diagnostic_keys ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER, key_title TEXT NOT NULL, region_country_id INTEGER, n_taxa_covered INTEGER, key_format TEXT, includes_microscopy INTEGER NOT NULL DEFAULT 0, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_atheliales_diagnostic_keys_publication_id ON ord_atheliales_diagnostic_keys (publication_id); CREATE INDEX ix_ord_atheliales_diagnostic_keys_region_country_id ON ord_atheliales_diagnostic_keys (region_country_id); CREATE TABLE ord_atheliales_type_species_register ( id INTEGER PRIMARY KEY AUTOINCREMENT, focal_genus_id INTEGER NOT NULL, type_species_id INTEGER, designation_publication_id INTEGER, designation_year INTEGER, designated_by_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (designation_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_atheliales_type_species_register_focal_genus_id ON ord_atheliales_type_species_register (focal_genus_id); CREATE INDEX ix_ord_atheliales_type_species_register_type_species_id ON ord_atheliales_type_species_register (type_species_id); CREATE TABLE ord_atheliales_distribution_grids ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, grid_cell_code TEXT NOT NULL, centroid_lat REAL, centroid_lon REAL, record_count INTEGER, first_record_year INTEGER, most_recent_record_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_atheliales_distribution_grids_species_id ON ord_atheliales_distribution_grids (species_id); CREATE INDEX ix_ord_atheliales_distribution_grids_country_id ON ord_atheliales_distribution_grids (country_id); CREATE TABLE ord_atheliales_microclimate_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER, publication_id INTEGER, substrate_temperature_c REAL, substrate_moisture_pct REAL, canopy_closure_pct REAL, photosynthetic_par_umol_m2_s REAL, days_post_rainfall INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_atheliales_microclimate_studies_species_id ON ord_atheliales_microclimate_studies (species_id); CREATE INDEX ix_ord_atheliales_microclimate_studies_publication_id ON ord_atheliales_microclimate_studies (publication_id); CREATE TABLE ord_atheliales_dna_barcoding_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, its_sequenced INTEGER NOT NULL DEFAULT 0, lsu_sequenced INTEGER NOT NULL DEFAULT 0, rpb2_sequenced INTEGER NOT NULL DEFAULT 0, ef1a_sequenced INTEGER NOT NULL DEFAULT 0, genome_assembled INTEGER NOT NULL DEFAULT 0, priority_for_sequencing_score INTEGER CHECK (priority_for_sequencing_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_atheliales_dna_barcoding_status_species_id ON ord_atheliales_dna_barcoding_status (species_id); CREATE TABLE ord_atheliales_spore_print_data ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, specimen_id INTEGER, print_color_label TEXT, print_color_chip_id INTEGER, spore_density_per_mm2 REAL, collection_substrate TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (print_color_chip_id) REFERENCES mor_color_chips (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_atheliales_spore_print_data_species_id ON ord_atheliales_spore_print_data (species_id); CREATE INDEX ix_ord_atheliales_spore_print_data_specimen_id ON ord_atheliales_spore_print_data (specimen_id); CREATE TABLE ord_atheliales_mating_systems ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, system_type TEXT, mating_loci_count INTEGER, publication_id INTEGER, notes_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_atheliales_mating_systems_species_id ON ord_atheliales_mating_systems (species_id); CREATE INDEX ix_ord_atheliales_mating_systems_publication_id ON ord_atheliales_mating_systems (publication_id); CREATE TABLE ord_atheliales_nutrient_uptake_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, nitrogen_source TEXT, carbon_source TEXT, growth_response TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_atheliales_nutrient_uptake_studies_species_id ON ord_atheliales_nutrient_uptake_studies (species_id); CREATE INDEX ix_ord_atheliales_nutrient_uptake_studies_strain_id ON ord_atheliales_nutrient_uptake_studies (strain_id); CREATE TABLE ord_atheliales_range_maps ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, polygon_file_uri TEXT NOT NULL, source_methodology TEXT, area_km2 REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_atheliales_range_maps_species_id ON ord_atheliales_range_maps (species_id); CREATE INDEX ix_ord_atheliales_range_maps_publication_id ON ord_atheliales_range_maps (publication_id); CREATE TABLE ord_atheliales_abundance_estimates ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, estimate_kind TEXT, value_min REAL, value_max REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_atheliales_abundance_estimates_species_id ON ord_atheliales_abundance_estimates (species_id); CREATE INDEX ix_ord_atheliales_abundance_estimates_country_id ON ord_atheliales_abundance_estimates (country_id); CREATE TABLE ord_atheliales_toxin_profiles ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, presence TEXT, typical_concentration_mg_per_kg REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_atheliales_toxin_profiles_species_id ON ord_atheliales_toxin_profiles (species_id); CREATE INDEX ix_ord_atheliales_toxin_profiles_compound_id ON ord_atheliales_toxin_profiles (compound_id); CREATE TABLE ord_atheliales_enzyme_activity_assays ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, enzyme_id INTEGER NOT NULL, strain_id INTEGER, activity_u_per_mg REAL, temperature_c REAL, ph REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (enzyme_id) REFERENCES bio_enzymes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_atheliales_enzyme_activity_assays_species_id ON ord_atheliales_enzyme_activity_assays (species_id); CREATE INDEX ix_ord_atheliales_enzyme_activity_assays_enzyme_id ON ord_atheliales_enzyme_activity_assays (enzyme_id); CREATE TABLE ord_atheliales_biocontrol_evaluations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, target_pest_text TEXT NOT NULL, efficacy_pct REAL, trial_setting TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_atheliales_biocontrol_evaluations_species_id ON ord_atheliales_biocontrol_evaluations (species_id); CREATE INDEX ix_ord_atheliales_biocontrol_evaluations_publication_id ON ord_atheliales_biocontrol_evaluations (publication_id); CREATE TABLE ord_atheliales_regional_checklists ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, checklist_publication_id INTEGER, status TEXT, checklist_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (checklist_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_atheliales_regional_checklists_species_id ON ord_atheliales_regional_checklists (species_id); CREATE INDEX ix_ord_atheliales_regional_checklists_country_id ON ord_atheliales_regional_checklists (country_id); CREATE TABLE ord_corticiales_morphology ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, hymenium_color_at_maturity TEXT, context_color_at_maturity TEXT, characteristic_microstructure TEXT, diagnostic_features_text TEXT, notes_kohler_reaction TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_corticiales_morphology_specimen_id ON ord_corticiales_morphology (specimen_id); CREATE INDEX ix_ord_corticiales_morphology_species_id ON ord_corticiales_morphology (species_id); CREATE TABLE ord_corticiales_ecology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, dominant_habitat_id INTEGER, dominant_substrate_id INTEGER, dominant_biome_id INTEGER, trophic_strategy TEXT, typical_fruiting_period TEXT, known_distribution_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_habitat_id) REFERENCES eco_habitat_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_substrate_id) REFERENCES eco_substrate_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_biome_id) REFERENCES geo_biomes (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_corticiales_ecology_species_id ON ord_corticiales_ecology (species_id); CREATE INDEX ix_ord_corticiales_ecology_dominant_habitat_id ON ord_corticiales_ecology (dominant_habitat_id); CREATE TABLE ord_corticiales_phenology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, season_name TEXT, region_country_id INTEGER, first_doy INTEGER, peak_doy INTEGER, last_doy INTEGER, years_observed INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_corticiales_phenology_species_id ON ord_corticiales_phenology (species_id); CREATE INDEX ix_ord_corticiales_phenology_region_country_id ON ord_corticiales_phenology (region_country_id); CREATE TABLE ord_corticiales_host_associations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, association_type TEXT, specificity TEXT, evidence_publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (evidence_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_corticiales_host_associations_species_id ON ord_corticiales_host_associations (species_id); CREATE INDEX ix_ord_corticiales_host_associations_host_id ON ord_corticiales_host_associations (host_id); CREATE TABLE ord_corticiales_substrate_preferences ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, substrate_id INTEGER NOT NULL, preference_score REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (substrate_id) REFERENCES eco_substrate_types (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_corticiales_substrate_preferences_species_id ON ord_corticiales_substrate_preferences (species_id); CREATE INDEX ix_ord_corticiales_substrate_preferences_substrate_id ON ord_corticiales_substrate_preferences (substrate_id); CREATE TABLE ord_corticiales_geographic_distribution ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, occurrence_status TEXT, first_record_year INTEGER, record_count INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_corticiales_geographic_distribution_species_id ON ord_corticiales_geographic_distribution (species_id); CREATE INDEX ix_ord_corticiales_geographic_distribution_country_id ON ord_corticiales_geographic_distribution (country_id); CREATE TABLE ord_corticiales_phylogeny ( id INTEGER PRIMARY KEY AUTOINCREMENT, tree_id INTEGER NOT NULL, focal_genus_id INTEGER, publication_id INTEGER, notes_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (tree_id) REFERENCES phy_trees (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_corticiales_phylogeny_tree_id ON ord_corticiales_phylogeny (tree_id); CREATE INDEX ix_ord_corticiales_phylogeny_focal_genus_id ON ord_corticiales_phylogeny (focal_genus_id); CREATE TABLE ord_corticiales_genomics ( id INTEGER PRIMARY KEY AUTOINCREMENT, assembly_id INTEGER NOT NULL, species_id INTEGER, avg_genome_size_mb REAL, avg_gene_count INTEGER, avg_busco_complete_pct REAL, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (assembly_id) REFERENCES gen_assemblies (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_corticiales_genomics_assembly_id ON ord_corticiales_genomics (assembly_id); CREATE INDEX ix_ord_corticiales_genomics_species_id ON ord_corticiales_genomics (species_id); CREATE TABLE ord_corticiales_biochemistry ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, typicality TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_corticiales_biochemistry_species_id ON ord_corticiales_biochemistry (species_id); CREATE INDEX ix_ord_corticiales_biochemistry_compound_id ON ord_corticiales_biochemistry (compound_id); CREATE TABLE ord_corticiales_cultivation_notes ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, typical_growth_rate_mm_per_day REAL, preferred_media_type_id INTEGER, optimal_temperature_c REAL, difficulty_score INTEGER CHECK (difficulty_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (preferred_media_type_id) REFERENCES cul_media_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_corticiales_cultivation_notes_species_id ON ord_corticiales_cultivation_notes (species_id); CREATE INDEX ix_ord_corticiales_cultivation_notes_strain_id ON ord_corticiales_cultivation_notes (strain_id); CREATE TABLE ord_corticiales_pathogenicity ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, disease_id INTEGER, severity_score INTEGER CHECK (severity_score BETWEEN 1 AND 5), publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (disease_id) REFERENCES pat_diseases (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_corticiales_pathogenicity_species_id ON ord_corticiales_pathogenicity (species_id); CREATE INDEX ix_ord_corticiales_pathogenicity_host_id ON ord_corticiales_pathogenicity (host_id); CREATE TABLE ord_corticiales_edibility ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, edibility_class TEXT, preparation_notes TEXT, regional_tradition_country_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (regional_tradition_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_corticiales_edibility_species_id ON ord_corticiales_edibility (species_id); CREATE INDEX ix_ord_corticiales_edibility_regional_tradition_country_id ON ord_corticiales_edibility (regional_tradition_country_id); CREATE TABLE ord_corticiales_medicinal_uses ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, traditional_use_text TEXT, modern_evidence_level TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_corticiales_medicinal_uses_species_id ON ord_corticiales_medicinal_uses (species_id); CREATE INDEX ix_ord_corticiales_medicinal_uses_publication_id ON ord_corticiales_medicinal_uses (publication_id); CREATE TABLE ord_corticiales_taxonomic_revisions ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER NOT NULL, affected_family_id INTEGER, affected_genus_id INTEGER, revision_summary TEXT, revision_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_family_id) REFERENCES tax_families (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_corticiales_taxonomic_revisions_publication_id ON ord_corticiales_taxonomic_revisions (publication_id); CREATE INDEX ix_ord_corticiales_taxonomic_revisions_affected_family_id ON ord_corticiales_taxonomic_revisions (affected_family_id); CREATE TABLE ord_corticiales_conservation_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, national_redlist_category TEXT, habitat_pressure_text TEXT, last_assessment_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_corticiales_conservation_status_species_id ON ord_corticiales_conservation_status (species_id); CREATE INDEX ix_ord_corticiales_conservation_status_country_id ON ord_corticiales_conservation_status (country_id); CREATE TABLE ord_corticiales_diagnostic_keys ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER, key_title TEXT NOT NULL, region_country_id INTEGER, n_taxa_covered INTEGER, key_format TEXT, includes_microscopy INTEGER NOT NULL DEFAULT 0, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_corticiales_diagnostic_keys_publication_id ON ord_corticiales_diagnostic_keys (publication_id); CREATE INDEX ix_ord_corticiales_diagnostic_keys_region_country_id ON ord_corticiales_diagnostic_keys (region_country_id); CREATE TABLE ord_corticiales_type_species_register ( id INTEGER PRIMARY KEY AUTOINCREMENT, focal_genus_id INTEGER NOT NULL, type_species_id INTEGER, designation_publication_id INTEGER, designation_year INTEGER, designated_by_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (designation_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_corticiales_type_species_register_focal_genus_id ON ord_corticiales_type_species_register (focal_genus_id); CREATE INDEX ix_ord_corticiales_type_species_register_type_species_id ON ord_corticiales_type_species_register (type_species_id); CREATE TABLE ord_corticiales_distribution_grids ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, grid_cell_code TEXT NOT NULL, centroid_lat REAL, centroid_lon REAL, record_count INTEGER, first_record_year INTEGER, most_recent_record_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_corticiales_distribution_grids_species_id ON ord_corticiales_distribution_grids (species_id); CREATE INDEX ix_ord_corticiales_distribution_grids_country_id ON ord_corticiales_distribution_grids (country_id); CREATE TABLE ord_corticiales_microclimate_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER, publication_id INTEGER, substrate_temperature_c REAL, substrate_moisture_pct REAL, canopy_closure_pct REAL, photosynthetic_par_umol_m2_s REAL, days_post_rainfall INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_corticiales_microclimate_studies_species_id ON ord_corticiales_microclimate_studies (species_id); CREATE INDEX ix_ord_corticiales_microclimate_studies_publication_id ON ord_corticiales_microclimate_studies (publication_id); CREATE TABLE ord_corticiales_dna_barcoding_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, its_sequenced INTEGER NOT NULL DEFAULT 0, lsu_sequenced INTEGER NOT NULL DEFAULT 0, rpb2_sequenced INTEGER NOT NULL DEFAULT 0, ef1a_sequenced INTEGER NOT NULL DEFAULT 0, genome_assembled INTEGER NOT NULL DEFAULT 0, priority_for_sequencing_score INTEGER CHECK (priority_for_sequencing_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_corticiales_dna_barcoding_status_species_id ON ord_corticiales_dna_barcoding_status (species_id); CREATE TABLE ord_corticiales_spore_print_data ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, specimen_id INTEGER, print_color_label TEXT, print_color_chip_id INTEGER, spore_density_per_mm2 REAL, collection_substrate TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (print_color_chip_id) REFERENCES mor_color_chips (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_corticiales_spore_print_data_species_id ON ord_corticiales_spore_print_data (species_id); CREATE INDEX ix_ord_corticiales_spore_print_data_specimen_id ON ord_corticiales_spore_print_data (specimen_id); CREATE TABLE ord_corticiales_mating_systems ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, system_type TEXT, mating_loci_count INTEGER, publication_id INTEGER, notes_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_corticiales_mating_systems_species_id ON ord_corticiales_mating_systems (species_id); CREATE INDEX ix_ord_corticiales_mating_systems_publication_id ON ord_corticiales_mating_systems (publication_id); CREATE TABLE ord_corticiales_nutrient_uptake_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, nitrogen_source TEXT, carbon_source TEXT, growth_response TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_corticiales_nutrient_uptake_studies_species_id ON ord_corticiales_nutrient_uptake_studies (species_id); CREATE INDEX ix_ord_corticiales_nutrient_uptake_studies_strain_id ON ord_corticiales_nutrient_uptake_studies (strain_id); CREATE TABLE ord_corticiales_range_maps ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, polygon_file_uri TEXT NOT NULL, source_methodology TEXT, area_km2 REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_corticiales_range_maps_species_id ON ord_corticiales_range_maps (species_id); CREATE INDEX ix_ord_corticiales_range_maps_publication_id ON ord_corticiales_range_maps (publication_id); CREATE TABLE ord_corticiales_abundance_estimates ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, estimate_kind TEXT, value_min REAL, value_max REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_corticiales_abundance_estimates_species_id ON ord_corticiales_abundance_estimates (species_id); CREATE INDEX ix_ord_corticiales_abundance_estimates_country_id ON ord_corticiales_abundance_estimates (country_id); CREATE TABLE ord_corticiales_toxin_profiles ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, presence TEXT, typical_concentration_mg_per_kg REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_corticiales_toxin_profiles_species_id ON ord_corticiales_toxin_profiles (species_id); CREATE INDEX ix_ord_corticiales_toxin_profiles_compound_id ON ord_corticiales_toxin_profiles (compound_id); CREATE TABLE ord_corticiales_enzyme_activity_assays ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, enzyme_id INTEGER NOT NULL, strain_id INTEGER, activity_u_per_mg REAL, temperature_c REAL, ph REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (enzyme_id) REFERENCES bio_enzymes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_corticiales_enzyme_activity_assays_species_id ON ord_corticiales_enzyme_activity_assays (species_id); CREATE INDEX ix_ord_corticiales_enzyme_activity_assays_enzyme_id ON ord_corticiales_enzyme_activity_assays (enzyme_id); CREATE TABLE ord_corticiales_biocontrol_evaluations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, target_pest_text TEXT NOT NULL, efficacy_pct REAL, trial_setting TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_corticiales_biocontrol_evaluations_species_id ON ord_corticiales_biocontrol_evaluations (species_id); CREATE INDEX ix_ord_corticiales_biocontrol_evaluations_publication_id ON ord_corticiales_biocontrol_evaluations (publication_id); CREATE TABLE ord_corticiales_regional_checklists ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, checklist_publication_id INTEGER, status TEXT, checklist_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (checklist_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_corticiales_regional_checklists_species_id ON ord_corticiales_regional_checklists (species_id); CREATE INDEX ix_ord_corticiales_regional_checklists_country_id ON ord_corticiales_regional_checklists (country_id); CREATE TABLE ord_gomphales_morphology ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, hymenium_color_at_maturity TEXT, context_color_at_maturity TEXT, characteristic_microstructure TEXT, diagnostic_features_text TEXT, notes_kohler_reaction TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_gomphales_morphology_specimen_id ON ord_gomphales_morphology (specimen_id); CREATE INDEX ix_ord_gomphales_morphology_species_id ON ord_gomphales_morphology (species_id); CREATE TABLE ord_gomphales_ecology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, dominant_habitat_id INTEGER, dominant_substrate_id INTEGER, dominant_biome_id INTEGER, trophic_strategy TEXT, typical_fruiting_period TEXT, known_distribution_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_habitat_id) REFERENCES eco_habitat_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_substrate_id) REFERENCES eco_substrate_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_biome_id) REFERENCES geo_biomes (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_gomphales_ecology_species_id ON ord_gomphales_ecology (species_id); CREATE INDEX ix_ord_gomphales_ecology_dominant_habitat_id ON ord_gomphales_ecology (dominant_habitat_id); CREATE TABLE ord_gomphales_phenology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, season_name TEXT, region_country_id INTEGER, first_doy INTEGER, peak_doy INTEGER, last_doy INTEGER, years_observed INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_gomphales_phenology_species_id ON ord_gomphales_phenology (species_id); CREATE INDEX ix_ord_gomphales_phenology_region_country_id ON ord_gomphales_phenology (region_country_id); CREATE TABLE ord_gomphales_host_associations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, association_type TEXT, specificity TEXT, evidence_publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (evidence_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_gomphales_host_associations_species_id ON ord_gomphales_host_associations (species_id); CREATE INDEX ix_ord_gomphales_host_associations_host_id ON ord_gomphales_host_associations (host_id); CREATE TABLE ord_gomphales_substrate_preferences ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, substrate_id INTEGER NOT NULL, preference_score REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (substrate_id) REFERENCES eco_substrate_types (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_gomphales_substrate_preferences_species_id ON ord_gomphales_substrate_preferences (species_id); CREATE INDEX ix_ord_gomphales_substrate_preferences_substrate_id ON ord_gomphales_substrate_preferences (substrate_id); CREATE TABLE ord_gomphales_geographic_distribution ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, occurrence_status TEXT, first_record_year INTEGER, record_count INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_gomphales_geographic_distribution_species_id ON ord_gomphales_geographic_distribution (species_id); CREATE INDEX ix_ord_gomphales_geographic_distribution_country_id ON ord_gomphales_geographic_distribution (country_id); CREATE TABLE ord_gomphales_phylogeny ( id INTEGER PRIMARY KEY AUTOINCREMENT, tree_id INTEGER NOT NULL, focal_genus_id INTEGER, publication_id INTEGER, notes_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (tree_id) REFERENCES phy_trees (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_gomphales_phylogeny_tree_id ON ord_gomphales_phylogeny (tree_id); CREATE INDEX ix_ord_gomphales_phylogeny_focal_genus_id ON ord_gomphales_phylogeny (focal_genus_id); CREATE TABLE ord_gomphales_genomics ( id INTEGER PRIMARY KEY AUTOINCREMENT, assembly_id INTEGER NOT NULL, species_id INTEGER, avg_genome_size_mb REAL, avg_gene_count INTEGER, avg_busco_complete_pct REAL, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (assembly_id) REFERENCES gen_assemblies (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_gomphales_genomics_assembly_id ON ord_gomphales_genomics (assembly_id); CREATE INDEX ix_ord_gomphales_genomics_species_id ON ord_gomphales_genomics (species_id); CREATE TABLE ord_gomphales_biochemistry ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, typicality TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_gomphales_biochemistry_species_id ON ord_gomphales_biochemistry (species_id); CREATE INDEX ix_ord_gomphales_biochemistry_compound_id ON ord_gomphales_biochemistry (compound_id); CREATE TABLE ord_gomphales_cultivation_notes ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, typical_growth_rate_mm_per_day REAL, preferred_media_type_id INTEGER, optimal_temperature_c REAL, difficulty_score INTEGER CHECK (difficulty_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (preferred_media_type_id) REFERENCES cul_media_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_gomphales_cultivation_notes_species_id ON ord_gomphales_cultivation_notes (species_id); CREATE INDEX ix_ord_gomphales_cultivation_notes_strain_id ON ord_gomphales_cultivation_notes (strain_id); CREATE TABLE ord_gomphales_pathogenicity ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, disease_id INTEGER, severity_score INTEGER CHECK (severity_score BETWEEN 1 AND 5), publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (disease_id) REFERENCES pat_diseases (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_gomphales_pathogenicity_species_id ON ord_gomphales_pathogenicity (species_id); CREATE INDEX ix_ord_gomphales_pathogenicity_host_id ON ord_gomphales_pathogenicity (host_id); CREATE TABLE ord_gomphales_edibility ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, edibility_class TEXT, preparation_notes TEXT, regional_tradition_country_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (regional_tradition_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_gomphales_edibility_species_id ON ord_gomphales_edibility (species_id); CREATE INDEX ix_ord_gomphales_edibility_regional_tradition_country_id ON ord_gomphales_edibility (regional_tradition_country_id); CREATE TABLE ord_gomphales_medicinal_uses ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, traditional_use_text TEXT, modern_evidence_level TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_gomphales_medicinal_uses_species_id ON ord_gomphales_medicinal_uses (species_id); CREATE INDEX ix_ord_gomphales_medicinal_uses_publication_id ON ord_gomphales_medicinal_uses (publication_id); CREATE TABLE ord_gomphales_taxonomic_revisions ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER NOT NULL, affected_family_id INTEGER, affected_genus_id INTEGER, revision_summary TEXT, revision_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_family_id) REFERENCES tax_families (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_gomphales_taxonomic_revisions_publication_id ON ord_gomphales_taxonomic_revisions (publication_id); CREATE INDEX ix_ord_gomphales_taxonomic_revisions_affected_family_id ON ord_gomphales_taxonomic_revisions (affected_family_id); CREATE TABLE ord_gomphales_conservation_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, national_redlist_category TEXT, habitat_pressure_text TEXT, last_assessment_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_gomphales_conservation_status_species_id ON ord_gomphales_conservation_status (species_id); CREATE INDEX ix_ord_gomphales_conservation_status_country_id ON ord_gomphales_conservation_status (country_id); CREATE TABLE ord_gomphales_diagnostic_keys ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER, key_title TEXT NOT NULL, region_country_id INTEGER, n_taxa_covered INTEGER, key_format TEXT, includes_microscopy INTEGER NOT NULL DEFAULT 0, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_gomphales_diagnostic_keys_publication_id ON ord_gomphales_diagnostic_keys (publication_id); CREATE INDEX ix_ord_gomphales_diagnostic_keys_region_country_id ON ord_gomphales_diagnostic_keys (region_country_id); CREATE TABLE ord_gomphales_type_species_register ( id INTEGER PRIMARY KEY AUTOINCREMENT, focal_genus_id INTEGER NOT NULL, type_species_id INTEGER, designation_publication_id INTEGER, designation_year INTEGER, designated_by_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (designation_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_gomphales_type_species_register_focal_genus_id ON ord_gomphales_type_species_register (focal_genus_id); CREATE INDEX ix_ord_gomphales_type_species_register_type_species_id ON ord_gomphales_type_species_register (type_species_id); CREATE TABLE ord_gomphales_distribution_grids ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, grid_cell_code TEXT NOT NULL, centroid_lat REAL, centroid_lon REAL, record_count INTEGER, first_record_year INTEGER, most_recent_record_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_gomphales_distribution_grids_species_id ON ord_gomphales_distribution_grids (species_id); CREATE INDEX ix_ord_gomphales_distribution_grids_country_id ON ord_gomphales_distribution_grids (country_id); CREATE TABLE ord_gomphales_microclimate_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER, publication_id INTEGER, substrate_temperature_c REAL, substrate_moisture_pct REAL, canopy_closure_pct REAL, photosynthetic_par_umol_m2_s REAL, days_post_rainfall INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_gomphales_microclimate_studies_species_id ON ord_gomphales_microclimate_studies (species_id); CREATE INDEX ix_ord_gomphales_microclimate_studies_publication_id ON ord_gomphales_microclimate_studies (publication_id); CREATE TABLE ord_gomphales_dna_barcoding_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, its_sequenced INTEGER NOT NULL DEFAULT 0, lsu_sequenced INTEGER NOT NULL DEFAULT 0, rpb2_sequenced INTEGER NOT NULL DEFAULT 0, ef1a_sequenced INTEGER NOT NULL DEFAULT 0, genome_assembled INTEGER NOT NULL DEFAULT 0, priority_for_sequencing_score INTEGER CHECK (priority_for_sequencing_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_gomphales_dna_barcoding_status_species_id ON ord_gomphales_dna_barcoding_status (species_id); CREATE TABLE ord_gomphales_spore_print_data ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, specimen_id INTEGER, print_color_label TEXT, print_color_chip_id INTEGER, spore_density_per_mm2 REAL, collection_substrate TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (print_color_chip_id) REFERENCES mor_color_chips (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_gomphales_spore_print_data_species_id ON ord_gomphales_spore_print_data (species_id); CREATE INDEX ix_ord_gomphales_spore_print_data_specimen_id ON ord_gomphales_spore_print_data (specimen_id); CREATE TABLE ord_gomphales_mating_systems ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, system_type TEXT, mating_loci_count INTEGER, publication_id INTEGER, notes_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_gomphales_mating_systems_species_id ON ord_gomphales_mating_systems (species_id); CREATE INDEX ix_ord_gomphales_mating_systems_publication_id ON ord_gomphales_mating_systems (publication_id); CREATE TABLE ord_gomphales_nutrient_uptake_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, nitrogen_source TEXT, carbon_source TEXT, growth_response TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_gomphales_nutrient_uptake_studies_species_id ON ord_gomphales_nutrient_uptake_studies (species_id); CREATE INDEX ix_ord_gomphales_nutrient_uptake_studies_strain_id ON ord_gomphales_nutrient_uptake_studies (strain_id); CREATE TABLE ord_gomphales_range_maps ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, polygon_file_uri TEXT NOT NULL, source_methodology TEXT, area_km2 REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_gomphales_range_maps_species_id ON ord_gomphales_range_maps (species_id); CREATE INDEX ix_ord_gomphales_range_maps_publication_id ON ord_gomphales_range_maps (publication_id); CREATE TABLE ord_gomphales_abundance_estimates ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, estimate_kind TEXT, value_min REAL, value_max REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_gomphales_abundance_estimates_species_id ON ord_gomphales_abundance_estimates (species_id); CREATE INDEX ix_ord_gomphales_abundance_estimates_country_id ON ord_gomphales_abundance_estimates (country_id); CREATE TABLE ord_gomphales_toxin_profiles ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, presence TEXT, typical_concentration_mg_per_kg REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_gomphales_toxin_profiles_species_id ON ord_gomphales_toxin_profiles (species_id); CREATE INDEX ix_ord_gomphales_toxin_profiles_compound_id ON ord_gomphales_toxin_profiles (compound_id); CREATE TABLE ord_gomphales_enzyme_activity_assays ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, enzyme_id INTEGER NOT NULL, strain_id INTEGER, activity_u_per_mg REAL, temperature_c REAL, ph REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (enzyme_id) REFERENCES bio_enzymes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_gomphales_enzyme_activity_assays_species_id ON ord_gomphales_enzyme_activity_assays (species_id); CREATE INDEX ix_ord_gomphales_enzyme_activity_assays_enzyme_id ON ord_gomphales_enzyme_activity_assays (enzyme_id); CREATE TABLE ord_gomphales_biocontrol_evaluations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, target_pest_text TEXT NOT NULL, efficacy_pct REAL, trial_setting TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_gomphales_biocontrol_evaluations_species_id ON ord_gomphales_biocontrol_evaluations (species_id); CREATE INDEX ix_ord_gomphales_biocontrol_evaluations_publication_id ON ord_gomphales_biocontrol_evaluations (publication_id); CREATE TABLE ord_gomphales_regional_checklists ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, checklist_publication_id INTEGER, status TEXT, checklist_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (checklist_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_gomphales_regional_checklists_species_id ON ord_gomphales_regional_checklists (species_id); CREATE INDEX ix_ord_gomphales_regional_checklists_country_id ON ord_gomphales_regional_checklists (country_id); CREATE TABLE ord_stereopsidales_morphology ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, hymenium_color_at_maturity TEXT, context_color_at_maturity TEXT, characteristic_microstructure TEXT, diagnostic_features_text TEXT, notes_kohler_reaction TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_stereopsidales_morphology_specimen_id ON ord_stereopsidales_morphology (specimen_id); CREATE INDEX ix_ord_stereopsidales_morphology_species_id ON ord_stereopsidales_morphology (species_id); CREATE TABLE ord_stereopsidales_ecology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, dominant_habitat_id INTEGER, dominant_substrate_id INTEGER, dominant_biome_id INTEGER, trophic_strategy TEXT, typical_fruiting_period TEXT, known_distribution_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_habitat_id) REFERENCES eco_habitat_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_substrate_id) REFERENCES eco_substrate_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_biome_id) REFERENCES geo_biomes (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_stereopsidales_ecology_species_id ON ord_stereopsidales_ecology (species_id); CREATE INDEX ix_ord_stereopsidales_ecology_dominant_habitat_id ON ord_stereopsidales_ecology (dominant_habitat_id); CREATE TABLE ord_stereopsidales_phenology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, season_name TEXT, region_country_id INTEGER, first_doy INTEGER, peak_doy INTEGER, last_doy INTEGER, years_observed INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_stereopsidales_phenology_species_id ON ord_stereopsidales_phenology (species_id); CREATE INDEX ix_ord_stereopsidales_phenology_region_country_id ON ord_stereopsidales_phenology (region_country_id); CREATE TABLE ord_stereopsidales_host_associations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, association_type TEXT, specificity TEXT, evidence_publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (evidence_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_stereopsidales_host_associations_species_id ON ord_stereopsidales_host_associations (species_id); CREATE INDEX ix_ord_stereopsidales_host_associations_host_id ON ord_stereopsidales_host_associations (host_id); CREATE TABLE ord_stereopsidales_substrate_preferences ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, substrate_id INTEGER NOT NULL, preference_score REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (substrate_id) REFERENCES eco_substrate_types (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_stereopsidales_substrate_preferences_species_id ON ord_stereopsidales_substrate_preferences (species_id); CREATE INDEX ix_ord_stereopsidales_substrate_preferences_substrate_id ON ord_stereopsidales_substrate_preferences (substrate_id); CREATE TABLE ord_stereopsidales_geographic_distribution ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, occurrence_status TEXT, first_record_year INTEGER, record_count INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_stereopsidales_geographic_distribution_species_id ON ord_stereopsidales_geographic_distribution (species_id); CREATE INDEX ix_ord_stereopsidales_geographic_distribution_country_id ON ord_stereopsidales_geographic_distribution (country_id); CREATE TABLE ord_stereopsidales_phylogeny ( id INTEGER PRIMARY KEY AUTOINCREMENT, tree_id INTEGER NOT NULL, focal_genus_id INTEGER, publication_id INTEGER, notes_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (tree_id) REFERENCES phy_trees (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_stereopsidales_phylogeny_tree_id ON ord_stereopsidales_phylogeny (tree_id); CREATE INDEX ix_ord_stereopsidales_phylogeny_focal_genus_id ON ord_stereopsidales_phylogeny (focal_genus_id); CREATE TABLE ord_stereopsidales_genomics ( id INTEGER PRIMARY KEY AUTOINCREMENT, assembly_id INTEGER NOT NULL, species_id INTEGER, avg_genome_size_mb REAL, avg_gene_count INTEGER, avg_busco_complete_pct REAL, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (assembly_id) REFERENCES gen_assemblies (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_stereopsidales_genomics_assembly_id ON ord_stereopsidales_genomics (assembly_id); CREATE INDEX ix_ord_stereopsidales_genomics_species_id ON ord_stereopsidales_genomics (species_id); CREATE TABLE ord_stereopsidales_biochemistry ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, typicality TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_stereopsidales_biochemistry_species_id ON ord_stereopsidales_biochemistry (species_id); CREATE INDEX ix_ord_stereopsidales_biochemistry_compound_id ON ord_stereopsidales_biochemistry (compound_id); CREATE TABLE ord_stereopsidales_cultivation_notes ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, typical_growth_rate_mm_per_day REAL, preferred_media_type_id INTEGER, optimal_temperature_c REAL, difficulty_score INTEGER CHECK (difficulty_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (preferred_media_type_id) REFERENCES cul_media_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_stereopsidales_cultivation_notes_species_id ON ord_stereopsidales_cultivation_notes (species_id); CREATE INDEX ix_ord_stereopsidales_cultivation_notes_strain_id ON ord_stereopsidales_cultivation_notes (strain_id); CREATE TABLE ord_stereopsidales_pathogenicity ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, disease_id INTEGER, severity_score INTEGER CHECK (severity_score BETWEEN 1 AND 5), publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (disease_id) REFERENCES pat_diseases (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_stereopsidales_pathogenicity_species_id ON ord_stereopsidales_pathogenicity (species_id); CREATE INDEX ix_ord_stereopsidales_pathogenicity_host_id ON ord_stereopsidales_pathogenicity (host_id); CREATE TABLE ord_stereopsidales_edibility ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, edibility_class TEXT, preparation_notes TEXT, regional_tradition_country_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (regional_tradition_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_stereopsidales_edibility_species_id ON ord_stereopsidales_edibility (species_id); CREATE INDEX ix_ord_stereopsidales_edibility_1 ON ord_stereopsidales_edibility (regional_tradition_country_id); CREATE TABLE ord_stereopsidales_medicinal_uses ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, traditional_use_text TEXT, modern_evidence_level TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_stereopsidales_medicinal_uses_species_id ON ord_stereopsidales_medicinal_uses (species_id); CREATE INDEX ix_ord_stereopsidales_medicinal_uses_publication_id ON ord_stereopsidales_medicinal_uses (publication_id); CREATE TABLE ord_stereopsidales_taxonomic_revisions ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER NOT NULL, affected_family_id INTEGER, affected_genus_id INTEGER, revision_summary TEXT, revision_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_family_id) REFERENCES tax_families (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_stereopsidales_taxonomic_revisions_publication_id ON ord_stereopsidales_taxonomic_revisions (publication_id); CREATE INDEX ix_ord_stereopsidales_taxonomic_revisions_affected_family_id ON ord_stereopsidales_taxonomic_revisions (affected_family_id); CREATE TABLE ord_stereopsidales_conservation_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, national_redlist_category TEXT, habitat_pressure_text TEXT, last_assessment_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_stereopsidales_conservation_status_species_id ON ord_stereopsidales_conservation_status (species_id); CREATE INDEX ix_ord_stereopsidales_conservation_status_country_id ON ord_stereopsidales_conservation_status (country_id); CREATE TABLE ord_stereopsidales_diagnostic_keys ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER, key_title TEXT NOT NULL, region_country_id INTEGER, n_taxa_covered INTEGER, key_format TEXT, includes_microscopy INTEGER NOT NULL DEFAULT 0, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_stereopsidales_diagnostic_keys_publication_id ON ord_stereopsidales_diagnostic_keys (publication_id); CREATE INDEX ix_ord_stereopsidales_diagnostic_keys_region_country_id ON ord_stereopsidales_diagnostic_keys (region_country_id); CREATE TABLE ord_stereopsidales_type_species_register ( id INTEGER PRIMARY KEY AUTOINCREMENT, focal_genus_id INTEGER NOT NULL, type_species_id INTEGER, designation_publication_id INTEGER, designation_year INTEGER, designated_by_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (designation_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_stereopsidales_type_species_register_focal_genus_id ON ord_stereopsidales_type_species_register (focal_genus_id); CREATE INDEX ix_ord_stereopsidales_type_species_register_type_species_id ON ord_stereopsidales_type_species_register (type_species_id); CREATE TABLE ord_stereopsidales_distribution_grids ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, grid_cell_code TEXT NOT NULL, centroid_lat REAL, centroid_lon REAL, record_count INTEGER, first_record_year INTEGER, most_recent_record_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_stereopsidales_distribution_grids_species_id ON ord_stereopsidales_distribution_grids (species_id); CREATE INDEX ix_ord_stereopsidales_distribution_grids_country_id ON ord_stereopsidales_distribution_grids (country_id); CREATE TABLE ord_stereopsidales_microclimate_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER, publication_id INTEGER, substrate_temperature_c REAL, substrate_moisture_pct REAL, canopy_closure_pct REAL, photosynthetic_par_umol_m2_s REAL, days_post_rainfall INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_stereopsidales_microclimate_studies_species_id ON ord_stereopsidales_microclimate_studies (species_id); CREATE INDEX ix_ord_stereopsidales_microclimate_studies_publication_id ON ord_stereopsidales_microclimate_studies (publication_id); CREATE TABLE ord_stereopsidales_dna_barcoding_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, its_sequenced INTEGER NOT NULL DEFAULT 0, lsu_sequenced INTEGER NOT NULL DEFAULT 0, rpb2_sequenced INTEGER NOT NULL DEFAULT 0, ef1a_sequenced INTEGER NOT NULL DEFAULT 0, genome_assembled INTEGER NOT NULL DEFAULT 0, priority_for_sequencing_score INTEGER CHECK (priority_for_sequencing_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_stereopsidales_dna_barcoding_status_species_id ON ord_stereopsidales_dna_barcoding_status (species_id); CREATE TABLE ord_stereopsidales_spore_print_data ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, specimen_id INTEGER, print_color_label TEXT, print_color_chip_id INTEGER, spore_density_per_mm2 REAL, collection_substrate TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (print_color_chip_id) REFERENCES mor_color_chips (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_stereopsidales_spore_print_data_species_id ON ord_stereopsidales_spore_print_data (species_id); CREATE INDEX ix_ord_stereopsidales_spore_print_data_specimen_id ON ord_stereopsidales_spore_print_data (specimen_id); CREATE TABLE ord_stereopsidales_mating_systems ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, system_type TEXT, mating_loci_count INTEGER, publication_id INTEGER, notes_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_stereopsidales_mating_systems_species_id ON ord_stereopsidales_mating_systems (species_id); CREATE INDEX ix_ord_stereopsidales_mating_systems_publication_id ON ord_stereopsidales_mating_systems (publication_id); CREATE TABLE ord_stereopsidales_nutrient_uptake_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, nitrogen_source TEXT, carbon_source TEXT, growth_response TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_stereopsidales_nutrient_uptake_studies_species_id ON ord_stereopsidales_nutrient_uptake_studies (species_id); CREATE INDEX ix_ord_stereopsidales_nutrient_uptake_studies_strain_id ON ord_stereopsidales_nutrient_uptake_studies (strain_id); CREATE TABLE ord_stereopsidales_range_maps ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, polygon_file_uri TEXT NOT NULL, source_methodology TEXT, area_km2 REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_stereopsidales_range_maps_species_id ON ord_stereopsidales_range_maps (species_id); CREATE INDEX ix_ord_stereopsidales_range_maps_publication_id ON ord_stereopsidales_range_maps (publication_id); CREATE TABLE ord_stereopsidales_abundance_estimates ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, estimate_kind TEXT, value_min REAL, value_max REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_stereopsidales_abundance_estimates_species_id ON ord_stereopsidales_abundance_estimates (species_id); CREATE INDEX ix_ord_stereopsidales_abundance_estimates_country_id ON ord_stereopsidales_abundance_estimates (country_id); CREATE TABLE ord_stereopsidales_toxin_profiles ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, presence TEXT, typical_concentration_mg_per_kg REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_stereopsidales_toxin_profiles_species_id ON ord_stereopsidales_toxin_profiles (species_id); CREATE INDEX ix_ord_stereopsidales_toxin_profiles_compound_id ON ord_stereopsidales_toxin_profiles (compound_id); CREATE TABLE ord_stereopsidales_enzyme_activity_assays ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, enzyme_id INTEGER NOT NULL, strain_id INTEGER, activity_u_per_mg REAL, temperature_c REAL, ph REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (enzyme_id) REFERENCES bio_enzymes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_stereopsidales_enzyme_activity_assays_species_id ON ord_stereopsidales_enzyme_activity_assays (species_id); CREATE INDEX ix_ord_stereopsidales_enzyme_activity_assays_enzyme_id ON ord_stereopsidales_enzyme_activity_assays (enzyme_id); CREATE TABLE ord_stereopsidales_biocontrol_evaluations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, target_pest_text TEXT NOT NULL, efficacy_pct REAL, trial_setting TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_stereopsidales_biocontrol_evaluations_species_id ON ord_stereopsidales_biocontrol_evaluations (species_id); CREATE INDEX ix_ord_stereopsidales_biocontrol_evaluations_publication_id ON ord_stereopsidales_biocontrol_evaluations (publication_id); CREATE TABLE ord_stereopsidales_regional_checklists ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, checklist_publication_id INTEGER, status TEXT, checklist_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (checklist_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_stereopsidales_regional_checklists_species_id ON ord_stereopsidales_regional_checklists (species_id); CREATE INDEX ix_ord_stereopsidales_regional_checklists_country_id ON ord_stereopsidales_regional_checklists (country_id); CREATE TABLE ord_pucciniales_morphology ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, hymenium_color_at_maturity TEXT, context_color_at_maturity TEXT, characteristic_microstructure TEXT, diagnostic_features_text TEXT, notes_kohler_reaction TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pucciniales_morphology_specimen_id ON ord_pucciniales_morphology (specimen_id); CREATE INDEX ix_ord_pucciniales_morphology_species_id ON ord_pucciniales_morphology (species_id); CREATE TABLE ord_pucciniales_ecology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, dominant_habitat_id INTEGER, dominant_substrate_id INTEGER, dominant_biome_id INTEGER, trophic_strategy TEXT, typical_fruiting_period TEXT, known_distribution_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_habitat_id) REFERENCES eco_habitat_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_substrate_id) REFERENCES eco_substrate_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_biome_id) REFERENCES geo_biomes (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pucciniales_ecology_species_id ON ord_pucciniales_ecology (species_id); CREATE INDEX ix_ord_pucciniales_ecology_dominant_habitat_id ON ord_pucciniales_ecology (dominant_habitat_id); CREATE TABLE ord_pucciniales_phenology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, season_name TEXT, region_country_id INTEGER, first_doy INTEGER, peak_doy INTEGER, last_doy INTEGER, years_observed INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pucciniales_phenology_species_id ON ord_pucciniales_phenology (species_id); CREATE INDEX ix_ord_pucciniales_phenology_region_country_id ON ord_pucciniales_phenology (region_country_id); CREATE TABLE ord_pucciniales_host_associations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, association_type TEXT, specificity TEXT, evidence_publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (evidence_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pucciniales_host_associations_species_id ON ord_pucciniales_host_associations (species_id); CREATE INDEX ix_ord_pucciniales_host_associations_host_id ON ord_pucciniales_host_associations (host_id); CREATE TABLE ord_pucciniales_substrate_preferences ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, substrate_id INTEGER NOT NULL, preference_score REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (substrate_id) REFERENCES eco_substrate_types (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pucciniales_substrate_preferences_species_id ON ord_pucciniales_substrate_preferences (species_id); CREATE INDEX ix_ord_pucciniales_substrate_preferences_substrate_id ON ord_pucciniales_substrate_preferences (substrate_id); CREATE TABLE ord_pucciniales_geographic_distribution ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, occurrence_status TEXT, first_record_year INTEGER, record_count INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pucciniales_geographic_distribution_species_id ON ord_pucciniales_geographic_distribution (species_id); CREATE INDEX ix_ord_pucciniales_geographic_distribution_country_id ON ord_pucciniales_geographic_distribution (country_id); CREATE TABLE ord_pucciniales_phylogeny ( id INTEGER PRIMARY KEY AUTOINCREMENT, tree_id INTEGER NOT NULL, focal_genus_id INTEGER, publication_id INTEGER, notes_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (tree_id) REFERENCES phy_trees (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pucciniales_phylogeny_tree_id ON ord_pucciniales_phylogeny (tree_id); CREATE INDEX ix_ord_pucciniales_phylogeny_focal_genus_id ON ord_pucciniales_phylogeny (focal_genus_id); CREATE TABLE ord_pucciniales_genomics ( id INTEGER PRIMARY KEY AUTOINCREMENT, assembly_id INTEGER NOT NULL, species_id INTEGER, avg_genome_size_mb REAL, avg_gene_count INTEGER, avg_busco_complete_pct REAL, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (assembly_id) REFERENCES gen_assemblies (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pucciniales_genomics_assembly_id ON ord_pucciniales_genomics (assembly_id); CREATE INDEX ix_ord_pucciniales_genomics_species_id ON ord_pucciniales_genomics (species_id); CREATE TABLE ord_pucciniales_biochemistry ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, typicality TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pucciniales_biochemistry_species_id ON ord_pucciniales_biochemistry (species_id); CREATE INDEX ix_ord_pucciniales_biochemistry_compound_id ON ord_pucciniales_biochemistry (compound_id); CREATE TABLE ord_pucciniales_cultivation_notes ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, typical_growth_rate_mm_per_day REAL, preferred_media_type_id INTEGER, optimal_temperature_c REAL, difficulty_score INTEGER CHECK (difficulty_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (preferred_media_type_id) REFERENCES cul_media_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pucciniales_cultivation_notes_species_id ON ord_pucciniales_cultivation_notes (species_id); CREATE INDEX ix_ord_pucciniales_cultivation_notes_strain_id ON ord_pucciniales_cultivation_notes (strain_id); CREATE TABLE ord_pucciniales_pathogenicity ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, disease_id INTEGER, severity_score INTEGER CHECK (severity_score BETWEEN 1 AND 5), publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (disease_id) REFERENCES pat_diseases (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pucciniales_pathogenicity_species_id ON ord_pucciniales_pathogenicity (species_id); CREATE INDEX ix_ord_pucciniales_pathogenicity_host_id ON ord_pucciniales_pathogenicity (host_id); CREATE TABLE ord_pucciniales_edibility ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, edibility_class TEXT, preparation_notes TEXT, regional_tradition_country_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (regional_tradition_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pucciniales_edibility_species_id ON ord_pucciniales_edibility (species_id); CREATE INDEX ix_ord_pucciniales_edibility_regional_tradition_country_id ON ord_pucciniales_edibility (regional_tradition_country_id); CREATE TABLE ord_pucciniales_medicinal_uses ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, traditional_use_text TEXT, modern_evidence_level TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pucciniales_medicinal_uses_species_id ON ord_pucciniales_medicinal_uses (species_id); CREATE INDEX ix_ord_pucciniales_medicinal_uses_publication_id ON ord_pucciniales_medicinal_uses (publication_id); CREATE TABLE ord_pucciniales_taxonomic_revisions ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER NOT NULL, affected_family_id INTEGER, affected_genus_id INTEGER, revision_summary TEXT, revision_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_family_id) REFERENCES tax_families (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pucciniales_taxonomic_revisions_publication_id ON ord_pucciniales_taxonomic_revisions (publication_id); CREATE INDEX ix_ord_pucciniales_taxonomic_revisions_affected_family_id ON ord_pucciniales_taxonomic_revisions (affected_family_id); CREATE TABLE ord_pucciniales_conservation_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, national_redlist_category TEXT, habitat_pressure_text TEXT, last_assessment_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pucciniales_conservation_status_species_id ON ord_pucciniales_conservation_status (species_id); CREATE INDEX ix_ord_pucciniales_conservation_status_country_id ON ord_pucciniales_conservation_status (country_id); CREATE TABLE ord_pucciniales_diagnostic_keys ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER, key_title TEXT NOT NULL, region_country_id INTEGER, n_taxa_covered INTEGER, key_format TEXT, includes_microscopy INTEGER NOT NULL DEFAULT 0, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pucciniales_diagnostic_keys_publication_id ON ord_pucciniales_diagnostic_keys (publication_id); CREATE INDEX ix_ord_pucciniales_diagnostic_keys_region_country_id ON ord_pucciniales_diagnostic_keys (region_country_id); CREATE TABLE ord_pucciniales_type_species_register ( id INTEGER PRIMARY KEY AUTOINCREMENT, focal_genus_id INTEGER NOT NULL, type_species_id INTEGER, designation_publication_id INTEGER, designation_year INTEGER, designated_by_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (designation_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pucciniales_type_species_register_focal_genus_id ON ord_pucciniales_type_species_register (focal_genus_id); CREATE INDEX ix_ord_pucciniales_type_species_register_type_species_id ON ord_pucciniales_type_species_register (type_species_id); CREATE TABLE ord_pucciniales_distribution_grids ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, grid_cell_code TEXT NOT NULL, centroid_lat REAL, centroid_lon REAL, record_count INTEGER, first_record_year INTEGER, most_recent_record_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pucciniales_distribution_grids_species_id ON ord_pucciniales_distribution_grids (species_id); CREATE INDEX ix_ord_pucciniales_distribution_grids_country_id ON ord_pucciniales_distribution_grids (country_id); CREATE TABLE ord_pucciniales_microclimate_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER, publication_id INTEGER, substrate_temperature_c REAL, substrate_moisture_pct REAL, canopy_closure_pct REAL, photosynthetic_par_umol_m2_s REAL, days_post_rainfall INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pucciniales_microclimate_studies_species_id ON ord_pucciniales_microclimate_studies (species_id); CREATE INDEX ix_ord_pucciniales_microclimate_studies_publication_id ON ord_pucciniales_microclimate_studies (publication_id); CREATE TABLE ord_pucciniales_dna_barcoding_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, its_sequenced INTEGER NOT NULL DEFAULT 0, lsu_sequenced INTEGER NOT NULL DEFAULT 0, rpb2_sequenced INTEGER NOT NULL DEFAULT 0, ef1a_sequenced INTEGER NOT NULL DEFAULT 0, genome_assembled INTEGER NOT NULL DEFAULT 0, priority_for_sequencing_score INTEGER CHECK (priority_for_sequencing_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pucciniales_dna_barcoding_status_species_id ON ord_pucciniales_dna_barcoding_status (species_id); CREATE TABLE ord_pucciniales_spore_print_data ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, specimen_id INTEGER, print_color_label TEXT, print_color_chip_id INTEGER, spore_density_per_mm2 REAL, collection_substrate TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (print_color_chip_id) REFERENCES mor_color_chips (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pucciniales_spore_print_data_species_id ON ord_pucciniales_spore_print_data (species_id); CREATE INDEX ix_ord_pucciniales_spore_print_data_specimen_id ON ord_pucciniales_spore_print_data (specimen_id); CREATE TABLE ord_pucciniales_mating_systems ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, system_type TEXT, mating_loci_count INTEGER, publication_id INTEGER, notes_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pucciniales_mating_systems_species_id ON ord_pucciniales_mating_systems (species_id); CREATE INDEX ix_ord_pucciniales_mating_systems_publication_id ON ord_pucciniales_mating_systems (publication_id); CREATE TABLE ord_pucciniales_nutrient_uptake_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, nitrogen_source TEXT, carbon_source TEXT, growth_response TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pucciniales_nutrient_uptake_studies_species_id ON ord_pucciniales_nutrient_uptake_studies (species_id); CREATE INDEX ix_ord_pucciniales_nutrient_uptake_studies_strain_id ON ord_pucciniales_nutrient_uptake_studies (strain_id); CREATE TABLE ord_pucciniales_range_maps ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, polygon_file_uri TEXT NOT NULL, source_methodology TEXT, area_km2 REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pucciniales_range_maps_species_id ON ord_pucciniales_range_maps (species_id); CREATE INDEX ix_ord_pucciniales_range_maps_publication_id ON ord_pucciniales_range_maps (publication_id); CREATE TABLE ord_pucciniales_abundance_estimates ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, estimate_kind TEXT, value_min REAL, value_max REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pucciniales_abundance_estimates_species_id ON ord_pucciniales_abundance_estimates (species_id); CREATE INDEX ix_ord_pucciniales_abundance_estimates_country_id ON ord_pucciniales_abundance_estimates (country_id); CREATE TABLE ord_pucciniales_toxin_profiles ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, presence TEXT, typical_concentration_mg_per_kg REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pucciniales_toxin_profiles_species_id ON ord_pucciniales_toxin_profiles (species_id); CREATE INDEX ix_ord_pucciniales_toxin_profiles_compound_id ON ord_pucciniales_toxin_profiles (compound_id); CREATE TABLE ord_pucciniales_enzyme_activity_assays ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, enzyme_id INTEGER NOT NULL, strain_id INTEGER, activity_u_per_mg REAL, temperature_c REAL, ph REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (enzyme_id) REFERENCES bio_enzymes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pucciniales_enzyme_activity_assays_species_id ON ord_pucciniales_enzyme_activity_assays (species_id); CREATE INDEX ix_ord_pucciniales_enzyme_activity_assays_enzyme_id ON ord_pucciniales_enzyme_activity_assays (enzyme_id); CREATE TABLE ord_pucciniales_biocontrol_evaluations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, target_pest_text TEXT NOT NULL, efficacy_pct REAL, trial_setting TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pucciniales_biocontrol_evaluations_species_id ON ord_pucciniales_biocontrol_evaluations (species_id); CREATE INDEX ix_ord_pucciniales_biocontrol_evaluations_publication_id ON ord_pucciniales_biocontrol_evaluations (publication_id); CREATE TABLE ord_pucciniales_regional_checklists ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, checklist_publication_id INTEGER, status TEXT, checklist_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (checklist_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pucciniales_regional_checklists_species_id ON ord_pucciniales_regional_checklists (species_id); CREATE INDEX ix_ord_pucciniales_regional_checklists_country_id ON ord_pucciniales_regional_checklists (country_id); CREATE TABLE ord_ustilaginales_morphology ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, hymenium_color_at_maturity TEXT, context_color_at_maturity TEXT, characteristic_microstructure TEXT, diagnostic_features_text TEXT, notes_kohler_reaction TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ustilaginales_morphology_specimen_id ON ord_ustilaginales_morphology (specimen_id); CREATE INDEX ix_ord_ustilaginales_morphology_species_id ON ord_ustilaginales_morphology (species_id); CREATE TABLE ord_ustilaginales_ecology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, dominant_habitat_id INTEGER, dominant_substrate_id INTEGER, dominant_biome_id INTEGER, trophic_strategy TEXT, typical_fruiting_period TEXT, known_distribution_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_habitat_id) REFERENCES eco_habitat_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_substrate_id) REFERENCES eco_substrate_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_biome_id) REFERENCES geo_biomes (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ustilaginales_ecology_species_id ON ord_ustilaginales_ecology (species_id); CREATE INDEX ix_ord_ustilaginales_ecology_dominant_habitat_id ON ord_ustilaginales_ecology (dominant_habitat_id); CREATE TABLE ord_ustilaginales_phenology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, season_name TEXT, region_country_id INTEGER, first_doy INTEGER, peak_doy INTEGER, last_doy INTEGER, years_observed INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ustilaginales_phenology_species_id ON ord_ustilaginales_phenology (species_id); CREATE INDEX ix_ord_ustilaginales_phenology_region_country_id ON ord_ustilaginales_phenology (region_country_id); CREATE TABLE ord_ustilaginales_host_associations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, association_type TEXT, specificity TEXT, evidence_publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (evidence_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ustilaginales_host_associations_species_id ON ord_ustilaginales_host_associations (species_id); CREATE INDEX ix_ord_ustilaginales_host_associations_host_id ON ord_ustilaginales_host_associations (host_id); CREATE TABLE ord_ustilaginales_substrate_preferences ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, substrate_id INTEGER NOT NULL, preference_score REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (substrate_id) REFERENCES eco_substrate_types (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ustilaginales_substrate_preferences_species_id ON ord_ustilaginales_substrate_preferences (species_id); CREATE INDEX ix_ord_ustilaginales_substrate_preferences_substrate_id ON ord_ustilaginales_substrate_preferences (substrate_id); CREATE TABLE ord_ustilaginales_geographic_distribution ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, occurrence_status TEXT, first_record_year INTEGER, record_count INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ustilaginales_geographic_distribution_species_id ON ord_ustilaginales_geographic_distribution (species_id); CREATE INDEX ix_ord_ustilaginales_geographic_distribution_country_id ON ord_ustilaginales_geographic_distribution (country_id); CREATE TABLE ord_ustilaginales_phylogeny ( id INTEGER PRIMARY KEY AUTOINCREMENT, tree_id INTEGER NOT NULL, focal_genus_id INTEGER, publication_id INTEGER, notes_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (tree_id) REFERENCES phy_trees (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ustilaginales_phylogeny_tree_id ON ord_ustilaginales_phylogeny (tree_id); CREATE INDEX ix_ord_ustilaginales_phylogeny_focal_genus_id ON ord_ustilaginales_phylogeny (focal_genus_id); CREATE TABLE ord_ustilaginales_genomics ( id INTEGER PRIMARY KEY AUTOINCREMENT, assembly_id INTEGER NOT NULL, species_id INTEGER, avg_genome_size_mb REAL, avg_gene_count INTEGER, avg_busco_complete_pct REAL, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (assembly_id) REFERENCES gen_assemblies (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ustilaginales_genomics_assembly_id ON ord_ustilaginales_genomics (assembly_id); CREATE INDEX ix_ord_ustilaginales_genomics_species_id ON ord_ustilaginales_genomics (species_id); CREATE TABLE ord_ustilaginales_biochemistry ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, typicality TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ustilaginales_biochemistry_species_id ON ord_ustilaginales_biochemistry (species_id); CREATE INDEX ix_ord_ustilaginales_biochemistry_compound_id ON ord_ustilaginales_biochemistry (compound_id); CREATE TABLE ord_ustilaginales_cultivation_notes ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, typical_growth_rate_mm_per_day REAL, preferred_media_type_id INTEGER, optimal_temperature_c REAL, difficulty_score INTEGER CHECK (difficulty_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (preferred_media_type_id) REFERENCES cul_media_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ustilaginales_cultivation_notes_species_id ON ord_ustilaginales_cultivation_notes (species_id); CREATE INDEX ix_ord_ustilaginales_cultivation_notes_strain_id ON ord_ustilaginales_cultivation_notes (strain_id); CREATE TABLE ord_ustilaginales_pathogenicity ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, disease_id INTEGER, severity_score INTEGER CHECK (severity_score BETWEEN 1 AND 5), publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (disease_id) REFERENCES pat_diseases (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ustilaginales_pathogenicity_species_id ON ord_ustilaginales_pathogenicity (species_id); CREATE INDEX ix_ord_ustilaginales_pathogenicity_host_id ON ord_ustilaginales_pathogenicity (host_id); CREATE TABLE ord_ustilaginales_edibility ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, edibility_class TEXT, preparation_notes TEXT, regional_tradition_country_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (regional_tradition_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ustilaginales_edibility_species_id ON ord_ustilaginales_edibility (species_id); CREATE INDEX ix_ord_ustilaginales_edibility_regional_tradition_country_id ON ord_ustilaginales_edibility (regional_tradition_country_id); CREATE TABLE ord_ustilaginales_medicinal_uses ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, traditional_use_text TEXT, modern_evidence_level TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ustilaginales_medicinal_uses_species_id ON ord_ustilaginales_medicinal_uses (species_id); CREATE INDEX ix_ord_ustilaginales_medicinal_uses_publication_id ON ord_ustilaginales_medicinal_uses (publication_id); CREATE TABLE ord_ustilaginales_taxonomic_revisions ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER NOT NULL, affected_family_id INTEGER, affected_genus_id INTEGER, revision_summary TEXT, revision_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_family_id) REFERENCES tax_families (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ustilaginales_taxonomic_revisions_publication_id ON ord_ustilaginales_taxonomic_revisions (publication_id); CREATE INDEX ix_ord_ustilaginales_taxonomic_revisions_affected_family_id ON ord_ustilaginales_taxonomic_revisions (affected_family_id); CREATE TABLE ord_ustilaginales_conservation_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, national_redlist_category TEXT, habitat_pressure_text TEXT, last_assessment_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ustilaginales_conservation_status_species_id ON ord_ustilaginales_conservation_status (species_id); CREATE INDEX ix_ord_ustilaginales_conservation_status_country_id ON ord_ustilaginales_conservation_status (country_id); CREATE TABLE ord_ustilaginales_diagnostic_keys ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER, key_title TEXT NOT NULL, region_country_id INTEGER, n_taxa_covered INTEGER, key_format TEXT, includes_microscopy INTEGER NOT NULL DEFAULT 0, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ustilaginales_diagnostic_keys_publication_id ON ord_ustilaginales_diagnostic_keys (publication_id); CREATE INDEX ix_ord_ustilaginales_diagnostic_keys_region_country_id ON ord_ustilaginales_diagnostic_keys (region_country_id); CREATE TABLE ord_ustilaginales_type_species_register ( id INTEGER PRIMARY KEY AUTOINCREMENT, focal_genus_id INTEGER NOT NULL, type_species_id INTEGER, designation_publication_id INTEGER, designation_year INTEGER, designated_by_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (designation_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ustilaginales_type_species_register_focal_genus_id ON ord_ustilaginales_type_species_register (focal_genus_id); CREATE INDEX ix_ord_ustilaginales_type_species_register_type_species_id ON ord_ustilaginales_type_species_register (type_species_id); CREATE TABLE ord_ustilaginales_distribution_grids ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, grid_cell_code TEXT NOT NULL, centroid_lat REAL, centroid_lon REAL, record_count INTEGER, first_record_year INTEGER, most_recent_record_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ustilaginales_distribution_grids_species_id ON ord_ustilaginales_distribution_grids (species_id); CREATE INDEX ix_ord_ustilaginales_distribution_grids_country_id ON ord_ustilaginales_distribution_grids (country_id); CREATE TABLE ord_ustilaginales_microclimate_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER, publication_id INTEGER, substrate_temperature_c REAL, substrate_moisture_pct REAL, canopy_closure_pct REAL, photosynthetic_par_umol_m2_s REAL, days_post_rainfall INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ustilaginales_microclimate_studies_species_id ON ord_ustilaginales_microclimate_studies (species_id); CREATE INDEX ix_ord_ustilaginales_microclimate_studies_publication_id ON ord_ustilaginales_microclimate_studies (publication_id); CREATE TABLE ord_ustilaginales_dna_barcoding_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, its_sequenced INTEGER NOT NULL DEFAULT 0, lsu_sequenced INTEGER NOT NULL DEFAULT 0, rpb2_sequenced INTEGER NOT NULL DEFAULT 0, ef1a_sequenced INTEGER NOT NULL DEFAULT 0, genome_assembled INTEGER NOT NULL DEFAULT 0, priority_for_sequencing_score INTEGER CHECK (priority_for_sequencing_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ustilaginales_dna_barcoding_status_species_id ON ord_ustilaginales_dna_barcoding_status (species_id); CREATE TABLE ord_ustilaginales_spore_print_data ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, specimen_id INTEGER, print_color_label TEXT, print_color_chip_id INTEGER, spore_density_per_mm2 REAL, collection_substrate TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (print_color_chip_id) REFERENCES mor_color_chips (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ustilaginales_spore_print_data_species_id ON ord_ustilaginales_spore_print_data (species_id); CREATE INDEX ix_ord_ustilaginales_spore_print_data_specimen_id ON ord_ustilaginales_spore_print_data (specimen_id); CREATE TABLE ord_ustilaginales_mating_systems ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, system_type TEXT, mating_loci_count INTEGER, publication_id INTEGER, notes_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ustilaginales_mating_systems_species_id ON ord_ustilaginales_mating_systems (species_id); CREATE INDEX ix_ord_ustilaginales_mating_systems_publication_id ON ord_ustilaginales_mating_systems (publication_id); CREATE TABLE ord_ustilaginales_nutrient_uptake_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, nitrogen_source TEXT, carbon_source TEXT, growth_response TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ustilaginales_nutrient_uptake_studies_species_id ON ord_ustilaginales_nutrient_uptake_studies (species_id); CREATE INDEX ix_ord_ustilaginales_nutrient_uptake_studies_strain_id ON ord_ustilaginales_nutrient_uptake_studies (strain_id); CREATE TABLE ord_ustilaginales_range_maps ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, polygon_file_uri TEXT NOT NULL, source_methodology TEXT, area_km2 REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ustilaginales_range_maps_species_id ON ord_ustilaginales_range_maps (species_id); CREATE INDEX ix_ord_ustilaginales_range_maps_publication_id ON ord_ustilaginales_range_maps (publication_id); CREATE TABLE ord_ustilaginales_abundance_estimates ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, estimate_kind TEXT, value_min REAL, value_max REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ustilaginales_abundance_estimates_species_id ON ord_ustilaginales_abundance_estimates (species_id); CREATE INDEX ix_ord_ustilaginales_abundance_estimates_country_id ON ord_ustilaginales_abundance_estimates (country_id); CREATE TABLE ord_ustilaginales_toxin_profiles ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, presence TEXT, typical_concentration_mg_per_kg REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ustilaginales_toxin_profiles_species_id ON ord_ustilaginales_toxin_profiles (species_id); CREATE INDEX ix_ord_ustilaginales_toxin_profiles_compound_id ON ord_ustilaginales_toxin_profiles (compound_id); CREATE TABLE ord_ustilaginales_enzyme_activity_assays ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, enzyme_id INTEGER NOT NULL, strain_id INTEGER, activity_u_per_mg REAL, temperature_c REAL, ph REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (enzyme_id) REFERENCES bio_enzymes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ustilaginales_enzyme_activity_assays_species_id ON ord_ustilaginales_enzyme_activity_assays (species_id); CREATE INDEX ix_ord_ustilaginales_enzyme_activity_assays_enzyme_id ON ord_ustilaginales_enzyme_activity_assays (enzyme_id); CREATE TABLE ord_ustilaginales_biocontrol_evaluations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, target_pest_text TEXT NOT NULL, efficacy_pct REAL, trial_setting TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ustilaginales_biocontrol_evaluations_species_id ON ord_ustilaginales_biocontrol_evaluations (species_id); CREATE INDEX ix_ord_ustilaginales_biocontrol_evaluations_publication_id ON ord_ustilaginales_biocontrol_evaluations (publication_id); CREATE TABLE ord_ustilaginales_regional_checklists ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, checklist_publication_id INTEGER, status TEXT, checklist_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (checklist_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ustilaginales_regional_checklists_species_id ON ord_ustilaginales_regional_checklists (species_id); CREATE INDEX ix_ord_ustilaginales_regional_checklists_country_id ON ord_ustilaginales_regional_checklists (country_id); CREATE TABLE ord_exobasidiales_morphology ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, hymenium_color_at_maturity TEXT, context_color_at_maturity TEXT, characteristic_microstructure TEXT, diagnostic_features_text TEXT, notes_kohler_reaction TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_exobasidiales_morphology_specimen_id ON ord_exobasidiales_morphology (specimen_id); CREATE INDEX ix_ord_exobasidiales_morphology_species_id ON ord_exobasidiales_morphology (species_id); CREATE TABLE ord_exobasidiales_ecology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, dominant_habitat_id INTEGER, dominant_substrate_id INTEGER, dominant_biome_id INTEGER, trophic_strategy TEXT, typical_fruiting_period TEXT, known_distribution_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_habitat_id) REFERENCES eco_habitat_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_substrate_id) REFERENCES eco_substrate_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_biome_id) REFERENCES geo_biomes (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_exobasidiales_ecology_species_id ON ord_exobasidiales_ecology (species_id); CREATE INDEX ix_ord_exobasidiales_ecology_dominant_habitat_id ON ord_exobasidiales_ecology (dominant_habitat_id); CREATE TABLE ord_exobasidiales_phenology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, season_name TEXT, region_country_id INTEGER, first_doy INTEGER, peak_doy INTEGER, last_doy INTEGER, years_observed INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_exobasidiales_phenology_species_id ON ord_exobasidiales_phenology (species_id); CREATE INDEX ix_ord_exobasidiales_phenology_region_country_id ON ord_exobasidiales_phenology (region_country_id); CREATE TABLE ord_exobasidiales_host_associations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, association_type TEXT, specificity TEXT, evidence_publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (evidence_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_exobasidiales_host_associations_species_id ON ord_exobasidiales_host_associations (species_id); CREATE INDEX ix_ord_exobasidiales_host_associations_host_id ON ord_exobasidiales_host_associations (host_id); CREATE TABLE ord_exobasidiales_substrate_preferences ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, substrate_id INTEGER NOT NULL, preference_score REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (substrate_id) REFERENCES eco_substrate_types (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_exobasidiales_substrate_preferences_species_id ON ord_exobasidiales_substrate_preferences (species_id); CREATE INDEX ix_ord_exobasidiales_substrate_preferences_substrate_id ON ord_exobasidiales_substrate_preferences (substrate_id); CREATE TABLE ord_exobasidiales_geographic_distribution ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, occurrence_status TEXT, first_record_year INTEGER, record_count INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_exobasidiales_geographic_distribution_species_id ON ord_exobasidiales_geographic_distribution (species_id); CREATE INDEX ix_ord_exobasidiales_geographic_distribution_country_id ON ord_exobasidiales_geographic_distribution (country_id); CREATE TABLE ord_exobasidiales_phylogeny ( id INTEGER PRIMARY KEY AUTOINCREMENT, tree_id INTEGER NOT NULL, focal_genus_id INTEGER, publication_id INTEGER, notes_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (tree_id) REFERENCES phy_trees (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_exobasidiales_phylogeny_tree_id ON ord_exobasidiales_phylogeny (tree_id); CREATE INDEX ix_ord_exobasidiales_phylogeny_focal_genus_id ON ord_exobasidiales_phylogeny (focal_genus_id); CREATE TABLE ord_exobasidiales_genomics ( id INTEGER PRIMARY KEY AUTOINCREMENT, assembly_id INTEGER NOT NULL, species_id INTEGER, avg_genome_size_mb REAL, avg_gene_count INTEGER, avg_busco_complete_pct REAL, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (assembly_id) REFERENCES gen_assemblies (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_exobasidiales_genomics_assembly_id ON ord_exobasidiales_genomics (assembly_id); CREATE INDEX ix_ord_exobasidiales_genomics_species_id ON ord_exobasidiales_genomics (species_id); CREATE TABLE ord_exobasidiales_biochemistry ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, typicality TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_exobasidiales_biochemistry_species_id ON ord_exobasidiales_biochemistry (species_id); CREATE INDEX ix_ord_exobasidiales_biochemistry_compound_id ON ord_exobasidiales_biochemistry (compound_id); CREATE TABLE ord_exobasidiales_cultivation_notes ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, typical_growth_rate_mm_per_day REAL, preferred_media_type_id INTEGER, optimal_temperature_c REAL, difficulty_score INTEGER CHECK (difficulty_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (preferred_media_type_id) REFERENCES cul_media_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_exobasidiales_cultivation_notes_species_id ON ord_exobasidiales_cultivation_notes (species_id); CREATE INDEX ix_ord_exobasidiales_cultivation_notes_strain_id ON ord_exobasidiales_cultivation_notes (strain_id); CREATE TABLE ord_exobasidiales_pathogenicity ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, disease_id INTEGER, severity_score INTEGER CHECK (severity_score BETWEEN 1 AND 5), publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (disease_id) REFERENCES pat_diseases (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_exobasidiales_pathogenicity_species_id ON ord_exobasidiales_pathogenicity (species_id); CREATE INDEX ix_ord_exobasidiales_pathogenicity_host_id ON ord_exobasidiales_pathogenicity (host_id); CREATE TABLE ord_exobasidiales_edibility ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, edibility_class TEXT, preparation_notes TEXT, regional_tradition_country_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (regional_tradition_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_exobasidiales_edibility_species_id ON ord_exobasidiales_edibility (species_id); CREATE INDEX ix_ord_exobasidiales_edibility_regional_tradition_country_id ON ord_exobasidiales_edibility (regional_tradition_country_id); CREATE TABLE ord_exobasidiales_medicinal_uses ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, traditional_use_text TEXT, modern_evidence_level TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_exobasidiales_medicinal_uses_species_id ON ord_exobasidiales_medicinal_uses (species_id); CREATE INDEX ix_ord_exobasidiales_medicinal_uses_publication_id ON ord_exobasidiales_medicinal_uses (publication_id); CREATE TABLE ord_exobasidiales_taxonomic_revisions ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER NOT NULL, affected_family_id INTEGER, affected_genus_id INTEGER, revision_summary TEXT, revision_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_family_id) REFERENCES tax_families (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_exobasidiales_taxonomic_revisions_publication_id ON ord_exobasidiales_taxonomic_revisions (publication_id); CREATE INDEX ix_ord_exobasidiales_taxonomic_revisions_affected_family_id ON ord_exobasidiales_taxonomic_revisions (affected_family_id); CREATE TABLE ord_exobasidiales_conservation_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, national_redlist_category TEXT, habitat_pressure_text TEXT, last_assessment_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_exobasidiales_conservation_status_species_id ON ord_exobasidiales_conservation_status (species_id); CREATE INDEX ix_ord_exobasidiales_conservation_status_country_id ON ord_exobasidiales_conservation_status (country_id); CREATE TABLE ord_exobasidiales_diagnostic_keys ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER, key_title TEXT NOT NULL, region_country_id INTEGER, n_taxa_covered INTEGER, key_format TEXT, includes_microscopy INTEGER NOT NULL DEFAULT 0, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_exobasidiales_diagnostic_keys_publication_id ON ord_exobasidiales_diagnostic_keys (publication_id); CREATE INDEX ix_ord_exobasidiales_diagnostic_keys_region_country_id ON ord_exobasidiales_diagnostic_keys (region_country_id); CREATE TABLE ord_exobasidiales_type_species_register ( id INTEGER PRIMARY KEY AUTOINCREMENT, focal_genus_id INTEGER NOT NULL, type_species_id INTEGER, designation_publication_id INTEGER, designation_year INTEGER, designated_by_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (designation_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_exobasidiales_type_species_register_focal_genus_id ON ord_exobasidiales_type_species_register (focal_genus_id); CREATE INDEX ix_ord_exobasidiales_type_species_register_type_species_id ON ord_exobasidiales_type_species_register (type_species_id); CREATE TABLE ord_exobasidiales_distribution_grids ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, grid_cell_code TEXT NOT NULL, centroid_lat REAL, centroid_lon REAL, record_count INTEGER, first_record_year INTEGER, most_recent_record_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_exobasidiales_distribution_grids_species_id ON ord_exobasidiales_distribution_grids (species_id); CREATE INDEX ix_ord_exobasidiales_distribution_grids_country_id ON ord_exobasidiales_distribution_grids (country_id); CREATE TABLE ord_exobasidiales_microclimate_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER, publication_id INTEGER, substrate_temperature_c REAL, substrate_moisture_pct REAL, canopy_closure_pct REAL, photosynthetic_par_umol_m2_s REAL, days_post_rainfall INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_exobasidiales_microclimate_studies_species_id ON ord_exobasidiales_microclimate_studies (species_id); CREATE INDEX ix_ord_exobasidiales_microclimate_studies_publication_id ON ord_exobasidiales_microclimate_studies (publication_id); CREATE TABLE ord_exobasidiales_dna_barcoding_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, its_sequenced INTEGER NOT NULL DEFAULT 0, lsu_sequenced INTEGER NOT NULL DEFAULT 0, rpb2_sequenced INTEGER NOT NULL DEFAULT 0, ef1a_sequenced INTEGER NOT NULL DEFAULT 0, genome_assembled INTEGER NOT NULL DEFAULT 0, priority_for_sequencing_score INTEGER CHECK (priority_for_sequencing_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_exobasidiales_dna_barcoding_status_species_id ON ord_exobasidiales_dna_barcoding_status (species_id); CREATE TABLE ord_exobasidiales_spore_print_data ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, specimen_id INTEGER, print_color_label TEXT, print_color_chip_id INTEGER, spore_density_per_mm2 REAL, collection_substrate TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (print_color_chip_id) REFERENCES mor_color_chips (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_exobasidiales_spore_print_data_species_id ON ord_exobasidiales_spore_print_data (species_id); CREATE INDEX ix_ord_exobasidiales_spore_print_data_specimen_id ON ord_exobasidiales_spore_print_data (specimen_id); CREATE TABLE ord_exobasidiales_mating_systems ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, system_type TEXT, mating_loci_count INTEGER, publication_id INTEGER, notes_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_exobasidiales_mating_systems_species_id ON ord_exobasidiales_mating_systems (species_id); CREATE INDEX ix_ord_exobasidiales_mating_systems_publication_id ON ord_exobasidiales_mating_systems (publication_id); CREATE TABLE ord_exobasidiales_nutrient_uptake_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, nitrogen_source TEXT, carbon_source TEXT, growth_response TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_exobasidiales_nutrient_uptake_studies_species_id ON ord_exobasidiales_nutrient_uptake_studies (species_id); CREATE INDEX ix_ord_exobasidiales_nutrient_uptake_studies_strain_id ON ord_exobasidiales_nutrient_uptake_studies (strain_id); CREATE TABLE ord_exobasidiales_range_maps ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, polygon_file_uri TEXT NOT NULL, source_methodology TEXT, area_km2 REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_exobasidiales_range_maps_species_id ON ord_exobasidiales_range_maps (species_id); CREATE INDEX ix_ord_exobasidiales_range_maps_publication_id ON ord_exobasidiales_range_maps (publication_id); CREATE TABLE ord_exobasidiales_abundance_estimates ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, estimate_kind TEXT, value_min REAL, value_max REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_exobasidiales_abundance_estimates_species_id ON ord_exobasidiales_abundance_estimates (species_id); CREATE INDEX ix_ord_exobasidiales_abundance_estimates_country_id ON ord_exobasidiales_abundance_estimates (country_id); CREATE TABLE ord_exobasidiales_toxin_profiles ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, presence TEXT, typical_concentration_mg_per_kg REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_exobasidiales_toxin_profiles_species_id ON ord_exobasidiales_toxin_profiles (species_id); CREATE INDEX ix_ord_exobasidiales_toxin_profiles_compound_id ON ord_exobasidiales_toxin_profiles (compound_id); CREATE TABLE ord_exobasidiales_enzyme_activity_assays ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, enzyme_id INTEGER NOT NULL, strain_id INTEGER, activity_u_per_mg REAL, temperature_c REAL, ph REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (enzyme_id) REFERENCES bio_enzymes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_exobasidiales_enzyme_activity_assays_species_id ON ord_exobasidiales_enzyme_activity_assays (species_id); CREATE INDEX ix_ord_exobasidiales_enzyme_activity_assays_enzyme_id ON ord_exobasidiales_enzyme_activity_assays (enzyme_id); CREATE TABLE ord_exobasidiales_biocontrol_evaluations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, target_pest_text TEXT NOT NULL, efficacy_pct REAL, trial_setting TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_exobasidiales_biocontrol_evaluations_species_id ON ord_exobasidiales_biocontrol_evaluations (species_id); CREATE INDEX ix_ord_exobasidiales_biocontrol_evaluations_publication_id ON ord_exobasidiales_biocontrol_evaluations (publication_id); CREATE TABLE ord_exobasidiales_regional_checklists ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, checklist_publication_id INTEGER, status TEXT, checklist_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (checklist_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_exobasidiales_regional_checklists_species_id ON ord_exobasidiales_regional_checklists (species_id); CREATE INDEX ix_ord_exobasidiales_regional_checklists_country_id ON ord_exobasidiales_regional_checklists (country_id); CREATE TABLE ord_tilletiales_morphology ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, hymenium_color_at_maturity TEXT, context_color_at_maturity TEXT, characteristic_microstructure TEXT, diagnostic_features_text TEXT, notes_kohler_reaction TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_tilletiales_morphology_specimen_id ON ord_tilletiales_morphology (specimen_id); CREATE INDEX ix_ord_tilletiales_morphology_species_id ON ord_tilletiales_morphology (species_id); CREATE TABLE ord_tilletiales_ecology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, dominant_habitat_id INTEGER, dominant_substrate_id INTEGER, dominant_biome_id INTEGER, trophic_strategy TEXT, typical_fruiting_period TEXT, known_distribution_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_habitat_id) REFERENCES eco_habitat_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_substrate_id) REFERENCES eco_substrate_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_biome_id) REFERENCES geo_biomes (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_tilletiales_ecology_species_id ON ord_tilletiales_ecology (species_id); CREATE INDEX ix_ord_tilletiales_ecology_dominant_habitat_id ON ord_tilletiales_ecology (dominant_habitat_id); CREATE TABLE ord_tilletiales_phenology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, season_name TEXT, region_country_id INTEGER, first_doy INTEGER, peak_doy INTEGER, last_doy INTEGER, years_observed INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_tilletiales_phenology_species_id ON ord_tilletiales_phenology (species_id); CREATE INDEX ix_ord_tilletiales_phenology_region_country_id ON ord_tilletiales_phenology (region_country_id); CREATE TABLE ord_tilletiales_host_associations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, association_type TEXT, specificity TEXT, evidence_publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (evidence_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_tilletiales_host_associations_species_id ON ord_tilletiales_host_associations (species_id); CREATE INDEX ix_ord_tilletiales_host_associations_host_id ON ord_tilletiales_host_associations (host_id); CREATE TABLE ord_tilletiales_substrate_preferences ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, substrate_id INTEGER NOT NULL, preference_score REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (substrate_id) REFERENCES eco_substrate_types (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_tilletiales_substrate_preferences_species_id ON ord_tilletiales_substrate_preferences (species_id); CREATE INDEX ix_ord_tilletiales_substrate_preferences_substrate_id ON ord_tilletiales_substrate_preferences (substrate_id); CREATE TABLE ord_tilletiales_geographic_distribution ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, occurrence_status TEXT, first_record_year INTEGER, record_count INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_tilletiales_geographic_distribution_species_id ON ord_tilletiales_geographic_distribution (species_id); CREATE INDEX ix_ord_tilletiales_geographic_distribution_country_id ON ord_tilletiales_geographic_distribution (country_id); CREATE TABLE ord_tilletiales_phylogeny ( id INTEGER PRIMARY KEY AUTOINCREMENT, tree_id INTEGER NOT NULL, focal_genus_id INTEGER, publication_id INTEGER, notes_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (tree_id) REFERENCES phy_trees (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_tilletiales_phylogeny_tree_id ON ord_tilletiales_phylogeny (tree_id); CREATE INDEX ix_ord_tilletiales_phylogeny_focal_genus_id ON ord_tilletiales_phylogeny (focal_genus_id); CREATE TABLE ord_tilletiales_genomics ( id INTEGER PRIMARY KEY AUTOINCREMENT, assembly_id INTEGER NOT NULL, species_id INTEGER, avg_genome_size_mb REAL, avg_gene_count INTEGER, avg_busco_complete_pct REAL, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (assembly_id) REFERENCES gen_assemblies (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_tilletiales_genomics_assembly_id ON ord_tilletiales_genomics (assembly_id); CREATE INDEX ix_ord_tilletiales_genomics_species_id ON ord_tilletiales_genomics (species_id); CREATE TABLE ord_tilletiales_biochemistry ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, typicality TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_tilletiales_biochemistry_species_id ON ord_tilletiales_biochemistry (species_id); CREATE INDEX ix_ord_tilletiales_biochemistry_compound_id ON ord_tilletiales_biochemistry (compound_id); CREATE TABLE ord_tilletiales_cultivation_notes ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, typical_growth_rate_mm_per_day REAL, preferred_media_type_id INTEGER, optimal_temperature_c REAL, difficulty_score INTEGER CHECK (difficulty_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (preferred_media_type_id) REFERENCES cul_media_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_tilletiales_cultivation_notes_species_id ON ord_tilletiales_cultivation_notes (species_id); CREATE INDEX ix_ord_tilletiales_cultivation_notes_strain_id ON ord_tilletiales_cultivation_notes (strain_id); CREATE TABLE ord_tilletiales_pathogenicity ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, disease_id INTEGER, severity_score INTEGER CHECK (severity_score BETWEEN 1 AND 5), publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (disease_id) REFERENCES pat_diseases (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_tilletiales_pathogenicity_species_id ON ord_tilletiales_pathogenicity (species_id); CREATE INDEX ix_ord_tilletiales_pathogenicity_host_id ON ord_tilletiales_pathogenicity (host_id); CREATE TABLE ord_tilletiales_edibility ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, edibility_class TEXT, preparation_notes TEXT, regional_tradition_country_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (regional_tradition_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_tilletiales_edibility_species_id ON ord_tilletiales_edibility (species_id); CREATE INDEX ix_ord_tilletiales_edibility_regional_tradition_country_id ON ord_tilletiales_edibility (regional_tradition_country_id); CREATE TABLE ord_tilletiales_medicinal_uses ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, traditional_use_text TEXT, modern_evidence_level TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_tilletiales_medicinal_uses_species_id ON ord_tilletiales_medicinal_uses (species_id); CREATE INDEX ix_ord_tilletiales_medicinal_uses_publication_id ON ord_tilletiales_medicinal_uses (publication_id); CREATE TABLE ord_tilletiales_taxonomic_revisions ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER NOT NULL, affected_family_id INTEGER, affected_genus_id INTEGER, revision_summary TEXT, revision_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_family_id) REFERENCES tax_families (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_tilletiales_taxonomic_revisions_publication_id ON ord_tilletiales_taxonomic_revisions (publication_id); CREATE INDEX ix_ord_tilletiales_taxonomic_revisions_affected_family_id ON ord_tilletiales_taxonomic_revisions (affected_family_id); CREATE TABLE ord_tilletiales_conservation_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, national_redlist_category TEXT, habitat_pressure_text TEXT, last_assessment_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_tilletiales_conservation_status_species_id ON ord_tilletiales_conservation_status (species_id); CREATE INDEX ix_ord_tilletiales_conservation_status_country_id ON ord_tilletiales_conservation_status (country_id); CREATE TABLE ord_tilletiales_diagnostic_keys ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER, key_title TEXT NOT NULL, region_country_id INTEGER, n_taxa_covered INTEGER, key_format TEXT, includes_microscopy INTEGER NOT NULL DEFAULT 0, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_tilletiales_diagnostic_keys_publication_id ON ord_tilletiales_diagnostic_keys (publication_id); CREATE INDEX ix_ord_tilletiales_diagnostic_keys_region_country_id ON ord_tilletiales_diagnostic_keys (region_country_id); CREATE TABLE ord_tilletiales_type_species_register ( id INTEGER PRIMARY KEY AUTOINCREMENT, focal_genus_id INTEGER NOT NULL, type_species_id INTEGER, designation_publication_id INTEGER, designation_year INTEGER, designated_by_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (designation_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_tilletiales_type_species_register_focal_genus_id ON ord_tilletiales_type_species_register (focal_genus_id); CREATE INDEX ix_ord_tilletiales_type_species_register_type_species_id ON ord_tilletiales_type_species_register (type_species_id); CREATE TABLE ord_tilletiales_distribution_grids ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, grid_cell_code TEXT NOT NULL, centroid_lat REAL, centroid_lon REAL, record_count INTEGER, first_record_year INTEGER, most_recent_record_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_tilletiales_distribution_grids_species_id ON ord_tilletiales_distribution_grids (species_id); CREATE INDEX ix_ord_tilletiales_distribution_grids_country_id ON ord_tilletiales_distribution_grids (country_id); CREATE TABLE ord_tilletiales_microclimate_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER, publication_id INTEGER, substrate_temperature_c REAL, substrate_moisture_pct REAL, canopy_closure_pct REAL, photosynthetic_par_umol_m2_s REAL, days_post_rainfall INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_tilletiales_microclimate_studies_species_id ON ord_tilletiales_microclimate_studies (species_id); CREATE INDEX ix_ord_tilletiales_microclimate_studies_publication_id ON ord_tilletiales_microclimate_studies (publication_id); CREATE TABLE ord_tilletiales_dna_barcoding_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, its_sequenced INTEGER NOT NULL DEFAULT 0, lsu_sequenced INTEGER NOT NULL DEFAULT 0, rpb2_sequenced INTEGER NOT NULL DEFAULT 0, ef1a_sequenced INTEGER NOT NULL DEFAULT 0, genome_assembled INTEGER NOT NULL DEFAULT 0, priority_for_sequencing_score INTEGER CHECK (priority_for_sequencing_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_tilletiales_dna_barcoding_status_species_id ON ord_tilletiales_dna_barcoding_status (species_id); CREATE TABLE ord_tilletiales_spore_print_data ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, specimen_id INTEGER, print_color_label TEXT, print_color_chip_id INTEGER, spore_density_per_mm2 REAL, collection_substrate TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (print_color_chip_id) REFERENCES mor_color_chips (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_tilletiales_spore_print_data_species_id ON ord_tilletiales_spore_print_data (species_id); CREATE INDEX ix_ord_tilletiales_spore_print_data_specimen_id ON ord_tilletiales_spore_print_data (specimen_id); CREATE TABLE ord_tilletiales_mating_systems ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, system_type TEXT, mating_loci_count INTEGER, publication_id INTEGER, notes_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_tilletiales_mating_systems_species_id ON ord_tilletiales_mating_systems (species_id); CREATE INDEX ix_ord_tilletiales_mating_systems_publication_id ON ord_tilletiales_mating_systems (publication_id); CREATE TABLE ord_tilletiales_nutrient_uptake_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, nitrogen_source TEXT, carbon_source TEXT, growth_response TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_tilletiales_nutrient_uptake_studies_species_id ON ord_tilletiales_nutrient_uptake_studies (species_id); CREATE INDEX ix_ord_tilletiales_nutrient_uptake_studies_strain_id ON ord_tilletiales_nutrient_uptake_studies (strain_id); CREATE TABLE ord_tilletiales_range_maps ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, polygon_file_uri TEXT NOT NULL, source_methodology TEXT, area_km2 REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_tilletiales_range_maps_species_id ON ord_tilletiales_range_maps (species_id); CREATE INDEX ix_ord_tilletiales_range_maps_publication_id ON ord_tilletiales_range_maps (publication_id); CREATE TABLE ord_tilletiales_abundance_estimates ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, estimate_kind TEXT, value_min REAL, value_max REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_tilletiales_abundance_estimates_species_id ON ord_tilletiales_abundance_estimates (species_id); CREATE INDEX ix_ord_tilletiales_abundance_estimates_country_id ON ord_tilletiales_abundance_estimates (country_id); CREATE TABLE ord_tilletiales_toxin_profiles ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, presence TEXT, typical_concentration_mg_per_kg REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_tilletiales_toxin_profiles_species_id ON ord_tilletiales_toxin_profiles (species_id); CREATE INDEX ix_ord_tilletiales_toxin_profiles_compound_id ON ord_tilletiales_toxin_profiles (compound_id); CREATE TABLE ord_tilletiales_enzyme_activity_assays ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, enzyme_id INTEGER NOT NULL, strain_id INTEGER, activity_u_per_mg REAL, temperature_c REAL, ph REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (enzyme_id) REFERENCES bio_enzymes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_tilletiales_enzyme_activity_assays_species_id ON ord_tilletiales_enzyme_activity_assays (species_id); CREATE INDEX ix_ord_tilletiales_enzyme_activity_assays_enzyme_id ON ord_tilletiales_enzyme_activity_assays (enzyme_id); CREATE TABLE ord_tilletiales_biocontrol_evaluations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, target_pest_text TEXT NOT NULL, efficacy_pct REAL, trial_setting TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_tilletiales_biocontrol_evaluations_species_id ON ord_tilletiales_biocontrol_evaluations (species_id); CREATE INDEX ix_ord_tilletiales_biocontrol_evaluations_publication_id ON ord_tilletiales_biocontrol_evaluations (publication_id); CREATE TABLE ord_tilletiales_regional_checklists ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, checklist_publication_id INTEGER, status TEXT, checklist_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (checklist_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_tilletiales_regional_checklists_species_id ON ord_tilletiales_regional_checklists (species_id); CREATE INDEX ix_ord_tilletiales_regional_checklists_country_id ON ord_tilletiales_regional_checklists (country_id); CREATE TABLE ord_malasseziales_morphology ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, hymenium_color_at_maturity TEXT, context_color_at_maturity TEXT, characteristic_microstructure TEXT, diagnostic_features_text TEXT, notes_kohler_reaction TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_malasseziales_morphology_specimen_id ON ord_malasseziales_morphology (specimen_id); CREATE INDEX ix_ord_malasseziales_morphology_species_id ON ord_malasseziales_morphology (species_id); CREATE TABLE ord_malasseziales_ecology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, dominant_habitat_id INTEGER, dominant_substrate_id INTEGER, dominant_biome_id INTEGER, trophic_strategy TEXT, typical_fruiting_period TEXT, known_distribution_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_habitat_id) REFERENCES eco_habitat_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_substrate_id) REFERENCES eco_substrate_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_biome_id) REFERENCES geo_biomes (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_malasseziales_ecology_species_id ON ord_malasseziales_ecology (species_id); CREATE INDEX ix_ord_malasseziales_ecology_dominant_habitat_id ON ord_malasseziales_ecology (dominant_habitat_id); CREATE TABLE ord_malasseziales_phenology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, season_name TEXT, region_country_id INTEGER, first_doy INTEGER, peak_doy INTEGER, last_doy INTEGER, years_observed INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_malasseziales_phenology_species_id ON ord_malasseziales_phenology (species_id); CREATE INDEX ix_ord_malasseziales_phenology_region_country_id ON ord_malasseziales_phenology (region_country_id); CREATE TABLE ord_malasseziales_host_associations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, association_type TEXT, specificity TEXT, evidence_publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (evidence_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_malasseziales_host_associations_species_id ON ord_malasseziales_host_associations (species_id); CREATE INDEX ix_ord_malasseziales_host_associations_host_id ON ord_malasseziales_host_associations (host_id); CREATE TABLE ord_malasseziales_substrate_preferences ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, substrate_id INTEGER NOT NULL, preference_score REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (substrate_id) REFERENCES eco_substrate_types (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_malasseziales_substrate_preferences_species_id ON ord_malasseziales_substrate_preferences (species_id); CREATE INDEX ix_ord_malasseziales_substrate_preferences_substrate_id ON ord_malasseziales_substrate_preferences (substrate_id); CREATE TABLE ord_malasseziales_geographic_distribution ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, occurrence_status TEXT, first_record_year INTEGER, record_count INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_malasseziales_geographic_distribution_species_id ON ord_malasseziales_geographic_distribution (species_id); CREATE INDEX ix_ord_malasseziales_geographic_distribution_country_id ON ord_malasseziales_geographic_distribution (country_id); CREATE TABLE ord_malasseziales_phylogeny ( id INTEGER PRIMARY KEY AUTOINCREMENT, tree_id INTEGER NOT NULL, focal_genus_id INTEGER, publication_id INTEGER, notes_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (tree_id) REFERENCES phy_trees (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_malasseziales_phylogeny_tree_id ON ord_malasseziales_phylogeny (tree_id); CREATE INDEX ix_ord_malasseziales_phylogeny_focal_genus_id ON ord_malasseziales_phylogeny (focal_genus_id); CREATE TABLE ord_malasseziales_genomics ( id INTEGER PRIMARY KEY AUTOINCREMENT, assembly_id INTEGER NOT NULL, species_id INTEGER, avg_genome_size_mb REAL, avg_gene_count INTEGER, avg_busco_complete_pct REAL, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (assembly_id) REFERENCES gen_assemblies (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_malasseziales_genomics_assembly_id ON ord_malasseziales_genomics (assembly_id); CREATE INDEX ix_ord_malasseziales_genomics_species_id ON ord_malasseziales_genomics (species_id); CREATE TABLE ord_malasseziales_biochemistry ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, typicality TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_malasseziales_biochemistry_species_id ON ord_malasseziales_biochemistry (species_id); CREATE INDEX ix_ord_malasseziales_biochemistry_compound_id ON ord_malasseziales_biochemistry (compound_id); CREATE TABLE ord_malasseziales_cultivation_notes ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, typical_growth_rate_mm_per_day REAL, preferred_media_type_id INTEGER, optimal_temperature_c REAL, difficulty_score INTEGER CHECK (difficulty_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (preferred_media_type_id) REFERENCES cul_media_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_malasseziales_cultivation_notes_species_id ON ord_malasseziales_cultivation_notes (species_id); CREATE INDEX ix_ord_malasseziales_cultivation_notes_strain_id ON ord_malasseziales_cultivation_notes (strain_id); CREATE TABLE ord_malasseziales_pathogenicity ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, disease_id INTEGER, severity_score INTEGER CHECK (severity_score BETWEEN 1 AND 5), publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (disease_id) REFERENCES pat_diseases (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_malasseziales_pathogenicity_species_id ON ord_malasseziales_pathogenicity (species_id); CREATE INDEX ix_ord_malasseziales_pathogenicity_host_id ON ord_malasseziales_pathogenicity (host_id); CREATE TABLE ord_malasseziales_edibility ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, edibility_class TEXT, preparation_notes TEXT, regional_tradition_country_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (regional_tradition_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_malasseziales_edibility_species_id ON ord_malasseziales_edibility (species_id); CREATE INDEX ix_ord_malasseziales_edibility_regional_tradition_country_id ON ord_malasseziales_edibility (regional_tradition_country_id); CREATE TABLE ord_malasseziales_medicinal_uses ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, traditional_use_text TEXT, modern_evidence_level TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_malasseziales_medicinal_uses_species_id ON ord_malasseziales_medicinal_uses (species_id); CREATE INDEX ix_ord_malasseziales_medicinal_uses_publication_id ON ord_malasseziales_medicinal_uses (publication_id); CREATE TABLE ord_malasseziales_taxonomic_revisions ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER NOT NULL, affected_family_id INTEGER, affected_genus_id INTEGER, revision_summary TEXT, revision_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_family_id) REFERENCES tax_families (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_malasseziales_taxonomic_revisions_publication_id ON ord_malasseziales_taxonomic_revisions (publication_id); CREATE INDEX ix_ord_malasseziales_taxonomic_revisions_affected_family_id ON ord_malasseziales_taxonomic_revisions (affected_family_id); CREATE TABLE ord_malasseziales_conservation_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, national_redlist_category TEXT, habitat_pressure_text TEXT, last_assessment_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_malasseziales_conservation_status_species_id ON ord_malasseziales_conservation_status (species_id); CREATE INDEX ix_ord_malasseziales_conservation_status_country_id ON ord_malasseziales_conservation_status (country_id); CREATE TABLE ord_malasseziales_diagnostic_keys ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER, key_title TEXT NOT NULL, region_country_id INTEGER, n_taxa_covered INTEGER, key_format TEXT, includes_microscopy INTEGER NOT NULL DEFAULT 0, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_malasseziales_diagnostic_keys_publication_id ON ord_malasseziales_diagnostic_keys (publication_id); CREATE INDEX ix_ord_malasseziales_diagnostic_keys_region_country_id ON ord_malasseziales_diagnostic_keys (region_country_id); CREATE TABLE ord_malasseziales_type_species_register ( id INTEGER PRIMARY KEY AUTOINCREMENT, focal_genus_id INTEGER NOT NULL, type_species_id INTEGER, designation_publication_id INTEGER, designation_year INTEGER, designated_by_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (designation_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_malasseziales_type_species_register_focal_genus_id ON ord_malasseziales_type_species_register (focal_genus_id); CREATE INDEX ix_ord_malasseziales_type_species_register_type_species_id ON ord_malasseziales_type_species_register (type_species_id); CREATE TABLE ord_malasseziales_distribution_grids ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, grid_cell_code TEXT NOT NULL, centroid_lat REAL, centroid_lon REAL, record_count INTEGER, first_record_year INTEGER, most_recent_record_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_malasseziales_distribution_grids_species_id ON ord_malasseziales_distribution_grids (species_id); CREATE INDEX ix_ord_malasseziales_distribution_grids_country_id ON ord_malasseziales_distribution_grids (country_id); CREATE TABLE ord_malasseziales_microclimate_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER, publication_id INTEGER, substrate_temperature_c REAL, substrate_moisture_pct REAL, canopy_closure_pct REAL, photosynthetic_par_umol_m2_s REAL, days_post_rainfall INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_malasseziales_microclimate_studies_species_id ON ord_malasseziales_microclimate_studies (species_id); CREATE INDEX ix_ord_malasseziales_microclimate_studies_publication_id ON ord_malasseziales_microclimate_studies (publication_id); CREATE TABLE ord_malasseziales_dna_barcoding_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, its_sequenced INTEGER NOT NULL DEFAULT 0, lsu_sequenced INTEGER NOT NULL DEFAULT 0, rpb2_sequenced INTEGER NOT NULL DEFAULT 0, ef1a_sequenced INTEGER NOT NULL DEFAULT 0, genome_assembled INTEGER NOT NULL DEFAULT 0, priority_for_sequencing_score INTEGER CHECK (priority_for_sequencing_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_malasseziales_dna_barcoding_status_species_id ON ord_malasseziales_dna_barcoding_status (species_id); CREATE TABLE ord_malasseziales_spore_print_data ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, specimen_id INTEGER, print_color_label TEXT, print_color_chip_id INTEGER, spore_density_per_mm2 REAL, collection_substrate TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (print_color_chip_id) REFERENCES mor_color_chips (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_malasseziales_spore_print_data_species_id ON ord_malasseziales_spore_print_data (species_id); CREATE INDEX ix_ord_malasseziales_spore_print_data_specimen_id ON ord_malasseziales_spore_print_data (specimen_id); CREATE TABLE ord_malasseziales_mating_systems ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, system_type TEXT, mating_loci_count INTEGER, publication_id INTEGER, notes_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_malasseziales_mating_systems_species_id ON ord_malasseziales_mating_systems (species_id); CREATE INDEX ix_ord_malasseziales_mating_systems_publication_id ON ord_malasseziales_mating_systems (publication_id); CREATE TABLE ord_malasseziales_nutrient_uptake_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, nitrogen_source TEXT, carbon_source TEXT, growth_response TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_malasseziales_nutrient_uptake_studies_species_id ON ord_malasseziales_nutrient_uptake_studies (species_id); CREATE INDEX ix_ord_malasseziales_nutrient_uptake_studies_strain_id ON ord_malasseziales_nutrient_uptake_studies (strain_id); CREATE TABLE ord_malasseziales_range_maps ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, polygon_file_uri TEXT NOT NULL, source_methodology TEXT, area_km2 REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_malasseziales_range_maps_species_id ON ord_malasseziales_range_maps (species_id); CREATE INDEX ix_ord_malasseziales_range_maps_publication_id ON ord_malasseziales_range_maps (publication_id); CREATE TABLE ord_malasseziales_abundance_estimates ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, estimate_kind TEXT, value_min REAL, value_max REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_malasseziales_abundance_estimates_species_id ON ord_malasseziales_abundance_estimates (species_id); CREATE INDEX ix_ord_malasseziales_abundance_estimates_country_id ON ord_malasseziales_abundance_estimates (country_id); CREATE TABLE ord_malasseziales_toxin_profiles ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, presence TEXT, typical_concentration_mg_per_kg REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_malasseziales_toxin_profiles_species_id ON ord_malasseziales_toxin_profiles (species_id); CREATE INDEX ix_ord_malasseziales_toxin_profiles_compound_id ON ord_malasseziales_toxin_profiles (compound_id); CREATE TABLE ord_malasseziales_enzyme_activity_assays ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, enzyme_id INTEGER NOT NULL, strain_id INTEGER, activity_u_per_mg REAL, temperature_c REAL, ph REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (enzyme_id) REFERENCES bio_enzymes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_malasseziales_enzyme_activity_assays_species_id ON ord_malasseziales_enzyme_activity_assays (species_id); CREATE INDEX ix_ord_malasseziales_enzyme_activity_assays_enzyme_id ON ord_malasseziales_enzyme_activity_assays (enzyme_id); CREATE TABLE ord_malasseziales_biocontrol_evaluations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, target_pest_text TEXT NOT NULL, efficacy_pct REAL, trial_setting TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_malasseziales_biocontrol_evaluations_species_id ON ord_malasseziales_biocontrol_evaluations (species_id); CREATE INDEX ix_ord_malasseziales_biocontrol_evaluations_publication_id ON ord_malasseziales_biocontrol_evaluations (publication_id); CREATE TABLE ord_malasseziales_regional_checklists ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, checklist_publication_id INTEGER, status TEXT, checklist_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (checklist_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_malasseziales_regional_checklists_species_id ON ord_malasseziales_regional_checklists (species_id); CREATE INDEX ix_ord_malasseziales_regional_checklists_country_id ON ord_malasseziales_regional_checklists (country_id); CREATE TABLE ord_trichosporonales_morphology ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, hymenium_color_at_maturity TEXT, context_color_at_maturity TEXT, characteristic_microstructure TEXT, diagnostic_features_text TEXT, notes_kohler_reaction TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_trichosporonales_morphology_specimen_id ON ord_trichosporonales_morphology (specimen_id); CREATE INDEX ix_ord_trichosporonales_morphology_species_id ON ord_trichosporonales_morphology (species_id); CREATE TABLE ord_trichosporonales_ecology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, dominant_habitat_id INTEGER, dominant_substrate_id INTEGER, dominant_biome_id INTEGER, trophic_strategy TEXT, typical_fruiting_period TEXT, known_distribution_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_habitat_id) REFERENCES eco_habitat_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_substrate_id) REFERENCES eco_substrate_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_biome_id) REFERENCES geo_biomes (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_trichosporonales_ecology_species_id ON ord_trichosporonales_ecology (species_id); CREATE INDEX ix_ord_trichosporonales_ecology_dominant_habitat_id ON ord_trichosporonales_ecology (dominant_habitat_id); CREATE TABLE ord_trichosporonales_phenology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, season_name TEXT, region_country_id INTEGER, first_doy INTEGER, peak_doy INTEGER, last_doy INTEGER, years_observed INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_trichosporonales_phenology_species_id ON ord_trichosporonales_phenology (species_id); CREATE INDEX ix_ord_trichosporonales_phenology_region_country_id ON ord_trichosporonales_phenology (region_country_id); CREATE TABLE ord_trichosporonales_host_associations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, association_type TEXT, specificity TEXT, evidence_publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (evidence_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_trichosporonales_host_associations_species_id ON ord_trichosporonales_host_associations (species_id); CREATE INDEX ix_ord_trichosporonales_host_associations_host_id ON ord_trichosporonales_host_associations (host_id); CREATE TABLE ord_trichosporonales_substrate_preferences ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, substrate_id INTEGER NOT NULL, preference_score REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (substrate_id) REFERENCES eco_substrate_types (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_trichosporonales_substrate_preferences_species_id ON ord_trichosporonales_substrate_preferences (species_id); CREATE INDEX ix_ord_trichosporonales_substrate_preferences_substrate_id ON ord_trichosporonales_substrate_preferences (substrate_id); CREATE TABLE ord_trichosporonales_geographic_distribution ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, occurrence_status TEXT, first_record_year INTEGER, record_count INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_trichosporonales_geographic_distribution_species_id ON ord_trichosporonales_geographic_distribution (species_id); CREATE INDEX ix_ord_trichosporonales_geographic_distribution_country_id ON ord_trichosporonales_geographic_distribution (country_id); CREATE TABLE ord_trichosporonales_phylogeny ( id INTEGER PRIMARY KEY AUTOINCREMENT, tree_id INTEGER NOT NULL, focal_genus_id INTEGER, publication_id INTEGER, notes_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (tree_id) REFERENCES phy_trees (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_trichosporonales_phylogeny_tree_id ON ord_trichosporonales_phylogeny (tree_id); CREATE INDEX ix_ord_trichosporonales_phylogeny_focal_genus_id ON ord_trichosporonales_phylogeny (focal_genus_id); CREATE TABLE ord_trichosporonales_genomics ( id INTEGER PRIMARY KEY AUTOINCREMENT, assembly_id INTEGER NOT NULL, species_id INTEGER, avg_genome_size_mb REAL, avg_gene_count INTEGER, avg_busco_complete_pct REAL, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (assembly_id) REFERENCES gen_assemblies (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_trichosporonales_genomics_assembly_id ON ord_trichosporonales_genomics (assembly_id); CREATE INDEX ix_ord_trichosporonales_genomics_species_id ON ord_trichosporonales_genomics (species_id); CREATE TABLE ord_trichosporonales_biochemistry ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, typicality TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_trichosporonales_biochemistry_species_id ON ord_trichosporonales_biochemistry (species_id); CREATE INDEX ix_ord_trichosporonales_biochemistry_compound_id ON ord_trichosporonales_biochemistry (compound_id); CREATE TABLE ord_trichosporonales_cultivation_notes ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, typical_growth_rate_mm_per_day REAL, preferred_media_type_id INTEGER, optimal_temperature_c REAL, difficulty_score INTEGER CHECK (difficulty_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (preferred_media_type_id) REFERENCES cul_media_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_trichosporonales_cultivation_notes_species_id ON ord_trichosporonales_cultivation_notes (species_id); CREATE INDEX ix_ord_trichosporonales_cultivation_notes_strain_id ON ord_trichosporonales_cultivation_notes (strain_id); CREATE TABLE ord_trichosporonales_pathogenicity ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, disease_id INTEGER, severity_score INTEGER CHECK (severity_score BETWEEN 1 AND 5), publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (disease_id) REFERENCES pat_diseases (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_trichosporonales_pathogenicity_species_id ON ord_trichosporonales_pathogenicity (species_id); CREATE INDEX ix_ord_trichosporonales_pathogenicity_host_id ON ord_trichosporonales_pathogenicity (host_id); CREATE TABLE ord_trichosporonales_edibility ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, edibility_class TEXT, preparation_notes TEXT, regional_tradition_country_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (regional_tradition_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_trichosporonales_edibility_species_id ON ord_trichosporonales_edibility (species_id); CREATE INDEX ix_ord_trichosporonales_edibility_1 ON ord_trichosporonales_edibility (regional_tradition_country_id); CREATE TABLE ord_trichosporonales_medicinal_uses ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, traditional_use_text TEXT, modern_evidence_level TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_trichosporonales_medicinal_uses_species_id ON ord_trichosporonales_medicinal_uses (species_id); CREATE INDEX ix_ord_trichosporonales_medicinal_uses_publication_id ON ord_trichosporonales_medicinal_uses (publication_id); CREATE TABLE ord_trichosporonales_taxonomic_revisions ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER NOT NULL, affected_family_id INTEGER, affected_genus_id INTEGER, revision_summary TEXT, revision_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_family_id) REFERENCES tax_families (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_trichosporonales_taxonomic_revisions_publication_id ON ord_trichosporonales_taxonomic_revisions (publication_id); CREATE INDEX ix_ord_trichosporonales_taxonomic_revisions_1 ON ord_trichosporonales_taxonomic_revisions (affected_family_id); CREATE TABLE ord_trichosporonales_conservation_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, national_redlist_category TEXT, habitat_pressure_text TEXT, last_assessment_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_trichosporonales_conservation_status_species_id ON ord_trichosporonales_conservation_status (species_id); CREATE INDEX ix_ord_trichosporonales_conservation_status_country_id ON ord_trichosporonales_conservation_status (country_id); CREATE TABLE ord_trichosporonales_diagnostic_keys ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER, key_title TEXT NOT NULL, region_country_id INTEGER, n_taxa_covered INTEGER, key_format TEXT, includes_microscopy INTEGER NOT NULL DEFAULT 0, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_trichosporonales_diagnostic_keys_publication_id ON ord_trichosporonales_diagnostic_keys (publication_id); CREATE INDEX ix_ord_trichosporonales_diagnostic_keys_region_country_id ON ord_trichosporonales_diagnostic_keys (region_country_id); CREATE TABLE ord_trichosporonales_type_species_register ( id INTEGER PRIMARY KEY AUTOINCREMENT, focal_genus_id INTEGER NOT NULL, type_species_id INTEGER, designation_publication_id INTEGER, designation_year INTEGER, designated_by_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (designation_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_trichosporonales_type_species_register_focal_genus_id ON ord_trichosporonales_type_species_register (focal_genus_id); CREATE INDEX ix_ord_trichosporonales_type_species_register_1 ON ord_trichosporonales_type_species_register (type_species_id); CREATE TABLE ord_trichosporonales_distribution_grids ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, grid_cell_code TEXT NOT NULL, centroid_lat REAL, centroid_lon REAL, record_count INTEGER, first_record_year INTEGER, most_recent_record_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_trichosporonales_distribution_grids_species_id ON ord_trichosporonales_distribution_grids (species_id); CREATE INDEX ix_ord_trichosporonales_distribution_grids_country_id ON ord_trichosporonales_distribution_grids (country_id); CREATE TABLE ord_trichosporonales_microclimate_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER, publication_id INTEGER, substrate_temperature_c REAL, substrate_moisture_pct REAL, canopy_closure_pct REAL, photosynthetic_par_umol_m2_s REAL, days_post_rainfall INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_trichosporonales_microclimate_studies_species_id ON ord_trichosporonales_microclimate_studies (species_id); CREATE INDEX ix_ord_trichosporonales_microclimate_studies_publication_id ON ord_trichosporonales_microclimate_studies (publication_id); CREATE TABLE ord_trichosporonales_dna_barcoding_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, its_sequenced INTEGER NOT NULL DEFAULT 0, lsu_sequenced INTEGER NOT NULL DEFAULT 0, rpb2_sequenced INTEGER NOT NULL DEFAULT 0, ef1a_sequenced INTEGER NOT NULL DEFAULT 0, genome_assembled INTEGER NOT NULL DEFAULT 0, priority_for_sequencing_score INTEGER CHECK (priority_for_sequencing_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_trichosporonales_dna_barcoding_status_species_id ON ord_trichosporonales_dna_barcoding_status (species_id); CREATE TABLE ord_trichosporonales_spore_print_data ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, specimen_id INTEGER, print_color_label TEXT, print_color_chip_id INTEGER, spore_density_per_mm2 REAL, collection_substrate TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (print_color_chip_id) REFERENCES mor_color_chips (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_trichosporonales_spore_print_data_species_id ON ord_trichosporonales_spore_print_data (species_id); CREATE INDEX ix_ord_trichosporonales_spore_print_data_specimen_id ON ord_trichosporonales_spore_print_data (specimen_id); CREATE TABLE ord_trichosporonales_mating_systems ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, system_type TEXT, mating_loci_count INTEGER, publication_id INTEGER, notes_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_trichosporonales_mating_systems_species_id ON ord_trichosporonales_mating_systems (species_id); CREATE INDEX ix_ord_trichosporonales_mating_systems_publication_id ON ord_trichosporonales_mating_systems (publication_id); CREATE TABLE ord_trichosporonales_nutrient_uptake_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, nitrogen_source TEXT, carbon_source TEXT, growth_response TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_trichosporonales_nutrient_uptake_studies_species_id ON ord_trichosporonales_nutrient_uptake_studies (species_id); CREATE INDEX ix_ord_trichosporonales_nutrient_uptake_studies_strain_id ON ord_trichosporonales_nutrient_uptake_studies (strain_id); CREATE TABLE ord_trichosporonales_range_maps ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, polygon_file_uri TEXT NOT NULL, source_methodology TEXT, area_km2 REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_trichosporonales_range_maps_species_id ON ord_trichosporonales_range_maps (species_id); CREATE INDEX ix_ord_trichosporonales_range_maps_publication_id ON ord_trichosporonales_range_maps (publication_id); CREATE TABLE ord_trichosporonales_abundance_estimates ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, estimate_kind TEXT, value_min REAL, value_max REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_trichosporonales_abundance_estimates_species_id ON ord_trichosporonales_abundance_estimates (species_id); CREATE INDEX ix_ord_trichosporonales_abundance_estimates_country_id ON ord_trichosporonales_abundance_estimates (country_id); CREATE TABLE ord_trichosporonales_toxin_profiles ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, presence TEXT, typical_concentration_mg_per_kg REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_trichosporonales_toxin_profiles_species_id ON ord_trichosporonales_toxin_profiles (species_id); CREATE INDEX ix_ord_trichosporonales_toxin_profiles_compound_id ON ord_trichosporonales_toxin_profiles (compound_id); CREATE TABLE ord_trichosporonales_enzyme_activity_assays ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, enzyme_id INTEGER NOT NULL, strain_id INTEGER, activity_u_per_mg REAL, temperature_c REAL, ph REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (enzyme_id) REFERENCES bio_enzymes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_trichosporonales_enzyme_activity_assays_species_id ON ord_trichosporonales_enzyme_activity_assays (species_id); CREATE INDEX ix_ord_trichosporonales_enzyme_activity_assays_enzyme_id ON ord_trichosporonales_enzyme_activity_assays (enzyme_id); CREATE TABLE ord_trichosporonales_biocontrol_evaluations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, target_pest_text TEXT NOT NULL, efficacy_pct REAL, trial_setting TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_trichosporonales_biocontrol_evaluations_species_id ON ord_trichosporonales_biocontrol_evaluations (species_id); CREATE INDEX ix_ord_trichosporonales_biocontrol_evaluations_1 ON ord_trichosporonales_biocontrol_evaluations (publication_id); CREATE TABLE ord_trichosporonales_regional_checklists ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, checklist_publication_id INTEGER, status TEXT, checklist_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (checklist_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_trichosporonales_regional_checklists_species_id ON ord_trichosporonales_regional_checklists (species_id); CREATE INDEX ix_ord_trichosporonales_regional_checklists_country_id ON ord_trichosporonales_regional_checklists (country_id); CREATE TABLE ord_saccharomycetales_morphology ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, hymenium_color_at_maturity TEXT, context_color_at_maturity TEXT, characteristic_microstructure TEXT, diagnostic_features_text TEXT, notes_kohler_reaction TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_saccharomycetales_morphology_specimen_id ON ord_saccharomycetales_morphology (specimen_id); CREATE INDEX ix_ord_saccharomycetales_morphology_species_id ON ord_saccharomycetales_morphology (species_id); CREATE TABLE ord_saccharomycetales_ecology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, dominant_habitat_id INTEGER, dominant_substrate_id INTEGER, dominant_biome_id INTEGER, trophic_strategy TEXT, typical_fruiting_period TEXT, known_distribution_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_habitat_id) REFERENCES eco_habitat_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_substrate_id) REFERENCES eco_substrate_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_biome_id) REFERENCES geo_biomes (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_saccharomycetales_ecology_species_id ON ord_saccharomycetales_ecology (species_id); CREATE INDEX ix_ord_saccharomycetales_ecology_dominant_habitat_id ON ord_saccharomycetales_ecology (dominant_habitat_id); CREATE TABLE ord_saccharomycetales_phenology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, season_name TEXT, region_country_id INTEGER, first_doy INTEGER, peak_doy INTEGER, last_doy INTEGER, years_observed INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_saccharomycetales_phenology_species_id ON ord_saccharomycetales_phenology (species_id); CREATE INDEX ix_ord_saccharomycetales_phenology_region_country_id ON ord_saccharomycetales_phenology (region_country_id); CREATE TABLE ord_saccharomycetales_host_associations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, association_type TEXT, specificity TEXT, evidence_publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (evidence_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_saccharomycetales_host_associations_species_id ON ord_saccharomycetales_host_associations (species_id); CREATE INDEX ix_ord_saccharomycetales_host_associations_host_id ON ord_saccharomycetales_host_associations (host_id); CREATE TABLE ord_saccharomycetales_substrate_preferences ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, substrate_id INTEGER NOT NULL, preference_score REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (substrate_id) REFERENCES eco_substrate_types (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_saccharomycetales_substrate_preferences_species_id ON ord_saccharomycetales_substrate_preferences (species_id); CREATE INDEX ix_ord_saccharomycetales_substrate_preferences_substrate_id ON ord_saccharomycetales_substrate_preferences (substrate_id); CREATE TABLE ord_saccharomycetales_geographic_distribution ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, occurrence_status TEXT, first_record_year INTEGER, record_count INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_saccharomycetales_geographic_distribution_species_id ON ord_saccharomycetales_geographic_distribution (species_id); CREATE INDEX ix_ord_saccharomycetales_geographic_distribution_country_id ON ord_saccharomycetales_geographic_distribution (country_id); CREATE TABLE ord_saccharomycetales_phylogeny ( id INTEGER PRIMARY KEY AUTOINCREMENT, tree_id INTEGER NOT NULL, focal_genus_id INTEGER, publication_id INTEGER, notes_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (tree_id) REFERENCES phy_trees (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_saccharomycetales_phylogeny_tree_id ON ord_saccharomycetales_phylogeny (tree_id); CREATE INDEX ix_ord_saccharomycetales_phylogeny_focal_genus_id ON ord_saccharomycetales_phylogeny (focal_genus_id); CREATE TABLE ord_saccharomycetales_genomics ( id INTEGER PRIMARY KEY AUTOINCREMENT, assembly_id INTEGER NOT NULL, species_id INTEGER, avg_genome_size_mb REAL, avg_gene_count INTEGER, avg_busco_complete_pct REAL, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (assembly_id) REFERENCES gen_assemblies (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_saccharomycetales_genomics_assembly_id ON ord_saccharomycetales_genomics (assembly_id); CREATE INDEX ix_ord_saccharomycetales_genomics_species_id ON ord_saccharomycetales_genomics (species_id); CREATE TABLE ord_saccharomycetales_biochemistry ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, typicality TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_saccharomycetales_biochemistry_species_id ON ord_saccharomycetales_biochemistry (species_id); CREATE INDEX ix_ord_saccharomycetales_biochemistry_compound_id ON ord_saccharomycetales_biochemistry (compound_id); CREATE TABLE ord_saccharomycetales_cultivation_notes ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, typical_growth_rate_mm_per_day REAL, preferred_media_type_id INTEGER, optimal_temperature_c REAL, difficulty_score INTEGER CHECK (difficulty_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (preferred_media_type_id) REFERENCES cul_media_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_saccharomycetales_cultivation_notes_species_id ON ord_saccharomycetales_cultivation_notes (species_id); CREATE INDEX ix_ord_saccharomycetales_cultivation_notes_strain_id ON ord_saccharomycetales_cultivation_notes (strain_id); CREATE TABLE ord_saccharomycetales_pathogenicity ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, disease_id INTEGER, severity_score INTEGER CHECK (severity_score BETWEEN 1 AND 5), publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (disease_id) REFERENCES pat_diseases (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_saccharomycetales_pathogenicity_species_id ON ord_saccharomycetales_pathogenicity (species_id); CREATE INDEX ix_ord_saccharomycetales_pathogenicity_host_id ON ord_saccharomycetales_pathogenicity (host_id); CREATE TABLE ord_saccharomycetales_edibility ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, edibility_class TEXT, preparation_notes TEXT, regional_tradition_country_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (regional_tradition_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_saccharomycetales_edibility_species_id ON ord_saccharomycetales_edibility (species_id); CREATE INDEX ix_ord_saccharomycetales_edibility_1 ON ord_saccharomycetales_edibility (regional_tradition_country_id); CREATE TABLE ord_saccharomycetales_medicinal_uses ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, traditional_use_text TEXT, modern_evidence_level TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_saccharomycetales_medicinal_uses_species_id ON ord_saccharomycetales_medicinal_uses (species_id); CREATE INDEX ix_ord_saccharomycetales_medicinal_uses_publication_id ON ord_saccharomycetales_medicinal_uses (publication_id); CREATE TABLE ord_saccharomycetales_taxonomic_revisions ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER NOT NULL, affected_family_id INTEGER, affected_genus_id INTEGER, revision_summary TEXT, revision_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_family_id) REFERENCES tax_families (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_saccharomycetales_taxonomic_revisions_publication_id ON ord_saccharomycetales_taxonomic_revisions (publication_id); CREATE INDEX ix_ord_saccharomycetales_taxonomic_revisions_1 ON ord_saccharomycetales_taxonomic_revisions (affected_family_id); CREATE TABLE ord_saccharomycetales_conservation_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, national_redlist_category TEXT, habitat_pressure_text TEXT, last_assessment_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_saccharomycetales_conservation_status_species_id ON ord_saccharomycetales_conservation_status (species_id); CREATE INDEX ix_ord_saccharomycetales_conservation_status_country_id ON ord_saccharomycetales_conservation_status (country_id); CREATE TABLE ord_saccharomycetales_diagnostic_keys ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER, key_title TEXT NOT NULL, region_country_id INTEGER, n_taxa_covered INTEGER, key_format TEXT, includes_microscopy INTEGER NOT NULL DEFAULT 0, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_saccharomycetales_diagnostic_keys_publication_id ON ord_saccharomycetales_diagnostic_keys (publication_id); CREATE INDEX ix_ord_saccharomycetales_diagnostic_keys_region_country_id ON ord_saccharomycetales_diagnostic_keys (region_country_id); CREATE TABLE ord_saccharomycetales_type_species_register ( id INTEGER PRIMARY KEY AUTOINCREMENT, focal_genus_id INTEGER NOT NULL, type_species_id INTEGER, designation_publication_id INTEGER, designation_year INTEGER, designated_by_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (designation_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_saccharomycetales_type_species_register_0 ON ord_saccharomycetales_type_species_register (focal_genus_id); CREATE INDEX ix_ord_saccharomycetales_type_species_register_1 ON ord_saccharomycetales_type_species_register (type_species_id); CREATE TABLE ord_saccharomycetales_distribution_grids ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, grid_cell_code TEXT NOT NULL, centroid_lat REAL, centroid_lon REAL, record_count INTEGER, first_record_year INTEGER, most_recent_record_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_saccharomycetales_distribution_grids_species_id ON ord_saccharomycetales_distribution_grids (species_id); CREATE INDEX ix_ord_saccharomycetales_distribution_grids_country_id ON ord_saccharomycetales_distribution_grids (country_id); CREATE TABLE ord_saccharomycetales_microclimate_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER, publication_id INTEGER, substrate_temperature_c REAL, substrate_moisture_pct REAL, canopy_closure_pct REAL, photosynthetic_par_umol_m2_s REAL, days_post_rainfall INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_saccharomycetales_microclimate_studies_species_id ON ord_saccharomycetales_microclimate_studies (species_id); CREATE INDEX ix_ord_saccharomycetales_microclimate_studies_publication_id ON ord_saccharomycetales_microclimate_studies (publication_id); CREATE TABLE ord_saccharomycetales_dna_barcoding_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, its_sequenced INTEGER NOT NULL DEFAULT 0, lsu_sequenced INTEGER NOT NULL DEFAULT 0, rpb2_sequenced INTEGER NOT NULL DEFAULT 0, ef1a_sequenced INTEGER NOT NULL DEFAULT 0, genome_assembled INTEGER NOT NULL DEFAULT 0, priority_for_sequencing_score INTEGER CHECK (priority_for_sequencing_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_saccharomycetales_dna_barcoding_status_species_id ON ord_saccharomycetales_dna_barcoding_status (species_id); CREATE TABLE ord_saccharomycetales_spore_print_data ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, specimen_id INTEGER, print_color_label TEXT, print_color_chip_id INTEGER, spore_density_per_mm2 REAL, collection_substrate TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (print_color_chip_id) REFERENCES mor_color_chips (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_saccharomycetales_spore_print_data_species_id ON ord_saccharomycetales_spore_print_data (species_id); CREATE INDEX ix_ord_saccharomycetales_spore_print_data_specimen_id ON ord_saccharomycetales_spore_print_data (specimen_id); CREATE TABLE ord_saccharomycetales_mating_systems ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, system_type TEXT, mating_loci_count INTEGER, publication_id INTEGER, notes_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_saccharomycetales_mating_systems_species_id ON ord_saccharomycetales_mating_systems (species_id); CREATE INDEX ix_ord_saccharomycetales_mating_systems_publication_id ON ord_saccharomycetales_mating_systems (publication_id); CREATE TABLE ord_saccharomycetales_nutrient_uptake_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, nitrogen_source TEXT, carbon_source TEXT, growth_response TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_saccharomycetales_nutrient_uptake_studies_species_id ON ord_saccharomycetales_nutrient_uptake_studies (species_id); CREATE INDEX ix_ord_saccharomycetales_nutrient_uptake_studies_strain_id ON ord_saccharomycetales_nutrient_uptake_studies (strain_id); CREATE TABLE ord_saccharomycetales_range_maps ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, polygon_file_uri TEXT NOT NULL, source_methodology TEXT, area_km2 REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_saccharomycetales_range_maps_species_id ON ord_saccharomycetales_range_maps (species_id); CREATE INDEX ix_ord_saccharomycetales_range_maps_publication_id ON ord_saccharomycetales_range_maps (publication_id); CREATE TABLE ord_saccharomycetales_abundance_estimates ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, estimate_kind TEXT, value_min REAL, value_max REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_saccharomycetales_abundance_estimates_species_id ON ord_saccharomycetales_abundance_estimates (species_id); CREATE INDEX ix_ord_saccharomycetales_abundance_estimates_country_id ON ord_saccharomycetales_abundance_estimates (country_id); CREATE TABLE ord_saccharomycetales_toxin_profiles ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, presence TEXT, typical_concentration_mg_per_kg REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_saccharomycetales_toxin_profiles_species_id ON ord_saccharomycetales_toxin_profiles (species_id); CREATE INDEX ix_ord_saccharomycetales_toxin_profiles_compound_id ON ord_saccharomycetales_toxin_profiles (compound_id); CREATE TABLE ord_saccharomycetales_enzyme_activity_assays ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, enzyme_id INTEGER NOT NULL, strain_id INTEGER, activity_u_per_mg REAL, temperature_c REAL, ph REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (enzyme_id) REFERENCES bio_enzymes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_saccharomycetales_enzyme_activity_assays_species_id ON ord_saccharomycetales_enzyme_activity_assays (species_id); CREATE INDEX ix_ord_saccharomycetales_enzyme_activity_assays_enzyme_id ON ord_saccharomycetales_enzyme_activity_assays (enzyme_id); CREATE TABLE ord_saccharomycetales_biocontrol_evaluations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, target_pest_text TEXT NOT NULL, efficacy_pct REAL, trial_setting TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_saccharomycetales_biocontrol_evaluations_species_id ON ord_saccharomycetales_biocontrol_evaluations (species_id); CREATE INDEX ix_ord_saccharomycetales_biocontrol_evaluations_1 ON ord_saccharomycetales_biocontrol_evaluations (publication_id); CREATE TABLE ord_saccharomycetales_regional_checklists ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, checklist_publication_id INTEGER, status TEXT, checklist_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (checklist_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_saccharomycetales_regional_checklists_species_id ON ord_saccharomycetales_regional_checklists (species_id); CREATE INDEX ix_ord_saccharomycetales_regional_checklists_country_id ON ord_saccharomycetales_regional_checklists (country_id); CREATE TABLE ord_schizosaccharomycetales_morphology ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, hymenium_color_at_maturity TEXT, context_color_at_maturity TEXT, characteristic_microstructure TEXT, diagnostic_features_text TEXT, notes_kohler_reaction TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_schizosaccharomycetales_morphology_specimen_id ON ord_schizosaccharomycetales_morphology (specimen_id); CREATE INDEX ix_ord_schizosaccharomycetales_morphology_species_id ON ord_schizosaccharomycetales_morphology (species_id); CREATE TABLE ord_schizosaccharomycetales_ecology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, dominant_habitat_id INTEGER, dominant_substrate_id INTEGER, dominant_biome_id INTEGER, trophic_strategy TEXT, typical_fruiting_period TEXT, known_distribution_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_habitat_id) REFERENCES eco_habitat_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_substrate_id) REFERENCES eco_substrate_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_biome_id) REFERENCES geo_biomes (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_schizosaccharomycetales_ecology_species_id ON ord_schizosaccharomycetales_ecology (species_id); CREATE INDEX ix_ord_schizosaccharomycetales_ecology_dominant_habitat_id ON ord_schizosaccharomycetales_ecology (dominant_habitat_id); CREATE TABLE ord_schizosaccharomycetales_phenology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, season_name TEXT, region_country_id INTEGER, first_doy INTEGER, peak_doy INTEGER, last_doy INTEGER, years_observed INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_schizosaccharomycetales_phenology_species_id ON ord_schizosaccharomycetales_phenology (species_id); CREATE INDEX ix_ord_schizosaccharomycetales_phenology_region_country_id ON ord_schizosaccharomycetales_phenology (region_country_id); CREATE TABLE ord_schizosaccharomycetales_host_associations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, association_type TEXT, specificity TEXT, evidence_publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (evidence_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_schizosaccharomycetales_host_associations_species_id ON ord_schizosaccharomycetales_host_associations (species_id); CREATE INDEX ix_ord_schizosaccharomycetales_host_associations_host_id ON ord_schizosaccharomycetales_host_associations (host_id); CREATE TABLE ord_schizosaccharomycetales_substrate_preferences ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, substrate_id INTEGER NOT NULL, preference_score REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (substrate_id) REFERENCES eco_substrate_types (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_schizosaccharomycetales_substrate_preferences_0 ON ord_schizosaccharomycetales_substrate_preferences (species_id); CREATE INDEX ix_ord_schizosaccharomycetales_substrate_preferences_1 ON ord_schizosaccharomycetales_substrate_preferences (substrate_id); CREATE TABLE ord_schizosaccharomycetales_geographic_distribution ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, occurrence_status TEXT, first_record_year INTEGER, record_count INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_schizosaccharomycetales_geographic_distribution_0 ON ord_schizosaccharomycetales_geographic_distribution (species_id); CREATE INDEX ix_ord_schizosaccharomycetales_geographic_distribution_1 ON ord_schizosaccharomycetales_geographic_distribution (country_id); CREATE TABLE ord_schizosaccharomycetales_phylogeny ( id INTEGER PRIMARY KEY AUTOINCREMENT, tree_id INTEGER NOT NULL, focal_genus_id INTEGER, publication_id INTEGER, notes_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (tree_id) REFERENCES phy_trees (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_schizosaccharomycetales_phylogeny_tree_id ON ord_schizosaccharomycetales_phylogeny (tree_id); CREATE INDEX ix_ord_schizosaccharomycetales_phylogeny_focal_genus_id ON ord_schizosaccharomycetales_phylogeny (focal_genus_id); CREATE TABLE ord_schizosaccharomycetales_genomics ( id INTEGER PRIMARY KEY AUTOINCREMENT, assembly_id INTEGER NOT NULL, species_id INTEGER, avg_genome_size_mb REAL, avg_gene_count INTEGER, avg_busco_complete_pct REAL, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (assembly_id) REFERENCES gen_assemblies (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_schizosaccharomycetales_genomics_assembly_id ON ord_schizosaccharomycetales_genomics (assembly_id); CREATE INDEX ix_ord_schizosaccharomycetales_genomics_species_id ON ord_schizosaccharomycetales_genomics (species_id); CREATE TABLE ord_schizosaccharomycetales_biochemistry ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, typicality TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_schizosaccharomycetales_biochemistry_species_id ON ord_schizosaccharomycetales_biochemistry (species_id); CREATE INDEX ix_ord_schizosaccharomycetales_biochemistry_compound_id ON ord_schizosaccharomycetales_biochemistry (compound_id); CREATE TABLE ord_schizosaccharomycetales_cultivation_notes ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, typical_growth_rate_mm_per_day REAL, preferred_media_type_id INTEGER, optimal_temperature_c REAL, difficulty_score INTEGER CHECK (difficulty_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (preferred_media_type_id) REFERENCES cul_media_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_schizosaccharomycetales_cultivation_notes_species_id ON ord_schizosaccharomycetales_cultivation_notes (species_id); CREATE INDEX ix_ord_schizosaccharomycetales_cultivation_notes_strain_id ON ord_schizosaccharomycetales_cultivation_notes (strain_id); CREATE TABLE ord_schizosaccharomycetales_pathogenicity ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, disease_id INTEGER, severity_score INTEGER CHECK (severity_score BETWEEN 1 AND 5), publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (disease_id) REFERENCES pat_diseases (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_schizosaccharomycetales_pathogenicity_species_id ON ord_schizosaccharomycetales_pathogenicity (species_id); CREATE INDEX ix_ord_schizosaccharomycetales_pathogenicity_host_id ON ord_schizosaccharomycetales_pathogenicity (host_id); CREATE TABLE ord_schizosaccharomycetales_edibility ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, edibility_class TEXT, preparation_notes TEXT, regional_tradition_country_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (regional_tradition_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_schizosaccharomycetales_edibility_species_id ON ord_schizosaccharomycetales_edibility (species_id); CREATE INDEX ix_ord_schizosaccharomycetales_edibility_1 ON ord_schizosaccharomycetales_edibility (regional_tradition_country_id); CREATE TABLE ord_schizosaccharomycetales_medicinal_uses ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, traditional_use_text TEXT, modern_evidence_level TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_schizosaccharomycetales_medicinal_uses_species_id ON ord_schizosaccharomycetales_medicinal_uses (species_id); CREATE INDEX ix_ord_schizosaccharomycetales_medicinal_uses_publication_id ON ord_schizosaccharomycetales_medicinal_uses (publication_id); CREATE TABLE ord_schizosaccharomycetales_taxonomic_revisions ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER NOT NULL, affected_family_id INTEGER, affected_genus_id INTEGER, revision_summary TEXT, revision_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_family_id) REFERENCES tax_families (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_schizosaccharomycetales_taxonomic_revisions_0 ON ord_schizosaccharomycetales_taxonomic_revisions (publication_id); CREATE INDEX ix_ord_schizosaccharomycetales_taxonomic_revisions_1 ON ord_schizosaccharomycetales_taxonomic_revisions (affected_family_id); CREATE TABLE ord_schizosaccharomycetales_conservation_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, national_redlist_category TEXT, habitat_pressure_text TEXT, last_assessment_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_schizosaccharomycetales_conservation_status_0 ON ord_schizosaccharomycetales_conservation_status (species_id); CREATE INDEX ix_ord_schizosaccharomycetales_conservation_status_1 ON ord_schizosaccharomycetales_conservation_status (country_id); CREATE TABLE ord_schizosaccharomycetales_diagnostic_keys ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER, key_title TEXT NOT NULL, region_country_id INTEGER, n_taxa_covered INTEGER, key_format TEXT, includes_microscopy INTEGER NOT NULL DEFAULT 0, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_schizosaccharomycetales_diagnostic_keys_0 ON ord_schizosaccharomycetales_diagnostic_keys (publication_id); CREATE INDEX ix_ord_schizosaccharomycetales_diagnostic_keys_1 ON ord_schizosaccharomycetales_diagnostic_keys (region_country_id); CREATE TABLE ord_schizosaccharomycetales_type_species_register ( id INTEGER PRIMARY KEY AUTOINCREMENT, focal_genus_id INTEGER NOT NULL, type_species_id INTEGER, designation_publication_id INTEGER, designation_year INTEGER, designated_by_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (designation_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_schizosaccharomycetales_type_species_register_0 ON ord_schizosaccharomycetales_type_species_register (focal_genus_id); CREATE INDEX ix_ord_schizosaccharomycetales_type_species_register_1 ON ord_schizosaccharomycetales_type_species_register (type_species_id); CREATE TABLE ord_schizosaccharomycetales_distribution_grids ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, grid_cell_code TEXT NOT NULL, centroid_lat REAL, centroid_lon REAL, record_count INTEGER, first_record_year INTEGER, most_recent_record_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_schizosaccharomycetales_distribution_grids_species_id ON ord_schizosaccharomycetales_distribution_grids (species_id); CREATE INDEX ix_ord_schizosaccharomycetales_distribution_grids_country_id ON ord_schizosaccharomycetales_distribution_grids (country_id); CREATE TABLE ord_schizosaccharomycetales_microclimate_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER, publication_id INTEGER, substrate_temperature_c REAL, substrate_moisture_pct REAL, canopy_closure_pct REAL, photosynthetic_par_umol_m2_s REAL, days_post_rainfall INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_schizosaccharomycetales_microclimate_studies_0 ON ord_schizosaccharomycetales_microclimate_studies (species_id); CREATE INDEX ix_ord_schizosaccharomycetales_microclimate_studies_1 ON ord_schizosaccharomycetales_microclimate_studies (publication_id); CREATE TABLE ord_schizosaccharomycetales_dna_barcoding_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, its_sequenced INTEGER NOT NULL DEFAULT 0, lsu_sequenced INTEGER NOT NULL DEFAULT 0, rpb2_sequenced INTEGER NOT NULL DEFAULT 0, ef1a_sequenced INTEGER NOT NULL DEFAULT 0, genome_assembled INTEGER NOT NULL DEFAULT 0, priority_for_sequencing_score INTEGER CHECK (priority_for_sequencing_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_schizosaccharomycetales_dna_barcoding_status_0 ON ord_schizosaccharomycetales_dna_barcoding_status (species_id); CREATE TABLE ord_schizosaccharomycetales_spore_print_data ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, specimen_id INTEGER, print_color_label TEXT, print_color_chip_id INTEGER, spore_density_per_mm2 REAL, collection_substrate TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (print_color_chip_id) REFERENCES mor_color_chips (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_schizosaccharomycetales_spore_print_data_species_id ON ord_schizosaccharomycetales_spore_print_data (species_id); CREATE INDEX ix_ord_schizosaccharomycetales_spore_print_data_specimen_id ON ord_schizosaccharomycetales_spore_print_data (specimen_id); CREATE TABLE ord_schizosaccharomycetales_mating_systems ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, system_type TEXT, mating_loci_count INTEGER, publication_id INTEGER, notes_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_schizosaccharomycetales_mating_systems_species_id ON ord_schizosaccharomycetales_mating_systems (species_id); CREATE INDEX ix_ord_schizosaccharomycetales_mating_systems_publication_id ON ord_schizosaccharomycetales_mating_systems (publication_id); CREATE TABLE ord_schizosaccharomycetales_nutrient_uptake_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, nitrogen_source TEXT, carbon_source TEXT, growth_response TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_schizosaccharomycetales_nutrient_uptake_studies_0 ON ord_schizosaccharomycetales_nutrient_uptake_studies (species_id); CREATE INDEX ix_ord_schizosaccharomycetales_nutrient_uptake_studies_1 ON ord_schizosaccharomycetales_nutrient_uptake_studies (strain_id); CREATE TABLE ord_schizosaccharomycetales_range_maps ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, polygon_file_uri TEXT NOT NULL, source_methodology TEXT, area_km2 REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_schizosaccharomycetales_range_maps_species_id ON ord_schizosaccharomycetales_range_maps (species_id); CREATE INDEX ix_ord_schizosaccharomycetales_range_maps_publication_id ON ord_schizosaccharomycetales_range_maps (publication_id); CREATE TABLE ord_schizosaccharomycetales_abundance_estimates ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, estimate_kind TEXT, value_min REAL, value_max REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_schizosaccharomycetales_abundance_estimates_0 ON ord_schizosaccharomycetales_abundance_estimates (species_id); CREATE INDEX ix_ord_schizosaccharomycetales_abundance_estimates_1 ON ord_schizosaccharomycetales_abundance_estimates (country_id); CREATE TABLE ord_schizosaccharomycetales_toxin_profiles ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, presence TEXT, typical_concentration_mg_per_kg REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_schizosaccharomycetales_toxin_profiles_species_id ON ord_schizosaccharomycetales_toxin_profiles (species_id); CREATE INDEX ix_ord_schizosaccharomycetales_toxin_profiles_compound_id ON ord_schizosaccharomycetales_toxin_profiles (compound_id); CREATE TABLE ord_schizosaccharomycetales_enzyme_activity_assays ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, enzyme_id INTEGER NOT NULL, strain_id INTEGER, activity_u_per_mg REAL, temperature_c REAL, ph REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (enzyme_id) REFERENCES bio_enzymes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_schizosaccharomycetales_enzyme_activity_assays_0 ON ord_schizosaccharomycetales_enzyme_activity_assays (species_id); CREATE INDEX ix_ord_schizosaccharomycetales_enzyme_activity_assays_1 ON ord_schizosaccharomycetales_enzyme_activity_assays (enzyme_id); CREATE TABLE ord_schizosaccharomycetales_biocontrol_evaluations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, target_pest_text TEXT NOT NULL, efficacy_pct REAL, trial_setting TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_schizosaccharomycetales_biocontrol_evaluations_0 ON ord_schizosaccharomycetales_biocontrol_evaluations (species_id); CREATE INDEX ix_ord_schizosaccharomycetales_biocontrol_evaluations_1 ON ord_schizosaccharomycetales_biocontrol_evaluations (publication_id); CREATE TABLE ord_schizosaccharomycetales_regional_checklists ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, checklist_publication_id INTEGER, status TEXT, checklist_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (checklist_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_schizosaccharomycetales_regional_checklists_0 ON ord_schizosaccharomycetales_regional_checklists (species_id); CREATE INDEX ix_ord_schizosaccharomycetales_regional_checklists_1 ON ord_schizosaccharomycetales_regional_checklists (country_id); CREATE TABLE ord_taphrinales_morphology ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, hymenium_color_at_maturity TEXT, context_color_at_maturity TEXT, characteristic_microstructure TEXT, diagnostic_features_text TEXT, notes_kohler_reaction TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_taphrinales_morphology_specimen_id ON ord_taphrinales_morphology (specimen_id); CREATE INDEX ix_ord_taphrinales_morphology_species_id ON ord_taphrinales_morphology (species_id); CREATE TABLE ord_taphrinales_ecology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, dominant_habitat_id INTEGER, dominant_substrate_id INTEGER, dominant_biome_id INTEGER, trophic_strategy TEXT, typical_fruiting_period TEXT, known_distribution_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_habitat_id) REFERENCES eco_habitat_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_substrate_id) REFERENCES eco_substrate_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_biome_id) REFERENCES geo_biomes (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_taphrinales_ecology_species_id ON ord_taphrinales_ecology (species_id); CREATE INDEX ix_ord_taphrinales_ecology_dominant_habitat_id ON ord_taphrinales_ecology (dominant_habitat_id); CREATE TABLE ord_taphrinales_phenology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, season_name TEXT, region_country_id INTEGER, first_doy INTEGER, peak_doy INTEGER, last_doy INTEGER, years_observed INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_taphrinales_phenology_species_id ON ord_taphrinales_phenology (species_id); CREATE INDEX ix_ord_taphrinales_phenology_region_country_id ON ord_taphrinales_phenology (region_country_id); CREATE TABLE ord_taphrinales_host_associations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, association_type TEXT, specificity TEXT, evidence_publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (evidence_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_taphrinales_host_associations_species_id ON ord_taphrinales_host_associations (species_id); CREATE INDEX ix_ord_taphrinales_host_associations_host_id ON ord_taphrinales_host_associations (host_id); CREATE TABLE ord_taphrinales_substrate_preferences ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, substrate_id INTEGER NOT NULL, preference_score REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (substrate_id) REFERENCES eco_substrate_types (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_taphrinales_substrate_preferences_species_id ON ord_taphrinales_substrate_preferences (species_id); CREATE INDEX ix_ord_taphrinales_substrate_preferences_substrate_id ON ord_taphrinales_substrate_preferences (substrate_id); CREATE TABLE ord_taphrinales_geographic_distribution ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, occurrence_status TEXT, first_record_year INTEGER, record_count INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_taphrinales_geographic_distribution_species_id ON ord_taphrinales_geographic_distribution (species_id); CREATE INDEX ix_ord_taphrinales_geographic_distribution_country_id ON ord_taphrinales_geographic_distribution (country_id); CREATE TABLE ord_taphrinales_phylogeny ( id INTEGER PRIMARY KEY AUTOINCREMENT, tree_id INTEGER NOT NULL, focal_genus_id INTEGER, publication_id INTEGER, notes_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (tree_id) REFERENCES phy_trees (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_taphrinales_phylogeny_tree_id ON ord_taphrinales_phylogeny (tree_id); CREATE INDEX ix_ord_taphrinales_phylogeny_focal_genus_id ON ord_taphrinales_phylogeny (focal_genus_id); CREATE TABLE ord_taphrinales_genomics ( id INTEGER PRIMARY KEY AUTOINCREMENT, assembly_id INTEGER NOT NULL, species_id INTEGER, avg_genome_size_mb REAL, avg_gene_count INTEGER, avg_busco_complete_pct REAL, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (assembly_id) REFERENCES gen_assemblies (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_taphrinales_genomics_assembly_id ON ord_taphrinales_genomics (assembly_id); CREATE INDEX ix_ord_taphrinales_genomics_species_id ON ord_taphrinales_genomics (species_id); CREATE TABLE ord_taphrinales_biochemistry ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, typicality TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_taphrinales_biochemistry_species_id ON ord_taphrinales_biochemistry (species_id); CREATE INDEX ix_ord_taphrinales_biochemistry_compound_id ON ord_taphrinales_biochemistry (compound_id); CREATE TABLE ord_taphrinales_cultivation_notes ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, typical_growth_rate_mm_per_day REAL, preferred_media_type_id INTEGER, optimal_temperature_c REAL, difficulty_score INTEGER CHECK (difficulty_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (preferred_media_type_id) REFERENCES cul_media_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_taphrinales_cultivation_notes_species_id ON ord_taphrinales_cultivation_notes (species_id); CREATE INDEX ix_ord_taphrinales_cultivation_notes_strain_id ON ord_taphrinales_cultivation_notes (strain_id); CREATE TABLE ord_taphrinales_pathogenicity ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, disease_id INTEGER, severity_score INTEGER CHECK (severity_score BETWEEN 1 AND 5), publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (disease_id) REFERENCES pat_diseases (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_taphrinales_pathogenicity_species_id ON ord_taphrinales_pathogenicity (species_id); CREATE INDEX ix_ord_taphrinales_pathogenicity_host_id ON ord_taphrinales_pathogenicity (host_id); CREATE TABLE ord_taphrinales_edibility ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, edibility_class TEXT, preparation_notes TEXT, regional_tradition_country_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (regional_tradition_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_taphrinales_edibility_species_id ON ord_taphrinales_edibility (species_id); CREATE INDEX ix_ord_taphrinales_edibility_regional_tradition_country_id ON ord_taphrinales_edibility (regional_tradition_country_id); CREATE TABLE ord_taphrinales_medicinal_uses ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, traditional_use_text TEXT, modern_evidence_level TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_taphrinales_medicinal_uses_species_id ON ord_taphrinales_medicinal_uses (species_id); CREATE INDEX ix_ord_taphrinales_medicinal_uses_publication_id ON ord_taphrinales_medicinal_uses (publication_id); CREATE TABLE ord_taphrinales_taxonomic_revisions ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER NOT NULL, affected_family_id INTEGER, affected_genus_id INTEGER, revision_summary TEXT, revision_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_family_id) REFERENCES tax_families (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_taphrinales_taxonomic_revisions_publication_id ON ord_taphrinales_taxonomic_revisions (publication_id); CREATE INDEX ix_ord_taphrinales_taxonomic_revisions_affected_family_id ON ord_taphrinales_taxonomic_revisions (affected_family_id); CREATE TABLE ord_taphrinales_conservation_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, national_redlist_category TEXT, habitat_pressure_text TEXT, last_assessment_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_taphrinales_conservation_status_species_id ON ord_taphrinales_conservation_status (species_id); CREATE INDEX ix_ord_taphrinales_conservation_status_country_id ON ord_taphrinales_conservation_status (country_id); CREATE TABLE ord_taphrinales_diagnostic_keys ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER, key_title TEXT NOT NULL, region_country_id INTEGER, n_taxa_covered INTEGER, key_format TEXT, includes_microscopy INTEGER NOT NULL DEFAULT 0, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_taphrinales_diagnostic_keys_publication_id ON ord_taphrinales_diagnostic_keys (publication_id); CREATE INDEX ix_ord_taphrinales_diagnostic_keys_region_country_id ON ord_taphrinales_diagnostic_keys (region_country_id); CREATE TABLE ord_taphrinales_type_species_register ( id INTEGER PRIMARY KEY AUTOINCREMENT, focal_genus_id INTEGER NOT NULL, type_species_id INTEGER, designation_publication_id INTEGER, designation_year INTEGER, designated_by_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (designation_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_taphrinales_type_species_register_focal_genus_id ON ord_taphrinales_type_species_register (focal_genus_id); CREATE INDEX ix_ord_taphrinales_type_species_register_type_species_id ON ord_taphrinales_type_species_register (type_species_id); CREATE TABLE ord_taphrinales_distribution_grids ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, grid_cell_code TEXT NOT NULL, centroid_lat REAL, centroid_lon REAL, record_count INTEGER, first_record_year INTEGER, most_recent_record_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_taphrinales_distribution_grids_species_id ON ord_taphrinales_distribution_grids (species_id); CREATE INDEX ix_ord_taphrinales_distribution_grids_country_id ON ord_taphrinales_distribution_grids (country_id); CREATE TABLE ord_taphrinales_microclimate_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER, publication_id INTEGER, substrate_temperature_c REAL, substrate_moisture_pct REAL, canopy_closure_pct REAL, photosynthetic_par_umol_m2_s REAL, days_post_rainfall INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_taphrinales_microclimate_studies_species_id ON ord_taphrinales_microclimate_studies (species_id); CREATE INDEX ix_ord_taphrinales_microclimate_studies_publication_id ON ord_taphrinales_microclimate_studies (publication_id); CREATE TABLE ord_taphrinales_dna_barcoding_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, its_sequenced INTEGER NOT NULL DEFAULT 0, lsu_sequenced INTEGER NOT NULL DEFAULT 0, rpb2_sequenced INTEGER NOT NULL DEFAULT 0, ef1a_sequenced INTEGER NOT NULL DEFAULT 0, genome_assembled INTEGER NOT NULL DEFAULT 0, priority_for_sequencing_score INTEGER CHECK (priority_for_sequencing_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_taphrinales_dna_barcoding_status_species_id ON ord_taphrinales_dna_barcoding_status (species_id); CREATE TABLE ord_taphrinales_spore_print_data ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, specimen_id INTEGER, print_color_label TEXT, print_color_chip_id INTEGER, spore_density_per_mm2 REAL, collection_substrate TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (print_color_chip_id) REFERENCES mor_color_chips (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_taphrinales_spore_print_data_species_id ON ord_taphrinales_spore_print_data (species_id); CREATE INDEX ix_ord_taphrinales_spore_print_data_specimen_id ON ord_taphrinales_spore_print_data (specimen_id); CREATE TABLE ord_taphrinales_mating_systems ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, system_type TEXT, mating_loci_count INTEGER, publication_id INTEGER, notes_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_taphrinales_mating_systems_species_id ON ord_taphrinales_mating_systems (species_id); CREATE INDEX ix_ord_taphrinales_mating_systems_publication_id ON ord_taphrinales_mating_systems (publication_id); CREATE TABLE ord_taphrinales_nutrient_uptake_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, nitrogen_source TEXT, carbon_source TEXT, growth_response TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_taphrinales_nutrient_uptake_studies_species_id ON ord_taphrinales_nutrient_uptake_studies (species_id); CREATE INDEX ix_ord_taphrinales_nutrient_uptake_studies_strain_id ON ord_taphrinales_nutrient_uptake_studies (strain_id); CREATE TABLE ord_taphrinales_range_maps ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, polygon_file_uri TEXT NOT NULL, source_methodology TEXT, area_km2 REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_taphrinales_range_maps_species_id ON ord_taphrinales_range_maps (species_id); CREATE INDEX ix_ord_taphrinales_range_maps_publication_id ON ord_taphrinales_range_maps (publication_id); CREATE TABLE ord_taphrinales_abundance_estimates ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, estimate_kind TEXT, value_min REAL, value_max REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_taphrinales_abundance_estimates_species_id ON ord_taphrinales_abundance_estimates (species_id); CREATE INDEX ix_ord_taphrinales_abundance_estimates_country_id ON ord_taphrinales_abundance_estimates (country_id); CREATE TABLE ord_taphrinales_toxin_profiles ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, presence TEXT, typical_concentration_mg_per_kg REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_taphrinales_toxin_profiles_species_id ON ord_taphrinales_toxin_profiles (species_id); CREATE INDEX ix_ord_taphrinales_toxin_profiles_compound_id ON ord_taphrinales_toxin_profiles (compound_id); CREATE TABLE ord_taphrinales_enzyme_activity_assays ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, enzyme_id INTEGER NOT NULL, strain_id INTEGER, activity_u_per_mg REAL, temperature_c REAL, ph REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (enzyme_id) REFERENCES bio_enzymes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_taphrinales_enzyme_activity_assays_species_id ON ord_taphrinales_enzyme_activity_assays (species_id); CREATE INDEX ix_ord_taphrinales_enzyme_activity_assays_enzyme_id ON ord_taphrinales_enzyme_activity_assays (enzyme_id); CREATE TABLE ord_taphrinales_biocontrol_evaluations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, target_pest_text TEXT NOT NULL, efficacy_pct REAL, trial_setting TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_taphrinales_biocontrol_evaluations_species_id ON ord_taphrinales_biocontrol_evaluations (species_id); CREATE INDEX ix_ord_taphrinales_biocontrol_evaluations_publication_id ON ord_taphrinales_biocontrol_evaluations (publication_id); CREATE TABLE ord_taphrinales_regional_checklists ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, checklist_publication_id INTEGER, status TEXT, checklist_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (checklist_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_taphrinales_regional_checklists_species_id ON ord_taphrinales_regional_checklists (species_id); CREATE INDEX ix_ord_taphrinales_regional_checklists_country_id ON ord_taphrinales_regional_checklists (country_id); CREATE TABLE ord_pezizales_morphology ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, hymenium_color_at_maturity TEXT, context_color_at_maturity TEXT, characteristic_microstructure TEXT, diagnostic_features_text TEXT, notes_kohler_reaction TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pezizales_morphology_specimen_id ON ord_pezizales_morphology (specimen_id); CREATE INDEX ix_ord_pezizales_morphology_species_id ON ord_pezizales_morphology (species_id); CREATE TABLE ord_pezizales_ecology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, dominant_habitat_id INTEGER, dominant_substrate_id INTEGER, dominant_biome_id INTEGER, trophic_strategy TEXT, typical_fruiting_period TEXT, known_distribution_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_habitat_id) REFERENCES eco_habitat_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_substrate_id) REFERENCES eco_substrate_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_biome_id) REFERENCES geo_biomes (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pezizales_ecology_species_id ON ord_pezizales_ecology (species_id); CREATE INDEX ix_ord_pezizales_ecology_dominant_habitat_id ON ord_pezizales_ecology (dominant_habitat_id); CREATE TABLE ord_pezizales_phenology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, season_name TEXT, region_country_id INTEGER, first_doy INTEGER, peak_doy INTEGER, last_doy INTEGER, years_observed INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pezizales_phenology_species_id ON ord_pezizales_phenology (species_id); CREATE INDEX ix_ord_pezizales_phenology_region_country_id ON ord_pezizales_phenology (region_country_id); CREATE TABLE ord_pezizales_host_associations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, association_type TEXT, specificity TEXT, evidence_publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (evidence_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pezizales_host_associations_species_id ON ord_pezizales_host_associations (species_id); CREATE INDEX ix_ord_pezizales_host_associations_host_id ON ord_pezizales_host_associations (host_id); CREATE TABLE ord_pezizales_substrate_preferences ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, substrate_id INTEGER NOT NULL, preference_score REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (substrate_id) REFERENCES eco_substrate_types (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pezizales_substrate_preferences_species_id ON ord_pezizales_substrate_preferences (species_id); CREATE INDEX ix_ord_pezizales_substrate_preferences_substrate_id ON ord_pezizales_substrate_preferences (substrate_id); CREATE TABLE ord_pezizales_geographic_distribution ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, occurrence_status TEXT, first_record_year INTEGER, record_count INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pezizales_geographic_distribution_species_id ON ord_pezizales_geographic_distribution (species_id); CREATE INDEX ix_ord_pezizales_geographic_distribution_country_id ON ord_pezizales_geographic_distribution (country_id); CREATE TABLE ord_pezizales_phylogeny ( id INTEGER PRIMARY KEY AUTOINCREMENT, tree_id INTEGER NOT NULL, focal_genus_id INTEGER, publication_id INTEGER, notes_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (tree_id) REFERENCES phy_trees (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pezizales_phylogeny_tree_id ON ord_pezizales_phylogeny (tree_id); CREATE INDEX ix_ord_pezizales_phylogeny_focal_genus_id ON ord_pezizales_phylogeny (focal_genus_id); CREATE TABLE ord_pezizales_genomics ( id INTEGER PRIMARY KEY AUTOINCREMENT, assembly_id INTEGER NOT NULL, species_id INTEGER, avg_genome_size_mb REAL, avg_gene_count INTEGER, avg_busco_complete_pct REAL, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (assembly_id) REFERENCES gen_assemblies (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pezizales_genomics_assembly_id ON ord_pezizales_genomics (assembly_id); CREATE INDEX ix_ord_pezizales_genomics_species_id ON ord_pezizales_genomics (species_id); CREATE TABLE ord_pezizales_biochemistry ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, typicality TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pezizales_biochemistry_species_id ON ord_pezizales_biochemistry (species_id); CREATE INDEX ix_ord_pezizales_biochemistry_compound_id ON ord_pezizales_biochemistry (compound_id); CREATE TABLE ord_pezizales_cultivation_notes ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, typical_growth_rate_mm_per_day REAL, preferred_media_type_id INTEGER, optimal_temperature_c REAL, difficulty_score INTEGER CHECK (difficulty_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (preferred_media_type_id) REFERENCES cul_media_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pezizales_cultivation_notes_species_id ON ord_pezizales_cultivation_notes (species_id); CREATE INDEX ix_ord_pezizales_cultivation_notes_strain_id ON ord_pezizales_cultivation_notes (strain_id); CREATE TABLE ord_pezizales_pathogenicity ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, disease_id INTEGER, severity_score INTEGER CHECK (severity_score BETWEEN 1 AND 5), publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (disease_id) REFERENCES pat_diseases (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pezizales_pathogenicity_species_id ON ord_pezizales_pathogenicity (species_id); CREATE INDEX ix_ord_pezizales_pathogenicity_host_id ON ord_pezizales_pathogenicity (host_id); CREATE TABLE ord_pezizales_edibility ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, edibility_class TEXT, preparation_notes TEXT, regional_tradition_country_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (regional_tradition_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pezizales_edibility_species_id ON ord_pezizales_edibility (species_id); CREATE INDEX ix_ord_pezizales_edibility_regional_tradition_country_id ON ord_pezizales_edibility (regional_tradition_country_id); CREATE TABLE ord_pezizales_medicinal_uses ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, traditional_use_text TEXT, modern_evidence_level TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pezizales_medicinal_uses_species_id ON ord_pezizales_medicinal_uses (species_id); CREATE INDEX ix_ord_pezizales_medicinal_uses_publication_id ON ord_pezizales_medicinal_uses (publication_id); CREATE TABLE ord_pezizales_taxonomic_revisions ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER NOT NULL, affected_family_id INTEGER, affected_genus_id INTEGER, revision_summary TEXT, revision_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_family_id) REFERENCES tax_families (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pezizales_taxonomic_revisions_publication_id ON ord_pezizales_taxonomic_revisions (publication_id); CREATE INDEX ix_ord_pezizales_taxonomic_revisions_affected_family_id ON ord_pezizales_taxonomic_revisions (affected_family_id); CREATE TABLE ord_pezizales_conservation_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, national_redlist_category TEXT, habitat_pressure_text TEXT, last_assessment_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pezizales_conservation_status_species_id ON ord_pezizales_conservation_status (species_id); CREATE INDEX ix_ord_pezizales_conservation_status_country_id ON ord_pezizales_conservation_status (country_id); CREATE TABLE ord_pezizales_diagnostic_keys ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER, key_title TEXT NOT NULL, region_country_id INTEGER, n_taxa_covered INTEGER, key_format TEXT, includes_microscopy INTEGER NOT NULL DEFAULT 0, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pezizales_diagnostic_keys_publication_id ON ord_pezizales_diagnostic_keys (publication_id); CREATE INDEX ix_ord_pezizales_diagnostic_keys_region_country_id ON ord_pezizales_diagnostic_keys (region_country_id); CREATE TABLE ord_pezizales_type_species_register ( id INTEGER PRIMARY KEY AUTOINCREMENT, focal_genus_id INTEGER NOT NULL, type_species_id INTEGER, designation_publication_id INTEGER, designation_year INTEGER, designated_by_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (designation_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pezizales_type_species_register_focal_genus_id ON ord_pezizales_type_species_register (focal_genus_id); CREATE INDEX ix_ord_pezizales_type_species_register_type_species_id ON ord_pezizales_type_species_register (type_species_id); CREATE TABLE ord_pezizales_distribution_grids ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, grid_cell_code TEXT NOT NULL, centroid_lat REAL, centroid_lon REAL, record_count INTEGER, first_record_year INTEGER, most_recent_record_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pezizales_distribution_grids_species_id ON ord_pezizales_distribution_grids (species_id); CREATE INDEX ix_ord_pezizales_distribution_grids_country_id ON ord_pezizales_distribution_grids (country_id); CREATE TABLE ord_pezizales_microclimate_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER, publication_id INTEGER, substrate_temperature_c REAL, substrate_moisture_pct REAL, canopy_closure_pct REAL, photosynthetic_par_umol_m2_s REAL, days_post_rainfall INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pezizales_microclimate_studies_species_id ON ord_pezizales_microclimate_studies (species_id); CREATE INDEX ix_ord_pezizales_microclimate_studies_publication_id ON ord_pezizales_microclimate_studies (publication_id); CREATE TABLE ord_pezizales_dna_barcoding_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, its_sequenced INTEGER NOT NULL DEFAULT 0, lsu_sequenced INTEGER NOT NULL DEFAULT 0, rpb2_sequenced INTEGER NOT NULL DEFAULT 0, ef1a_sequenced INTEGER NOT NULL DEFAULT 0, genome_assembled INTEGER NOT NULL DEFAULT 0, priority_for_sequencing_score INTEGER CHECK (priority_for_sequencing_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pezizales_dna_barcoding_status_species_id ON ord_pezizales_dna_barcoding_status (species_id); CREATE TABLE ord_pezizales_spore_print_data ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, specimen_id INTEGER, print_color_label TEXT, print_color_chip_id INTEGER, spore_density_per_mm2 REAL, collection_substrate TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (print_color_chip_id) REFERENCES mor_color_chips (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pezizales_spore_print_data_species_id ON ord_pezizales_spore_print_data (species_id); CREATE INDEX ix_ord_pezizales_spore_print_data_specimen_id ON ord_pezizales_spore_print_data (specimen_id); CREATE TABLE ord_pezizales_mating_systems ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, system_type TEXT, mating_loci_count INTEGER, publication_id INTEGER, notes_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pezizales_mating_systems_species_id ON ord_pezizales_mating_systems (species_id); CREATE INDEX ix_ord_pezizales_mating_systems_publication_id ON ord_pezizales_mating_systems (publication_id); CREATE TABLE ord_pezizales_nutrient_uptake_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, nitrogen_source TEXT, carbon_source TEXT, growth_response TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pezizales_nutrient_uptake_studies_species_id ON ord_pezizales_nutrient_uptake_studies (species_id); CREATE INDEX ix_ord_pezizales_nutrient_uptake_studies_strain_id ON ord_pezizales_nutrient_uptake_studies (strain_id); CREATE TABLE ord_pezizales_range_maps ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, polygon_file_uri TEXT NOT NULL, source_methodology TEXT, area_km2 REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pezizales_range_maps_species_id ON ord_pezizales_range_maps (species_id); CREATE INDEX ix_ord_pezizales_range_maps_publication_id ON ord_pezizales_range_maps (publication_id); CREATE TABLE ord_pezizales_abundance_estimates ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, estimate_kind TEXT, value_min REAL, value_max REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pezizales_abundance_estimates_species_id ON ord_pezizales_abundance_estimates (species_id); CREATE INDEX ix_ord_pezizales_abundance_estimates_country_id ON ord_pezizales_abundance_estimates (country_id); CREATE TABLE ord_pezizales_toxin_profiles ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, presence TEXT, typical_concentration_mg_per_kg REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pezizales_toxin_profiles_species_id ON ord_pezizales_toxin_profiles (species_id); CREATE INDEX ix_ord_pezizales_toxin_profiles_compound_id ON ord_pezizales_toxin_profiles (compound_id); CREATE TABLE ord_pezizales_enzyme_activity_assays ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, enzyme_id INTEGER NOT NULL, strain_id INTEGER, activity_u_per_mg REAL, temperature_c REAL, ph REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (enzyme_id) REFERENCES bio_enzymes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pezizales_enzyme_activity_assays_species_id ON ord_pezizales_enzyme_activity_assays (species_id); CREATE INDEX ix_ord_pezizales_enzyme_activity_assays_enzyme_id ON ord_pezizales_enzyme_activity_assays (enzyme_id); CREATE TABLE ord_pezizales_biocontrol_evaluations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, target_pest_text TEXT NOT NULL, efficacy_pct REAL, trial_setting TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pezizales_biocontrol_evaluations_species_id ON ord_pezizales_biocontrol_evaluations (species_id); CREATE INDEX ix_ord_pezizales_biocontrol_evaluations_publication_id ON ord_pezizales_biocontrol_evaluations (publication_id); CREATE TABLE ord_pezizales_regional_checklists ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, checklist_publication_id INTEGER, status TEXT, checklist_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (checklist_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pezizales_regional_checklists_species_id ON ord_pezizales_regional_checklists (species_id); CREATE INDEX ix_ord_pezizales_regional_checklists_country_id ON ord_pezizales_regional_checklists (country_id); CREATE TABLE ord_helotiales_morphology ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, hymenium_color_at_maturity TEXT, context_color_at_maturity TEXT, characteristic_microstructure TEXT, diagnostic_features_text TEXT, notes_kohler_reaction TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_helotiales_morphology_specimen_id ON ord_helotiales_morphology (specimen_id); CREATE INDEX ix_ord_helotiales_morphology_species_id ON ord_helotiales_morphology (species_id); CREATE TABLE ord_helotiales_ecology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, dominant_habitat_id INTEGER, dominant_substrate_id INTEGER, dominant_biome_id INTEGER, trophic_strategy TEXT, typical_fruiting_period TEXT, known_distribution_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_habitat_id) REFERENCES eco_habitat_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_substrate_id) REFERENCES eco_substrate_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_biome_id) REFERENCES geo_biomes (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_helotiales_ecology_species_id ON ord_helotiales_ecology (species_id); CREATE INDEX ix_ord_helotiales_ecology_dominant_habitat_id ON ord_helotiales_ecology (dominant_habitat_id); CREATE TABLE ord_helotiales_phenology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, season_name TEXT, region_country_id INTEGER, first_doy INTEGER, peak_doy INTEGER, last_doy INTEGER, years_observed INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_helotiales_phenology_species_id ON ord_helotiales_phenology (species_id); CREATE INDEX ix_ord_helotiales_phenology_region_country_id ON ord_helotiales_phenology (region_country_id); CREATE TABLE ord_helotiales_host_associations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, association_type TEXT, specificity TEXT, evidence_publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (evidence_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_helotiales_host_associations_species_id ON ord_helotiales_host_associations (species_id); CREATE INDEX ix_ord_helotiales_host_associations_host_id ON ord_helotiales_host_associations (host_id); CREATE TABLE ord_helotiales_substrate_preferences ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, substrate_id INTEGER NOT NULL, preference_score REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (substrate_id) REFERENCES eco_substrate_types (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_helotiales_substrate_preferences_species_id ON ord_helotiales_substrate_preferences (species_id); CREATE INDEX ix_ord_helotiales_substrate_preferences_substrate_id ON ord_helotiales_substrate_preferences (substrate_id); CREATE TABLE ord_helotiales_geographic_distribution ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, occurrence_status TEXT, first_record_year INTEGER, record_count INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_helotiales_geographic_distribution_species_id ON ord_helotiales_geographic_distribution (species_id); CREATE INDEX ix_ord_helotiales_geographic_distribution_country_id ON ord_helotiales_geographic_distribution (country_id); CREATE TABLE ord_helotiales_phylogeny ( id INTEGER PRIMARY KEY AUTOINCREMENT, tree_id INTEGER NOT NULL, focal_genus_id INTEGER, publication_id INTEGER, notes_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (tree_id) REFERENCES phy_trees (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_helotiales_phylogeny_tree_id ON ord_helotiales_phylogeny (tree_id); CREATE INDEX ix_ord_helotiales_phylogeny_focal_genus_id ON ord_helotiales_phylogeny (focal_genus_id); CREATE TABLE ord_helotiales_genomics ( id INTEGER PRIMARY KEY AUTOINCREMENT, assembly_id INTEGER NOT NULL, species_id INTEGER, avg_genome_size_mb REAL, avg_gene_count INTEGER, avg_busco_complete_pct REAL, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (assembly_id) REFERENCES gen_assemblies (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_helotiales_genomics_assembly_id ON ord_helotiales_genomics (assembly_id); CREATE INDEX ix_ord_helotiales_genomics_species_id ON ord_helotiales_genomics (species_id); CREATE TABLE ord_helotiales_biochemistry ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, typicality TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_helotiales_biochemistry_species_id ON ord_helotiales_biochemistry (species_id); CREATE INDEX ix_ord_helotiales_biochemistry_compound_id ON ord_helotiales_biochemistry (compound_id); CREATE TABLE ord_helotiales_cultivation_notes ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, typical_growth_rate_mm_per_day REAL, preferred_media_type_id INTEGER, optimal_temperature_c REAL, difficulty_score INTEGER CHECK (difficulty_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (preferred_media_type_id) REFERENCES cul_media_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_helotiales_cultivation_notes_species_id ON ord_helotiales_cultivation_notes (species_id); CREATE INDEX ix_ord_helotiales_cultivation_notes_strain_id ON ord_helotiales_cultivation_notes (strain_id); CREATE TABLE ord_helotiales_pathogenicity ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, disease_id INTEGER, severity_score INTEGER CHECK (severity_score BETWEEN 1 AND 5), publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (disease_id) REFERENCES pat_diseases (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_helotiales_pathogenicity_species_id ON ord_helotiales_pathogenicity (species_id); CREATE INDEX ix_ord_helotiales_pathogenicity_host_id ON ord_helotiales_pathogenicity (host_id); CREATE TABLE ord_helotiales_edibility ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, edibility_class TEXT, preparation_notes TEXT, regional_tradition_country_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (regional_tradition_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_helotiales_edibility_species_id ON ord_helotiales_edibility (species_id); CREATE INDEX ix_ord_helotiales_edibility_regional_tradition_country_id ON ord_helotiales_edibility (regional_tradition_country_id); CREATE TABLE ord_helotiales_medicinal_uses ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, traditional_use_text TEXT, modern_evidence_level TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_helotiales_medicinal_uses_species_id ON ord_helotiales_medicinal_uses (species_id); CREATE INDEX ix_ord_helotiales_medicinal_uses_publication_id ON ord_helotiales_medicinal_uses (publication_id); CREATE TABLE ord_helotiales_taxonomic_revisions ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER NOT NULL, affected_family_id INTEGER, affected_genus_id INTEGER, revision_summary TEXT, revision_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_family_id) REFERENCES tax_families (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_helotiales_taxonomic_revisions_publication_id ON ord_helotiales_taxonomic_revisions (publication_id); CREATE INDEX ix_ord_helotiales_taxonomic_revisions_affected_family_id ON ord_helotiales_taxonomic_revisions (affected_family_id); CREATE TABLE ord_helotiales_conservation_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, national_redlist_category TEXT, habitat_pressure_text TEXT, last_assessment_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_helotiales_conservation_status_species_id ON ord_helotiales_conservation_status (species_id); CREATE INDEX ix_ord_helotiales_conservation_status_country_id ON ord_helotiales_conservation_status (country_id); CREATE TABLE ord_helotiales_diagnostic_keys ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER, key_title TEXT NOT NULL, region_country_id INTEGER, n_taxa_covered INTEGER, key_format TEXT, includes_microscopy INTEGER NOT NULL DEFAULT 0, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_helotiales_diagnostic_keys_publication_id ON ord_helotiales_diagnostic_keys (publication_id); CREATE INDEX ix_ord_helotiales_diagnostic_keys_region_country_id ON ord_helotiales_diagnostic_keys (region_country_id); CREATE TABLE ord_helotiales_type_species_register ( id INTEGER PRIMARY KEY AUTOINCREMENT, focal_genus_id INTEGER NOT NULL, type_species_id INTEGER, designation_publication_id INTEGER, designation_year INTEGER, designated_by_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (designation_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_helotiales_type_species_register_focal_genus_id ON ord_helotiales_type_species_register (focal_genus_id); CREATE INDEX ix_ord_helotiales_type_species_register_type_species_id ON ord_helotiales_type_species_register (type_species_id); CREATE TABLE ord_helotiales_distribution_grids ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, grid_cell_code TEXT NOT NULL, centroid_lat REAL, centroid_lon REAL, record_count INTEGER, first_record_year INTEGER, most_recent_record_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_helotiales_distribution_grids_species_id ON ord_helotiales_distribution_grids (species_id); CREATE INDEX ix_ord_helotiales_distribution_grids_country_id ON ord_helotiales_distribution_grids (country_id); CREATE TABLE ord_helotiales_microclimate_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER, publication_id INTEGER, substrate_temperature_c REAL, substrate_moisture_pct REAL, canopy_closure_pct REAL, photosynthetic_par_umol_m2_s REAL, days_post_rainfall INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_helotiales_microclimate_studies_species_id ON ord_helotiales_microclimate_studies (species_id); CREATE INDEX ix_ord_helotiales_microclimate_studies_publication_id ON ord_helotiales_microclimate_studies (publication_id); CREATE TABLE ord_helotiales_dna_barcoding_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, its_sequenced INTEGER NOT NULL DEFAULT 0, lsu_sequenced INTEGER NOT NULL DEFAULT 0, rpb2_sequenced INTEGER NOT NULL DEFAULT 0, ef1a_sequenced INTEGER NOT NULL DEFAULT 0, genome_assembled INTEGER NOT NULL DEFAULT 0, priority_for_sequencing_score INTEGER CHECK (priority_for_sequencing_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_helotiales_dna_barcoding_status_species_id ON ord_helotiales_dna_barcoding_status (species_id); CREATE TABLE ord_helotiales_spore_print_data ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, specimen_id INTEGER, print_color_label TEXT, print_color_chip_id INTEGER, spore_density_per_mm2 REAL, collection_substrate TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (print_color_chip_id) REFERENCES mor_color_chips (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_helotiales_spore_print_data_species_id ON ord_helotiales_spore_print_data (species_id); CREATE INDEX ix_ord_helotiales_spore_print_data_specimen_id ON ord_helotiales_spore_print_data (specimen_id); CREATE TABLE ord_helotiales_mating_systems ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, system_type TEXT, mating_loci_count INTEGER, publication_id INTEGER, notes_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_helotiales_mating_systems_species_id ON ord_helotiales_mating_systems (species_id); CREATE INDEX ix_ord_helotiales_mating_systems_publication_id ON ord_helotiales_mating_systems (publication_id); CREATE TABLE ord_helotiales_nutrient_uptake_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, nitrogen_source TEXT, carbon_source TEXT, growth_response TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_helotiales_nutrient_uptake_studies_species_id ON ord_helotiales_nutrient_uptake_studies (species_id); CREATE INDEX ix_ord_helotiales_nutrient_uptake_studies_strain_id ON ord_helotiales_nutrient_uptake_studies (strain_id); CREATE TABLE ord_helotiales_range_maps ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, polygon_file_uri TEXT NOT NULL, source_methodology TEXT, area_km2 REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_helotiales_range_maps_species_id ON ord_helotiales_range_maps (species_id); CREATE INDEX ix_ord_helotiales_range_maps_publication_id ON ord_helotiales_range_maps (publication_id); CREATE TABLE ord_helotiales_abundance_estimates ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, estimate_kind TEXT, value_min REAL, value_max REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_helotiales_abundance_estimates_species_id ON ord_helotiales_abundance_estimates (species_id); CREATE INDEX ix_ord_helotiales_abundance_estimates_country_id ON ord_helotiales_abundance_estimates (country_id); CREATE TABLE ord_helotiales_toxin_profiles ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, presence TEXT, typical_concentration_mg_per_kg REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_helotiales_toxin_profiles_species_id ON ord_helotiales_toxin_profiles (species_id); CREATE INDEX ix_ord_helotiales_toxin_profiles_compound_id ON ord_helotiales_toxin_profiles (compound_id); CREATE TABLE ord_helotiales_enzyme_activity_assays ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, enzyme_id INTEGER NOT NULL, strain_id INTEGER, activity_u_per_mg REAL, temperature_c REAL, ph REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (enzyme_id) REFERENCES bio_enzymes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_helotiales_enzyme_activity_assays_species_id ON ord_helotiales_enzyme_activity_assays (species_id); CREATE INDEX ix_ord_helotiales_enzyme_activity_assays_enzyme_id ON ord_helotiales_enzyme_activity_assays (enzyme_id); CREATE TABLE ord_helotiales_biocontrol_evaluations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, target_pest_text TEXT NOT NULL, efficacy_pct REAL, trial_setting TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_helotiales_biocontrol_evaluations_species_id ON ord_helotiales_biocontrol_evaluations (species_id); CREATE INDEX ix_ord_helotiales_biocontrol_evaluations_publication_id ON ord_helotiales_biocontrol_evaluations (publication_id); CREATE TABLE ord_helotiales_regional_checklists ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, checklist_publication_id INTEGER, status TEXT, checklist_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (checklist_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_helotiales_regional_checklists_species_id ON ord_helotiales_regional_checklists (species_id); CREATE INDEX ix_ord_helotiales_regional_checklists_country_id ON ord_helotiales_regional_checklists (country_id); CREATE TABLE ord_rhytismatales_morphology ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, hymenium_color_at_maturity TEXT, context_color_at_maturity TEXT, characteristic_microstructure TEXT, diagnostic_features_text TEXT, notes_kohler_reaction TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_rhytismatales_morphology_specimen_id ON ord_rhytismatales_morphology (specimen_id); CREATE INDEX ix_ord_rhytismatales_morphology_species_id ON ord_rhytismatales_morphology (species_id); CREATE TABLE ord_rhytismatales_ecology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, dominant_habitat_id INTEGER, dominant_substrate_id INTEGER, dominant_biome_id INTEGER, trophic_strategy TEXT, typical_fruiting_period TEXT, known_distribution_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_habitat_id) REFERENCES eco_habitat_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_substrate_id) REFERENCES eco_substrate_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_biome_id) REFERENCES geo_biomes (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_rhytismatales_ecology_species_id ON ord_rhytismatales_ecology (species_id); CREATE INDEX ix_ord_rhytismatales_ecology_dominant_habitat_id ON ord_rhytismatales_ecology (dominant_habitat_id); CREATE TABLE ord_rhytismatales_phenology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, season_name TEXT, region_country_id INTEGER, first_doy INTEGER, peak_doy INTEGER, last_doy INTEGER, years_observed INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_rhytismatales_phenology_species_id ON ord_rhytismatales_phenology (species_id); CREATE INDEX ix_ord_rhytismatales_phenology_region_country_id ON ord_rhytismatales_phenology (region_country_id); CREATE TABLE ord_rhytismatales_host_associations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, association_type TEXT, specificity TEXT, evidence_publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (evidence_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_rhytismatales_host_associations_species_id ON ord_rhytismatales_host_associations (species_id); CREATE INDEX ix_ord_rhytismatales_host_associations_host_id ON ord_rhytismatales_host_associations (host_id); CREATE TABLE ord_rhytismatales_substrate_preferences ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, substrate_id INTEGER NOT NULL, preference_score REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (substrate_id) REFERENCES eco_substrate_types (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_rhytismatales_substrate_preferences_species_id ON ord_rhytismatales_substrate_preferences (species_id); CREATE INDEX ix_ord_rhytismatales_substrate_preferences_substrate_id ON ord_rhytismatales_substrate_preferences (substrate_id); CREATE TABLE ord_rhytismatales_geographic_distribution ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, occurrence_status TEXT, first_record_year INTEGER, record_count INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_rhytismatales_geographic_distribution_species_id ON ord_rhytismatales_geographic_distribution (species_id); CREATE INDEX ix_ord_rhytismatales_geographic_distribution_country_id ON ord_rhytismatales_geographic_distribution (country_id); CREATE TABLE ord_rhytismatales_phylogeny ( id INTEGER PRIMARY KEY AUTOINCREMENT, tree_id INTEGER NOT NULL, focal_genus_id INTEGER, publication_id INTEGER, notes_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (tree_id) REFERENCES phy_trees (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_rhytismatales_phylogeny_tree_id ON ord_rhytismatales_phylogeny (tree_id); CREATE INDEX ix_ord_rhytismatales_phylogeny_focal_genus_id ON ord_rhytismatales_phylogeny (focal_genus_id); CREATE TABLE ord_rhytismatales_genomics ( id INTEGER PRIMARY KEY AUTOINCREMENT, assembly_id INTEGER NOT NULL, species_id INTEGER, avg_genome_size_mb REAL, avg_gene_count INTEGER, avg_busco_complete_pct REAL, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (assembly_id) REFERENCES gen_assemblies (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_rhytismatales_genomics_assembly_id ON ord_rhytismatales_genomics (assembly_id); CREATE INDEX ix_ord_rhytismatales_genomics_species_id ON ord_rhytismatales_genomics (species_id); CREATE TABLE ord_rhytismatales_biochemistry ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, typicality TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_rhytismatales_biochemistry_species_id ON ord_rhytismatales_biochemistry (species_id); CREATE INDEX ix_ord_rhytismatales_biochemistry_compound_id ON ord_rhytismatales_biochemistry (compound_id); CREATE TABLE ord_rhytismatales_cultivation_notes ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, typical_growth_rate_mm_per_day REAL, preferred_media_type_id INTEGER, optimal_temperature_c REAL, difficulty_score INTEGER CHECK (difficulty_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (preferred_media_type_id) REFERENCES cul_media_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_rhytismatales_cultivation_notes_species_id ON ord_rhytismatales_cultivation_notes (species_id); CREATE INDEX ix_ord_rhytismatales_cultivation_notes_strain_id ON ord_rhytismatales_cultivation_notes (strain_id); CREATE TABLE ord_rhytismatales_pathogenicity ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, disease_id INTEGER, severity_score INTEGER CHECK (severity_score BETWEEN 1 AND 5), publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (disease_id) REFERENCES pat_diseases (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_rhytismatales_pathogenicity_species_id ON ord_rhytismatales_pathogenicity (species_id); CREATE INDEX ix_ord_rhytismatales_pathogenicity_host_id ON ord_rhytismatales_pathogenicity (host_id); CREATE TABLE ord_rhytismatales_edibility ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, edibility_class TEXT, preparation_notes TEXT, regional_tradition_country_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (regional_tradition_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_rhytismatales_edibility_species_id ON ord_rhytismatales_edibility (species_id); CREATE INDEX ix_ord_rhytismatales_edibility_regional_tradition_country_id ON ord_rhytismatales_edibility (regional_tradition_country_id); CREATE TABLE ord_rhytismatales_medicinal_uses ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, traditional_use_text TEXT, modern_evidence_level TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_rhytismatales_medicinal_uses_species_id ON ord_rhytismatales_medicinal_uses (species_id); CREATE INDEX ix_ord_rhytismatales_medicinal_uses_publication_id ON ord_rhytismatales_medicinal_uses (publication_id); CREATE TABLE ord_rhytismatales_taxonomic_revisions ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER NOT NULL, affected_family_id INTEGER, affected_genus_id INTEGER, revision_summary TEXT, revision_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_family_id) REFERENCES tax_families (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_rhytismatales_taxonomic_revisions_publication_id ON ord_rhytismatales_taxonomic_revisions (publication_id); CREATE INDEX ix_ord_rhytismatales_taxonomic_revisions_affected_family_id ON ord_rhytismatales_taxonomic_revisions (affected_family_id); CREATE TABLE ord_rhytismatales_conservation_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, national_redlist_category TEXT, habitat_pressure_text TEXT, last_assessment_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_rhytismatales_conservation_status_species_id ON ord_rhytismatales_conservation_status (species_id); CREATE INDEX ix_ord_rhytismatales_conservation_status_country_id ON ord_rhytismatales_conservation_status (country_id); CREATE TABLE ord_rhytismatales_diagnostic_keys ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER, key_title TEXT NOT NULL, region_country_id INTEGER, n_taxa_covered INTEGER, key_format TEXT, includes_microscopy INTEGER NOT NULL DEFAULT 0, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_rhytismatales_diagnostic_keys_publication_id ON ord_rhytismatales_diagnostic_keys (publication_id); CREATE INDEX ix_ord_rhytismatales_diagnostic_keys_region_country_id ON ord_rhytismatales_diagnostic_keys (region_country_id); CREATE TABLE ord_rhytismatales_type_species_register ( id INTEGER PRIMARY KEY AUTOINCREMENT, focal_genus_id INTEGER NOT NULL, type_species_id INTEGER, designation_publication_id INTEGER, designation_year INTEGER, designated_by_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (designation_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_rhytismatales_type_species_register_focal_genus_id ON ord_rhytismatales_type_species_register (focal_genus_id); CREATE INDEX ix_ord_rhytismatales_type_species_register_type_species_id ON ord_rhytismatales_type_species_register (type_species_id); CREATE TABLE ord_rhytismatales_distribution_grids ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, grid_cell_code TEXT NOT NULL, centroid_lat REAL, centroid_lon REAL, record_count INTEGER, first_record_year INTEGER, most_recent_record_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_rhytismatales_distribution_grids_species_id ON ord_rhytismatales_distribution_grids (species_id); CREATE INDEX ix_ord_rhytismatales_distribution_grids_country_id ON ord_rhytismatales_distribution_grids (country_id); CREATE TABLE ord_rhytismatales_microclimate_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER, publication_id INTEGER, substrate_temperature_c REAL, substrate_moisture_pct REAL, canopy_closure_pct REAL, photosynthetic_par_umol_m2_s REAL, days_post_rainfall INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_rhytismatales_microclimate_studies_species_id ON ord_rhytismatales_microclimate_studies (species_id); CREATE INDEX ix_ord_rhytismatales_microclimate_studies_publication_id ON ord_rhytismatales_microclimate_studies (publication_id); CREATE TABLE ord_rhytismatales_dna_barcoding_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, its_sequenced INTEGER NOT NULL DEFAULT 0, lsu_sequenced INTEGER NOT NULL DEFAULT 0, rpb2_sequenced INTEGER NOT NULL DEFAULT 0, ef1a_sequenced INTEGER NOT NULL DEFAULT 0, genome_assembled INTEGER NOT NULL DEFAULT 0, priority_for_sequencing_score INTEGER CHECK (priority_for_sequencing_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_rhytismatales_dna_barcoding_status_species_id ON ord_rhytismatales_dna_barcoding_status (species_id); CREATE TABLE ord_rhytismatales_spore_print_data ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, specimen_id INTEGER, print_color_label TEXT, print_color_chip_id INTEGER, spore_density_per_mm2 REAL, collection_substrate TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (print_color_chip_id) REFERENCES mor_color_chips (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_rhytismatales_spore_print_data_species_id ON ord_rhytismatales_spore_print_data (species_id); CREATE INDEX ix_ord_rhytismatales_spore_print_data_specimen_id ON ord_rhytismatales_spore_print_data (specimen_id); CREATE TABLE ord_rhytismatales_mating_systems ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, system_type TEXT, mating_loci_count INTEGER, publication_id INTEGER, notes_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_rhytismatales_mating_systems_species_id ON ord_rhytismatales_mating_systems (species_id); CREATE INDEX ix_ord_rhytismatales_mating_systems_publication_id ON ord_rhytismatales_mating_systems (publication_id); CREATE TABLE ord_rhytismatales_nutrient_uptake_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, nitrogen_source TEXT, carbon_source TEXT, growth_response TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_rhytismatales_nutrient_uptake_studies_species_id ON ord_rhytismatales_nutrient_uptake_studies (species_id); CREATE INDEX ix_ord_rhytismatales_nutrient_uptake_studies_strain_id ON ord_rhytismatales_nutrient_uptake_studies (strain_id); CREATE TABLE ord_rhytismatales_range_maps ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, polygon_file_uri TEXT NOT NULL, source_methodology TEXT, area_km2 REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_rhytismatales_range_maps_species_id ON ord_rhytismatales_range_maps (species_id); CREATE INDEX ix_ord_rhytismatales_range_maps_publication_id ON ord_rhytismatales_range_maps (publication_id); CREATE TABLE ord_rhytismatales_abundance_estimates ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, estimate_kind TEXT, value_min REAL, value_max REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_rhytismatales_abundance_estimates_species_id ON ord_rhytismatales_abundance_estimates (species_id); CREATE INDEX ix_ord_rhytismatales_abundance_estimates_country_id ON ord_rhytismatales_abundance_estimates (country_id); CREATE TABLE ord_rhytismatales_toxin_profiles ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, presence TEXT, typical_concentration_mg_per_kg REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_rhytismatales_toxin_profiles_species_id ON ord_rhytismatales_toxin_profiles (species_id); CREATE INDEX ix_ord_rhytismatales_toxin_profiles_compound_id ON ord_rhytismatales_toxin_profiles (compound_id); CREATE TABLE ord_rhytismatales_enzyme_activity_assays ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, enzyme_id INTEGER NOT NULL, strain_id INTEGER, activity_u_per_mg REAL, temperature_c REAL, ph REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (enzyme_id) REFERENCES bio_enzymes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_rhytismatales_enzyme_activity_assays_species_id ON ord_rhytismatales_enzyme_activity_assays (species_id); CREATE INDEX ix_ord_rhytismatales_enzyme_activity_assays_enzyme_id ON ord_rhytismatales_enzyme_activity_assays (enzyme_id); CREATE TABLE ord_rhytismatales_biocontrol_evaluations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, target_pest_text TEXT NOT NULL, efficacy_pct REAL, trial_setting TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_rhytismatales_biocontrol_evaluations_species_id ON ord_rhytismatales_biocontrol_evaluations (species_id); CREATE INDEX ix_ord_rhytismatales_biocontrol_evaluations_publication_id ON ord_rhytismatales_biocontrol_evaluations (publication_id); CREATE TABLE ord_rhytismatales_regional_checklists ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, checklist_publication_id INTEGER, status TEXT, checklist_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (checklist_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_rhytismatales_regional_checklists_species_id ON ord_rhytismatales_regional_checklists (species_id); CREATE INDEX ix_ord_rhytismatales_regional_checklists_country_id ON ord_rhytismatales_regional_checklists (country_id); CREATE TABLE ord_erysiphales_morphology ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, hymenium_color_at_maturity TEXT, context_color_at_maturity TEXT, characteristic_microstructure TEXT, diagnostic_features_text TEXT, notes_kohler_reaction TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_erysiphales_morphology_specimen_id ON ord_erysiphales_morphology (specimen_id); CREATE INDEX ix_ord_erysiphales_morphology_species_id ON ord_erysiphales_morphology (species_id); CREATE TABLE ord_erysiphales_ecology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, dominant_habitat_id INTEGER, dominant_substrate_id INTEGER, dominant_biome_id INTEGER, trophic_strategy TEXT, typical_fruiting_period TEXT, known_distribution_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_habitat_id) REFERENCES eco_habitat_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_substrate_id) REFERENCES eco_substrate_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_biome_id) REFERENCES geo_biomes (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_erysiphales_ecology_species_id ON ord_erysiphales_ecology (species_id); CREATE INDEX ix_ord_erysiphales_ecology_dominant_habitat_id ON ord_erysiphales_ecology (dominant_habitat_id); CREATE TABLE ord_erysiphales_phenology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, season_name TEXT, region_country_id INTEGER, first_doy INTEGER, peak_doy INTEGER, last_doy INTEGER, years_observed INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_erysiphales_phenology_species_id ON ord_erysiphales_phenology (species_id); CREATE INDEX ix_ord_erysiphales_phenology_region_country_id ON ord_erysiphales_phenology (region_country_id); CREATE TABLE ord_erysiphales_host_associations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, association_type TEXT, specificity TEXT, evidence_publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (evidence_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_erysiphales_host_associations_species_id ON ord_erysiphales_host_associations (species_id); CREATE INDEX ix_ord_erysiphales_host_associations_host_id ON ord_erysiphales_host_associations (host_id); CREATE TABLE ord_erysiphales_substrate_preferences ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, substrate_id INTEGER NOT NULL, preference_score REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (substrate_id) REFERENCES eco_substrate_types (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_erysiphales_substrate_preferences_species_id ON ord_erysiphales_substrate_preferences (species_id); CREATE INDEX ix_ord_erysiphales_substrate_preferences_substrate_id ON ord_erysiphales_substrate_preferences (substrate_id); CREATE TABLE ord_erysiphales_geographic_distribution ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, occurrence_status TEXT, first_record_year INTEGER, record_count INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_erysiphales_geographic_distribution_species_id ON ord_erysiphales_geographic_distribution (species_id); CREATE INDEX ix_ord_erysiphales_geographic_distribution_country_id ON ord_erysiphales_geographic_distribution (country_id); CREATE TABLE ord_erysiphales_phylogeny ( id INTEGER PRIMARY KEY AUTOINCREMENT, tree_id INTEGER NOT NULL, focal_genus_id INTEGER, publication_id INTEGER, notes_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (tree_id) REFERENCES phy_trees (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_erysiphales_phylogeny_tree_id ON ord_erysiphales_phylogeny (tree_id); CREATE INDEX ix_ord_erysiphales_phylogeny_focal_genus_id ON ord_erysiphales_phylogeny (focal_genus_id); CREATE TABLE ord_erysiphales_genomics ( id INTEGER PRIMARY KEY AUTOINCREMENT, assembly_id INTEGER NOT NULL, species_id INTEGER, avg_genome_size_mb REAL, avg_gene_count INTEGER, avg_busco_complete_pct REAL, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (assembly_id) REFERENCES gen_assemblies (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_erysiphales_genomics_assembly_id ON ord_erysiphales_genomics (assembly_id); CREATE INDEX ix_ord_erysiphales_genomics_species_id ON ord_erysiphales_genomics (species_id); CREATE TABLE ord_erysiphales_biochemistry ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, typicality TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_erysiphales_biochemistry_species_id ON ord_erysiphales_biochemistry (species_id); CREATE INDEX ix_ord_erysiphales_biochemistry_compound_id ON ord_erysiphales_biochemistry (compound_id); CREATE TABLE ord_erysiphales_cultivation_notes ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, typical_growth_rate_mm_per_day REAL, preferred_media_type_id INTEGER, optimal_temperature_c REAL, difficulty_score INTEGER CHECK (difficulty_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (preferred_media_type_id) REFERENCES cul_media_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_erysiphales_cultivation_notes_species_id ON ord_erysiphales_cultivation_notes (species_id); CREATE INDEX ix_ord_erysiphales_cultivation_notes_strain_id ON ord_erysiphales_cultivation_notes (strain_id); CREATE TABLE ord_erysiphales_pathogenicity ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, disease_id INTEGER, severity_score INTEGER CHECK (severity_score BETWEEN 1 AND 5), publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (disease_id) REFERENCES pat_diseases (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_erysiphales_pathogenicity_species_id ON ord_erysiphales_pathogenicity (species_id); CREATE INDEX ix_ord_erysiphales_pathogenicity_host_id ON ord_erysiphales_pathogenicity (host_id); CREATE TABLE ord_erysiphales_edibility ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, edibility_class TEXT, preparation_notes TEXT, regional_tradition_country_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (regional_tradition_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_erysiphales_edibility_species_id ON ord_erysiphales_edibility (species_id); CREATE INDEX ix_ord_erysiphales_edibility_regional_tradition_country_id ON ord_erysiphales_edibility (regional_tradition_country_id); CREATE TABLE ord_erysiphales_medicinal_uses ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, traditional_use_text TEXT, modern_evidence_level TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_erysiphales_medicinal_uses_species_id ON ord_erysiphales_medicinal_uses (species_id); CREATE INDEX ix_ord_erysiphales_medicinal_uses_publication_id ON ord_erysiphales_medicinal_uses (publication_id); CREATE TABLE ord_erysiphales_taxonomic_revisions ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER NOT NULL, affected_family_id INTEGER, affected_genus_id INTEGER, revision_summary TEXT, revision_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_family_id) REFERENCES tax_families (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_erysiphales_taxonomic_revisions_publication_id ON ord_erysiphales_taxonomic_revisions (publication_id); CREATE INDEX ix_ord_erysiphales_taxonomic_revisions_affected_family_id ON ord_erysiphales_taxonomic_revisions (affected_family_id); CREATE TABLE ord_erysiphales_conservation_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, national_redlist_category TEXT, habitat_pressure_text TEXT, last_assessment_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_erysiphales_conservation_status_species_id ON ord_erysiphales_conservation_status (species_id); CREATE INDEX ix_ord_erysiphales_conservation_status_country_id ON ord_erysiphales_conservation_status (country_id); CREATE TABLE ord_erysiphales_diagnostic_keys ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER, key_title TEXT NOT NULL, region_country_id INTEGER, n_taxa_covered INTEGER, key_format TEXT, includes_microscopy INTEGER NOT NULL DEFAULT 0, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_erysiphales_diagnostic_keys_publication_id ON ord_erysiphales_diagnostic_keys (publication_id); CREATE INDEX ix_ord_erysiphales_diagnostic_keys_region_country_id ON ord_erysiphales_diagnostic_keys (region_country_id); CREATE TABLE ord_erysiphales_type_species_register ( id INTEGER PRIMARY KEY AUTOINCREMENT, focal_genus_id INTEGER NOT NULL, type_species_id INTEGER, designation_publication_id INTEGER, designation_year INTEGER, designated_by_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (designation_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_erysiphales_type_species_register_focal_genus_id ON ord_erysiphales_type_species_register (focal_genus_id); CREATE INDEX ix_ord_erysiphales_type_species_register_type_species_id ON ord_erysiphales_type_species_register (type_species_id); CREATE TABLE ord_erysiphales_distribution_grids ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, grid_cell_code TEXT NOT NULL, centroid_lat REAL, centroid_lon REAL, record_count INTEGER, first_record_year INTEGER, most_recent_record_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_erysiphales_distribution_grids_species_id ON ord_erysiphales_distribution_grids (species_id); CREATE INDEX ix_ord_erysiphales_distribution_grids_country_id ON ord_erysiphales_distribution_grids (country_id); CREATE TABLE ord_erysiphales_microclimate_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER, publication_id INTEGER, substrate_temperature_c REAL, substrate_moisture_pct REAL, canopy_closure_pct REAL, photosynthetic_par_umol_m2_s REAL, days_post_rainfall INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_erysiphales_microclimate_studies_species_id ON ord_erysiphales_microclimate_studies (species_id); CREATE INDEX ix_ord_erysiphales_microclimate_studies_publication_id ON ord_erysiphales_microclimate_studies (publication_id); CREATE TABLE ord_erysiphales_dna_barcoding_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, its_sequenced INTEGER NOT NULL DEFAULT 0, lsu_sequenced INTEGER NOT NULL DEFAULT 0, rpb2_sequenced INTEGER NOT NULL DEFAULT 0, ef1a_sequenced INTEGER NOT NULL DEFAULT 0, genome_assembled INTEGER NOT NULL DEFAULT 0, priority_for_sequencing_score INTEGER CHECK (priority_for_sequencing_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_erysiphales_dna_barcoding_status_species_id ON ord_erysiphales_dna_barcoding_status (species_id); CREATE TABLE ord_erysiphales_spore_print_data ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, specimen_id INTEGER, print_color_label TEXT, print_color_chip_id INTEGER, spore_density_per_mm2 REAL, collection_substrate TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (print_color_chip_id) REFERENCES mor_color_chips (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_erysiphales_spore_print_data_species_id ON ord_erysiphales_spore_print_data (species_id); CREATE INDEX ix_ord_erysiphales_spore_print_data_specimen_id ON ord_erysiphales_spore_print_data (specimen_id); CREATE TABLE ord_erysiphales_mating_systems ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, system_type TEXT, mating_loci_count INTEGER, publication_id INTEGER, notes_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_erysiphales_mating_systems_species_id ON ord_erysiphales_mating_systems (species_id); CREATE INDEX ix_ord_erysiphales_mating_systems_publication_id ON ord_erysiphales_mating_systems (publication_id); CREATE TABLE ord_erysiphales_nutrient_uptake_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, nitrogen_source TEXT, carbon_source TEXT, growth_response TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_erysiphales_nutrient_uptake_studies_species_id ON ord_erysiphales_nutrient_uptake_studies (species_id); CREATE INDEX ix_ord_erysiphales_nutrient_uptake_studies_strain_id ON ord_erysiphales_nutrient_uptake_studies (strain_id); CREATE TABLE ord_erysiphales_range_maps ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, polygon_file_uri TEXT NOT NULL, source_methodology TEXT, area_km2 REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_erysiphales_range_maps_species_id ON ord_erysiphales_range_maps (species_id); CREATE INDEX ix_ord_erysiphales_range_maps_publication_id ON ord_erysiphales_range_maps (publication_id); CREATE TABLE ord_erysiphales_abundance_estimates ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, estimate_kind TEXT, value_min REAL, value_max REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_erysiphales_abundance_estimates_species_id ON ord_erysiphales_abundance_estimates (species_id); CREATE INDEX ix_ord_erysiphales_abundance_estimates_country_id ON ord_erysiphales_abundance_estimates (country_id); CREATE TABLE ord_erysiphales_toxin_profiles ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, presence TEXT, typical_concentration_mg_per_kg REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_erysiphales_toxin_profiles_species_id ON ord_erysiphales_toxin_profiles (species_id); CREATE INDEX ix_ord_erysiphales_toxin_profiles_compound_id ON ord_erysiphales_toxin_profiles (compound_id); CREATE TABLE ord_erysiphales_enzyme_activity_assays ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, enzyme_id INTEGER NOT NULL, strain_id INTEGER, activity_u_per_mg REAL, temperature_c REAL, ph REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (enzyme_id) REFERENCES bio_enzymes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_erysiphales_enzyme_activity_assays_species_id ON ord_erysiphales_enzyme_activity_assays (species_id); CREATE INDEX ix_ord_erysiphales_enzyme_activity_assays_enzyme_id ON ord_erysiphales_enzyme_activity_assays (enzyme_id); CREATE TABLE ord_erysiphales_biocontrol_evaluations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, target_pest_text TEXT NOT NULL, efficacy_pct REAL, trial_setting TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_erysiphales_biocontrol_evaluations_species_id ON ord_erysiphales_biocontrol_evaluations (species_id); CREATE INDEX ix_ord_erysiphales_biocontrol_evaluations_publication_id ON ord_erysiphales_biocontrol_evaluations (publication_id); CREATE TABLE ord_erysiphales_regional_checklists ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, checklist_publication_id INTEGER, status TEXT, checklist_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (checklist_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_erysiphales_regional_checklists_species_id ON ord_erysiphales_regional_checklists (species_id); CREATE INDEX ix_ord_erysiphales_regional_checklists_country_id ON ord_erysiphales_regional_checklists (country_id); CREATE TABLE ord_hypocreales_morphology ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, hymenium_color_at_maturity TEXT, context_color_at_maturity TEXT, characteristic_microstructure TEXT, diagnostic_features_text TEXT, notes_kohler_reaction TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_hypocreales_morphology_specimen_id ON ord_hypocreales_morphology (specimen_id); CREATE INDEX ix_ord_hypocreales_morphology_species_id ON ord_hypocreales_morphology (species_id); CREATE TABLE ord_hypocreales_ecology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, dominant_habitat_id INTEGER, dominant_substrate_id INTEGER, dominant_biome_id INTEGER, trophic_strategy TEXT, typical_fruiting_period TEXT, known_distribution_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_habitat_id) REFERENCES eco_habitat_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_substrate_id) REFERENCES eco_substrate_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_biome_id) REFERENCES geo_biomes (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_hypocreales_ecology_species_id ON ord_hypocreales_ecology (species_id); CREATE INDEX ix_ord_hypocreales_ecology_dominant_habitat_id ON ord_hypocreales_ecology (dominant_habitat_id); CREATE TABLE ord_hypocreales_phenology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, season_name TEXT, region_country_id INTEGER, first_doy INTEGER, peak_doy INTEGER, last_doy INTEGER, years_observed INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_hypocreales_phenology_species_id ON ord_hypocreales_phenology (species_id); CREATE INDEX ix_ord_hypocreales_phenology_region_country_id ON ord_hypocreales_phenology (region_country_id); CREATE TABLE ord_hypocreales_host_associations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, association_type TEXT, specificity TEXT, evidence_publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (evidence_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_hypocreales_host_associations_species_id ON ord_hypocreales_host_associations (species_id); CREATE INDEX ix_ord_hypocreales_host_associations_host_id ON ord_hypocreales_host_associations (host_id); CREATE TABLE ord_hypocreales_substrate_preferences ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, substrate_id INTEGER NOT NULL, preference_score REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (substrate_id) REFERENCES eco_substrate_types (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_hypocreales_substrate_preferences_species_id ON ord_hypocreales_substrate_preferences (species_id); CREATE INDEX ix_ord_hypocreales_substrate_preferences_substrate_id ON ord_hypocreales_substrate_preferences (substrate_id); CREATE TABLE ord_hypocreales_geographic_distribution ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, occurrence_status TEXT, first_record_year INTEGER, record_count INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_hypocreales_geographic_distribution_species_id ON ord_hypocreales_geographic_distribution (species_id); CREATE INDEX ix_ord_hypocreales_geographic_distribution_country_id ON ord_hypocreales_geographic_distribution (country_id); CREATE TABLE ord_hypocreales_phylogeny ( id INTEGER PRIMARY KEY AUTOINCREMENT, tree_id INTEGER NOT NULL, focal_genus_id INTEGER, publication_id INTEGER, notes_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (tree_id) REFERENCES phy_trees (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_hypocreales_phylogeny_tree_id ON ord_hypocreales_phylogeny (tree_id); CREATE INDEX ix_ord_hypocreales_phylogeny_focal_genus_id ON ord_hypocreales_phylogeny (focal_genus_id); CREATE TABLE ord_hypocreales_genomics ( id INTEGER PRIMARY KEY AUTOINCREMENT, assembly_id INTEGER NOT NULL, species_id INTEGER, avg_genome_size_mb REAL, avg_gene_count INTEGER, avg_busco_complete_pct REAL, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (assembly_id) REFERENCES gen_assemblies (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_hypocreales_genomics_assembly_id ON ord_hypocreales_genomics (assembly_id); CREATE INDEX ix_ord_hypocreales_genomics_species_id ON ord_hypocreales_genomics (species_id); CREATE TABLE ord_hypocreales_biochemistry ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, typicality TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_hypocreales_biochemistry_species_id ON ord_hypocreales_biochemistry (species_id); CREATE INDEX ix_ord_hypocreales_biochemistry_compound_id ON ord_hypocreales_biochemistry (compound_id); CREATE TABLE ord_hypocreales_cultivation_notes ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, typical_growth_rate_mm_per_day REAL, preferred_media_type_id INTEGER, optimal_temperature_c REAL, difficulty_score INTEGER CHECK (difficulty_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (preferred_media_type_id) REFERENCES cul_media_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_hypocreales_cultivation_notes_species_id ON ord_hypocreales_cultivation_notes (species_id); CREATE INDEX ix_ord_hypocreales_cultivation_notes_strain_id ON ord_hypocreales_cultivation_notes (strain_id); CREATE TABLE ord_hypocreales_pathogenicity ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, disease_id INTEGER, severity_score INTEGER CHECK (severity_score BETWEEN 1 AND 5), publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (disease_id) REFERENCES pat_diseases (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_hypocreales_pathogenicity_species_id ON ord_hypocreales_pathogenicity (species_id); CREATE INDEX ix_ord_hypocreales_pathogenicity_host_id ON ord_hypocreales_pathogenicity (host_id); CREATE TABLE ord_hypocreales_edibility ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, edibility_class TEXT, preparation_notes TEXT, regional_tradition_country_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (regional_tradition_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_hypocreales_edibility_species_id ON ord_hypocreales_edibility (species_id); CREATE INDEX ix_ord_hypocreales_edibility_regional_tradition_country_id ON ord_hypocreales_edibility (regional_tradition_country_id); CREATE TABLE ord_hypocreales_medicinal_uses ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, traditional_use_text TEXT, modern_evidence_level TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_hypocreales_medicinal_uses_species_id ON ord_hypocreales_medicinal_uses (species_id); CREATE INDEX ix_ord_hypocreales_medicinal_uses_publication_id ON ord_hypocreales_medicinal_uses (publication_id); CREATE TABLE ord_hypocreales_taxonomic_revisions ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER NOT NULL, affected_family_id INTEGER, affected_genus_id INTEGER, revision_summary TEXT, revision_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_family_id) REFERENCES tax_families (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_hypocreales_taxonomic_revisions_publication_id ON ord_hypocreales_taxonomic_revisions (publication_id); CREATE INDEX ix_ord_hypocreales_taxonomic_revisions_affected_family_id ON ord_hypocreales_taxonomic_revisions (affected_family_id); CREATE TABLE ord_hypocreales_conservation_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, national_redlist_category TEXT, habitat_pressure_text TEXT, last_assessment_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_hypocreales_conservation_status_species_id ON ord_hypocreales_conservation_status (species_id); CREATE INDEX ix_ord_hypocreales_conservation_status_country_id ON ord_hypocreales_conservation_status (country_id); CREATE TABLE ord_hypocreales_diagnostic_keys ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER, key_title TEXT NOT NULL, region_country_id INTEGER, n_taxa_covered INTEGER, key_format TEXT, includes_microscopy INTEGER NOT NULL DEFAULT 0, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_hypocreales_diagnostic_keys_publication_id ON ord_hypocreales_diagnostic_keys (publication_id); CREATE INDEX ix_ord_hypocreales_diagnostic_keys_region_country_id ON ord_hypocreales_diagnostic_keys (region_country_id); CREATE TABLE ord_hypocreales_type_species_register ( id INTEGER PRIMARY KEY AUTOINCREMENT, focal_genus_id INTEGER NOT NULL, type_species_id INTEGER, designation_publication_id INTEGER, designation_year INTEGER, designated_by_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (designation_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_hypocreales_type_species_register_focal_genus_id ON ord_hypocreales_type_species_register (focal_genus_id); CREATE INDEX ix_ord_hypocreales_type_species_register_type_species_id ON ord_hypocreales_type_species_register (type_species_id); CREATE TABLE ord_hypocreales_distribution_grids ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, grid_cell_code TEXT NOT NULL, centroid_lat REAL, centroid_lon REAL, record_count INTEGER, first_record_year INTEGER, most_recent_record_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_hypocreales_distribution_grids_species_id ON ord_hypocreales_distribution_grids (species_id); CREATE INDEX ix_ord_hypocreales_distribution_grids_country_id ON ord_hypocreales_distribution_grids (country_id); CREATE TABLE ord_hypocreales_microclimate_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER, publication_id INTEGER, substrate_temperature_c REAL, substrate_moisture_pct REAL, canopy_closure_pct REAL, photosynthetic_par_umol_m2_s REAL, days_post_rainfall INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_hypocreales_microclimate_studies_species_id ON ord_hypocreales_microclimate_studies (species_id); CREATE INDEX ix_ord_hypocreales_microclimate_studies_publication_id ON ord_hypocreales_microclimate_studies (publication_id); CREATE TABLE ord_hypocreales_dna_barcoding_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, its_sequenced INTEGER NOT NULL DEFAULT 0, lsu_sequenced INTEGER NOT NULL DEFAULT 0, rpb2_sequenced INTEGER NOT NULL DEFAULT 0, ef1a_sequenced INTEGER NOT NULL DEFAULT 0, genome_assembled INTEGER NOT NULL DEFAULT 0, priority_for_sequencing_score INTEGER CHECK (priority_for_sequencing_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_hypocreales_dna_barcoding_status_species_id ON ord_hypocreales_dna_barcoding_status (species_id); CREATE TABLE ord_hypocreales_spore_print_data ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, specimen_id INTEGER, print_color_label TEXT, print_color_chip_id INTEGER, spore_density_per_mm2 REAL, collection_substrate TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (print_color_chip_id) REFERENCES mor_color_chips (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_hypocreales_spore_print_data_species_id ON ord_hypocreales_spore_print_data (species_id); CREATE INDEX ix_ord_hypocreales_spore_print_data_specimen_id ON ord_hypocreales_spore_print_data (specimen_id); CREATE TABLE ord_hypocreales_mating_systems ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, system_type TEXT, mating_loci_count INTEGER, publication_id INTEGER, notes_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_hypocreales_mating_systems_species_id ON ord_hypocreales_mating_systems (species_id); CREATE INDEX ix_ord_hypocreales_mating_systems_publication_id ON ord_hypocreales_mating_systems (publication_id); CREATE TABLE ord_hypocreales_nutrient_uptake_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, nitrogen_source TEXT, carbon_source TEXT, growth_response TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_hypocreales_nutrient_uptake_studies_species_id ON ord_hypocreales_nutrient_uptake_studies (species_id); CREATE INDEX ix_ord_hypocreales_nutrient_uptake_studies_strain_id ON ord_hypocreales_nutrient_uptake_studies (strain_id); CREATE TABLE ord_hypocreales_range_maps ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, polygon_file_uri TEXT NOT NULL, source_methodology TEXT, area_km2 REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_hypocreales_range_maps_species_id ON ord_hypocreales_range_maps (species_id); CREATE INDEX ix_ord_hypocreales_range_maps_publication_id ON ord_hypocreales_range_maps (publication_id); CREATE TABLE ord_hypocreales_abundance_estimates ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, estimate_kind TEXT, value_min REAL, value_max REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_hypocreales_abundance_estimates_species_id ON ord_hypocreales_abundance_estimates (species_id); CREATE INDEX ix_ord_hypocreales_abundance_estimates_country_id ON ord_hypocreales_abundance_estimates (country_id); CREATE TABLE ord_hypocreales_toxin_profiles ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, presence TEXT, typical_concentration_mg_per_kg REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_hypocreales_toxin_profiles_species_id ON ord_hypocreales_toxin_profiles (species_id); CREATE INDEX ix_ord_hypocreales_toxin_profiles_compound_id ON ord_hypocreales_toxin_profiles (compound_id); CREATE TABLE ord_hypocreales_enzyme_activity_assays ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, enzyme_id INTEGER NOT NULL, strain_id INTEGER, activity_u_per_mg REAL, temperature_c REAL, ph REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (enzyme_id) REFERENCES bio_enzymes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_hypocreales_enzyme_activity_assays_species_id ON ord_hypocreales_enzyme_activity_assays (species_id); CREATE INDEX ix_ord_hypocreales_enzyme_activity_assays_enzyme_id ON ord_hypocreales_enzyme_activity_assays (enzyme_id); CREATE TABLE ord_hypocreales_biocontrol_evaluations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, target_pest_text TEXT NOT NULL, efficacy_pct REAL, trial_setting TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_hypocreales_biocontrol_evaluations_species_id ON ord_hypocreales_biocontrol_evaluations (species_id); CREATE INDEX ix_ord_hypocreales_biocontrol_evaluations_publication_id ON ord_hypocreales_biocontrol_evaluations (publication_id); CREATE TABLE ord_hypocreales_regional_checklists ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, checklist_publication_id INTEGER, status TEXT, checklist_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (checklist_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_hypocreales_regional_checklists_species_id ON ord_hypocreales_regional_checklists (species_id); CREATE INDEX ix_ord_hypocreales_regional_checklists_country_id ON ord_hypocreales_regional_checklists (country_id); CREATE TABLE ord_xylariales_morphology ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, hymenium_color_at_maturity TEXT, context_color_at_maturity TEXT, characteristic_microstructure TEXT, diagnostic_features_text TEXT, notes_kohler_reaction TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_xylariales_morphology_specimen_id ON ord_xylariales_morphology (specimen_id); CREATE INDEX ix_ord_xylariales_morphology_species_id ON ord_xylariales_morphology (species_id); CREATE TABLE ord_xylariales_ecology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, dominant_habitat_id INTEGER, dominant_substrate_id INTEGER, dominant_biome_id INTEGER, trophic_strategy TEXT, typical_fruiting_period TEXT, known_distribution_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_habitat_id) REFERENCES eco_habitat_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_substrate_id) REFERENCES eco_substrate_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_biome_id) REFERENCES geo_biomes (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_xylariales_ecology_species_id ON ord_xylariales_ecology (species_id); CREATE INDEX ix_ord_xylariales_ecology_dominant_habitat_id ON ord_xylariales_ecology (dominant_habitat_id); CREATE TABLE ord_xylariales_phenology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, season_name TEXT, region_country_id INTEGER, first_doy INTEGER, peak_doy INTEGER, last_doy INTEGER, years_observed INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_xylariales_phenology_species_id ON ord_xylariales_phenology (species_id); CREATE INDEX ix_ord_xylariales_phenology_region_country_id ON ord_xylariales_phenology (region_country_id); CREATE TABLE ord_xylariales_host_associations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, association_type TEXT, specificity TEXT, evidence_publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (evidence_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_xylariales_host_associations_species_id ON ord_xylariales_host_associations (species_id); CREATE INDEX ix_ord_xylariales_host_associations_host_id ON ord_xylariales_host_associations (host_id); CREATE TABLE ord_xylariales_substrate_preferences ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, substrate_id INTEGER NOT NULL, preference_score REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (substrate_id) REFERENCES eco_substrate_types (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_xylariales_substrate_preferences_species_id ON ord_xylariales_substrate_preferences (species_id); CREATE INDEX ix_ord_xylariales_substrate_preferences_substrate_id ON ord_xylariales_substrate_preferences (substrate_id); CREATE TABLE ord_xylariales_geographic_distribution ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, occurrence_status TEXT, first_record_year INTEGER, record_count INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_xylariales_geographic_distribution_species_id ON ord_xylariales_geographic_distribution (species_id); CREATE INDEX ix_ord_xylariales_geographic_distribution_country_id ON ord_xylariales_geographic_distribution (country_id); CREATE TABLE ord_xylariales_phylogeny ( id INTEGER PRIMARY KEY AUTOINCREMENT, tree_id INTEGER NOT NULL, focal_genus_id INTEGER, publication_id INTEGER, notes_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (tree_id) REFERENCES phy_trees (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_xylariales_phylogeny_tree_id ON ord_xylariales_phylogeny (tree_id); CREATE INDEX ix_ord_xylariales_phylogeny_focal_genus_id ON ord_xylariales_phylogeny (focal_genus_id); CREATE TABLE ord_xylariales_genomics ( id INTEGER PRIMARY KEY AUTOINCREMENT, assembly_id INTEGER NOT NULL, species_id INTEGER, avg_genome_size_mb REAL, avg_gene_count INTEGER, avg_busco_complete_pct REAL, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (assembly_id) REFERENCES gen_assemblies (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_xylariales_genomics_assembly_id ON ord_xylariales_genomics (assembly_id); CREATE INDEX ix_ord_xylariales_genomics_species_id ON ord_xylariales_genomics (species_id); CREATE TABLE ord_xylariales_biochemistry ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, typicality TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_xylariales_biochemistry_species_id ON ord_xylariales_biochemistry (species_id); CREATE INDEX ix_ord_xylariales_biochemistry_compound_id ON ord_xylariales_biochemistry (compound_id); CREATE TABLE ord_xylariales_cultivation_notes ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, typical_growth_rate_mm_per_day REAL, preferred_media_type_id INTEGER, optimal_temperature_c REAL, difficulty_score INTEGER CHECK (difficulty_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (preferred_media_type_id) REFERENCES cul_media_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_xylariales_cultivation_notes_species_id ON ord_xylariales_cultivation_notes (species_id); CREATE INDEX ix_ord_xylariales_cultivation_notes_strain_id ON ord_xylariales_cultivation_notes (strain_id); CREATE TABLE ord_xylariales_pathogenicity ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, disease_id INTEGER, severity_score INTEGER CHECK (severity_score BETWEEN 1 AND 5), publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (disease_id) REFERENCES pat_diseases (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_xylariales_pathogenicity_species_id ON ord_xylariales_pathogenicity (species_id); CREATE INDEX ix_ord_xylariales_pathogenicity_host_id ON ord_xylariales_pathogenicity (host_id); CREATE TABLE ord_xylariales_edibility ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, edibility_class TEXT, preparation_notes TEXT, regional_tradition_country_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (regional_tradition_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_xylariales_edibility_species_id ON ord_xylariales_edibility (species_id); CREATE INDEX ix_ord_xylariales_edibility_regional_tradition_country_id ON ord_xylariales_edibility (regional_tradition_country_id); CREATE TABLE ord_xylariales_medicinal_uses ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, traditional_use_text TEXT, modern_evidence_level TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_xylariales_medicinal_uses_species_id ON ord_xylariales_medicinal_uses (species_id); CREATE INDEX ix_ord_xylariales_medicinal_uses_publication_id ON ord_xylariales_medicinal_uses (publication_id); CREATE TABLE ord_xylariales_taxonomic_revisions ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER NOT NULL, affected_family_id INTEGER, affected_genus_id INTEGER, revision_summary TEXT, revision_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_family_id) REFERENCES tax_families (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_xylariales_taxonomic_revisions_publication_id ON ord_xylariales_taxonomic_revisions (publication_id); CREATE INDEX ix_ord_xylariales_taxonomic_revisions_affected_family_id ON ord_xylariales_taxonomic_revisions (affected_family_id); CREATE TABLE ord_xylariales_conservation_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, national_redlist_category TEXT, habitat_pressure_text TEXT, last_assessment_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_xylariales_conservation_status_species_id ON ord_xylariales_conservation_status (species_id); CREATE INDEX ix_ord_xylariales_conservation_status_country_id ON ord_xylariales_conservation_status (country_id); CREATE TABLE ord_xylariales_diagnostic_keys ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER, key_title TEXT NOT NULL, region_country_id INTEGER, n_taxa_covered INTEGER, key_format TEXT, includes_microscopy INTEGER NOT NULL DEFAULT 0, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_xylariales_diagnostic_keys_publication_id ON ord_xylariales_diagnostic_keys (publication_id); CREATE INDEX ix_ord_xylariales_diagnostic_keys_region_country_id ON ord_xylariales_diagnostic_keys (region_country_id); CREATE TABLE ord_xylariales_type_species_register ( id INTEGER PRIMARY KEY AUTOINCREMENT, focal_genus_id INTEGER NOT NULL, type_species_id INTEGER, designation_publication_id INTEGER, designation_year INTEGER, designated_by_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (designation_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_xylariales_type_species_register_focal_genus_id ON ord_xylariales_type_species_register (focal_genus_id); CREATE INDEX ix_ord_xylariales_type_species_register_type_species_id ON ord_xylariales_type_species_register (type_species_id); CREATE TABLE ord_xylariales_distribution_grids ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, grid_cell_code TEXT NOT NULL, centroid_lat REAL, centroid_lon REAL, record_count INTEGER, first_record_year INTEGER, most_recent_record_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_xylariales_distribution_grids_species_id ON ord_xylariales_distribution_grids (species_id); CREATE INDEX ix_ord_xylariales_distribution_grids_country_id ON ord_xylariales_distribution_grids (country_id); CREATE TABLE ord_xylariales_microclimate_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER, publication_id INTEGER, substrate_temperature_c REAL, substrate_moisture_pct REAL, canopy_closure_pct REAL, photosynthetic_par_umol_m2_s REAL, days_post_rainfall INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_xylariales_microclimate_studies_species_id ON ord_xylariales_microclimate_studies (species_id); CREATE INDEX ix_ord_xylariales_microclimate_studies_publication_id ON ord_xylariales_microclimate_studies (publication_id); CREATE TABLE ord_xylariales_dna_barcoding_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, its_sequenced INTEGER NOT NULL DEFAULT 0, lsu_sequenced INTEGER NOT NULL DEFAULT 0, rpb2_sequenced INTEGER NOT NULL DEFAULT 0, ef1a_sequenced INTEGER NOT NULL DEFAULT 0, genome_assembled INTEGER NOT NULL DEFAULT 0, priority_for_sequencing_score INTEGER CHECK (priority_for_sequencing_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_xylariales_dna_barcoding_status_species_id ON ord_xylariales_dna_barcoding_status (species_id); CREATE TABLE ord_xylariales_spore_print_data ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, specimen_id INTEGER, print_color_label TEXT, print_color_chip_id INTEGER, spore_density_per_mm2 REAL, collection_substrate TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (print_color_chip_id) REFERENCES mor_color_chips (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_xylariales_spore_print_data_species_id ON ord_xylariales_spore_print_data (species_id); CREATE INDEX ix_ord_xylariales_spore_print_data_specimen_id ON ord_xylariales_spore_print_data (specimen_id); CREATE TABLE ord_xylariales_mating_systems ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, system_type TEXT, mating_loci_count INTEGER, publication_id INTEGER, notes_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_xylariales_mating_systems_species_id ON ord_xylariales_mating_systems (species_id); CREATE INDEX ix_ord_xylariales_mating_systems_publication_id ON ord_xylariales_mating_systems (publication_id); CREATE TABLE ord_xylariales_nutrient_uptake_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, nitrogen_source TEXT, carbon_source TEXT, growth_response TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_xylariales_nutrient_uptake_studies_species_id ON ord_xylariales_nutrient_uptake_studies (species_id); CREATE INDEX ix_ord_xylariales_nutrient_uptake_studies_strain_id ON ord_xylariales_nutrient_uptake_studies (strain_id); CREATE TABLE ord_xylariales_range_maps ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, polygon_file_uri TEXT NOT NULL, source_methodology TEXT, area_km2 REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_xylariales_range_maps_species_id ON ord_xylariales_range_maps (species_id); CREATE INDEX ix_ord_xylariales_range_maps_publication_id ON ord_xylariales_range_maps (publication_id); CREATE TABLE ord_xylariales_abundance_estimates ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, estimate_kind TEXT, value_min REAL, value_max REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_xylariales_abundance_estimates_species_id ON ord_xylariales_abundance_estimates (species_id); CREATE INDEX ix_ord_xylariales_abundance_estimates_country_id ON ord_xylariales_abundance_estimates (country_id); CREATE TABLE ord_xylariales_toxin_profiles ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, presence TEXT, typical_concentration_mg_per_kg REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_xylariales_toxin_profiles_species_id ON ord_xylariales_toxin_profiles (species_id); CREATE INDEX ix_ord_xylariales_toxin_profiles_compound_id ON ord_xylariales_toxin_profiles (compound_id); CREATE TABLE ord_xylariales_enzyme_activity_assays ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, enzyme_id INTEGER NOT NULL, strain_id INTEGER, activity_u_per_mg REAL, temperature_c REAL, ph REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (enzyme_id) REFERENCES bio_enzymes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_xylariales_enzyme_activity_assays_species_id ON ord_xylariales_enzyme_activity_assays (species_id); CREATE INDEX ix_ord_xylariales_enzyme_activity_assays_enzyme_id ON ord_xylariales_enzyme_activity_assays (enzyme_id); CREATE TABLE ord_xylariales_biocontrol_evaluations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, target_pest_text TEXT NOT NULL, efficacy_pct REAL, trial_setting TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_xylariales_biocontrol_evaluations_species_id ON ord_xylariales_biocontrol_evaluations (species_id); CREATE INDEX ix_ord_xylariales_biocontrol_evaluations_publication_id ON ord_xylariales_biocontrol_evaluations (publication_id); CREATE TABLE ord_xylariales_regional_checklists ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, checklist_publication_id INTEGER, status TEXT, checklist_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (checklist_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_xylariales_regional_checklists_species_id ON ord_xylariales_regional_checklists (species_id); CREATE INDEX ix_ord_xylariales_regional_checklists_country_id ON ord_xylariales_regional_checklists (country_id); CREATE TABLE ord_sordariales_morphology ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, hymenium_color_at_maturity TEXT, context_color_at_maturity TEXT, characteristic_microstructure TEXT, diagnostic_features_text TEXT, notes_kohler_reaction TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_sordariales_morphology_specimen_id ON ord_sordariales_morphology (specimen_id); CREATE INDEX ix_ord_sordariales_morphology_species_id ON ord_sordariales_morphology (species_id); CREATE TABLE ord_sordariales_ecology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, dominant_habitat_id INTEGER, dominant_substrate_id INTEGER, dominant_biome_id INTEGER, trophic_strategy TEXT, typical_fruiting_period TEXT, known_distribution_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_habitat_id) REFERENCES eco_habitat_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_substrate_id) REFERENCES eco_substrate_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_biome_id) REFERENCES geo_biomes (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_sordariales_ecology_species_id ON ord_sordariales_ecology (species_id); CREATE INDEX ix_ord_sordariales_ecology_dominant_habitat_id ON ord_sordariales_ecology (dominant_habitat_id); CREATE TABLE ord_sordariales_phenology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, season_name TEXT, region_country_id INTEGER, first_doy INTEGER, peak_doy INTEGER, last_doy INTEGER, years_observed INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_sordariales_phenology_species_id ON ord_sordariales_phenology (species_id); CREATE INDEX ix_ord_sordariales_phenology_region_country_id ON ord_sordariales_phenology (region_country_id); CREATE TABLE ord_sordariales_host_associations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, association_type TEXT, specificity TEXT, evidence_publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (evidence_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_sordariales_host_associations_species_id ON ord_sordariales_host_associations (species_id); CREATE INDEX ix_ord_sordariales_host_associations_host_id ON ord_sordariales_host_associations (host_id); CREATE TABLE ord_sordariales_substrate_preferences ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, substrate_id INTEGER NOT NULL, preference_score REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (substrate_id) REFERENCES eco_substrate_types (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_sordariales_substrate_preferences_species_id ON ord_sordariales_substrate_preferences (species_id); CREATE INDEX ix_ord_sordariales_substrate_preferences_substrate_id ON ord_sordariales_substrate_preferences (substrate_id); CREATE TABLE ord_sordariales_geographic_distribution ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, occurrence_status TEXT, first_record_year INTEGER, record_count INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_sordariales_geographic_distribution_species_id ON ord_sordariales_geographic_distribution (species_id); CREATE INDEX ix_ord_sordariales_geographic_distribution_country_id ON ord_sordariales_geographic_distribution (country_id); CREATE TABLE ord_sordariales_phylogeny ( id INTEGER PRIMARY KEY AUTOINCREMENT, tree_id INTEGER NOT NULL, focal_genus_id INTEGER, publication_id INTEGER, notes_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (tree_id) REFERENCES phy_trees (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_sordariales_phylogeny_tree_id ON ord_sordariales_phylogeny (tree_id); CREATE INDEX ix_ord_sordariales_phylogeny_focal_genus_id ON ord_sordariales_phylogeny (focal_genus_id); CREATE TABLE ord_sordariales_genomics ( id INTEGER PRIMARY KEY AUTOINCREMENT, assembly_id INTEGER NOT NULL, species_id INTEGER, avg_genome_size_mb REAL, avg_gene_count INTEGER, avg_busco_complete_pct REAL, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (assembly_id) REFERENCES gen_assemblies (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_sordariales_genomics_assembly_id ON ord_sordariales_genomics (assembly_id); CREATE INDEX ix_ord_sordariales_genomics_species_id ON ord_sordariales_genomics (species_id); CREATE TABLE ord_sordariales_biochemistry ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, typicality TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_sordariales_biochemistry_species_id ON ord_sordariales_biochemistry (species_id); CREATE INDEX ix_ord_sordariales_biochemistry_compound_id ON ord_sordariales_biochemistry (compound_id); CREATE TABLE ord_sordariales_cultivation_notes ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, typical_growth_rate_mm_per_day REAL, preferred_media_type_id INTEGER, optimal_temperature_c REAL, difficulty_score INTEGER CHECK (difficulty_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (preferred_media_type_id) REFERENCES cul_media_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_sordariales_cultivation_notes_species_id ON ord_sordariales_cultivation_notes (species_id); CREATE INDEX ix_ord_sordariales_cultivation_notes_strain_id ON ord_sordariales_cultivation_notes (strain_id); CREATE TABLE ord_sordariales_pathogenicity ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, disease_id INTEGER, severity_score INTEGER CHECK (severity_score BETWEEN 1 AND 5), publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (disease_id) REFERENCES pat_diseases (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_sordariales_pathogenicity_species_id ON ord_sordariales_pathogenicity (species_id); CREATE INDEX ix_ord_sordariales_pathogenicity_host_id ON ord_sordariales_pathogenicity (host_id); CREATE TABLE ord_sordariales_edibility ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, edibility_class TEXT, preparation_notes TEXT, regional_tradition_country_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (regional_tradition_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_sordariales_edibility_species_id ON ord_sordariales_edibility (species_id); CREATE INDEX ix_ord_sordariales_edibility_regional_tradition_country_id ON ord_sordariales_edibility (regional_tradition_country_id); CREATE TABLE ord_sordariales_medicinal_uses ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, traditional_use_text TEXT, modern_evidence_level TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_sordariales_medicinal_uses_species_id ON ord_sordariales_medicinal_uses (species_id); CREATE INDEX ix_ord_sordariales_medicinal_uses_publication_id ON ord_sordariales_medicinal_uses (publication_id); CREATE TABLE ord_sordariales_taxonomic_revisions ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER NOT NULL, affected_family_id INTEGER, affected_genus_id INTEGER, revision_summary TEXT, revision_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_family_id) REFERENCES tax_families (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_sordariales_taxonomic_revisions_publication_id ON ord_sordariales_taxonomic_revisions (publication_id); CREATE INDEX ix_ord_sordariales_taxonomic_revisions_affected_family_id ON ord_sordariales_taxonomic_revisions (affected_family_id); CREATE TABLE ord_sordariales_conservation_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, national_redlist_category TEXT, habitat_pressure_text TEXT, last_assessment_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_sordariales_conservation_status_species_id ON ord_sordariales_conservation_status (species_id); CREATE INDEX ix_ord_sordariales_conservation_status_country_id ON ord_sordariales_conservation_status (country_id); CREATE TABLE ord_sordariales_diagnostic_keys ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER, key_title TEXT NOT NULL, region_country_id INTEGER, n_taxa_covered INTEGER, key_format TEXT, includes_microscopy INTEGER NOT NULL DEFAULT 0, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_sordariales_diagnostic_keys_publication_id ON ord_sordariales_diagnostic_keys (publication_id); CREATE INDEX ix_ord_sordariales_diagnostic_keys_region_country_id ON ord_sordariales_diagnostic_keys (region_country_id); CREATE TABLE ord_sordariales_type_species_register ( id INTEGER PRIMARY KEY AUTOINCREMENT, focal_genus_id INTEGER NOT NULL, type_species_id INTEGER, designation_publication_id INTEGER, designation_year INTEGER, designated_by_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (designation_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_sordariales_type_species_register_focal_genus_id ON ord_sordariales_type_species_register (focal_genus_id); CREATE INDEX ix_ord_sordariales_type_species_register_type_species_id ON ord_sordariales_type_species_register (type_species_id); CREATE TABLE ord_sordariales_distribution_grids ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, grid_cell_code TEXT NOT NULL, centroid_lat REAL, centroid_lon REAL, record_count INTEGER, first_record_year INTEGER, most_recent_record_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_sordariales_distribution_grids_species_id ON ord_sordariales_distribution_grids (species_id); CREATE INDEX ix_ord_sordariales_distribution_grids_country_id ON ord_sordariales_distribution_grids (country_id); CREATE TABLE ord_sordariales_microclimate_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER, publication_id INTEGER, substrate_temperature_c REAL, substrate_moisture_pct REAL, canopy_closure_pct REAL, photosynthetic_par_umol_m2_s REAL, days_post_rainfall INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_sordariales_microclimate_studies_species_id ON ord_sordariales_microclimate_studies (species_id); CREATE INDEX ix_ord_sordariales_microclimate_studies_publication_id ON ord_sordariales_microclimate_studies (publication_id); CREATE TABLE ord_sordariales_dna_barcoding_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, its_sequenced INTEGER NOT NULL DEFAULT 0, lsu_sequenced INTEGER NOT NULL DEFAULT 0, rpb2_sequenced INTEGER NOT NULL DEFAULT 0, ef1a_sequenced INTEGER NOT NULL DEFAULT 0, genome_assembled INTEGER NOT NULL DEFAULT 0, priority_for_sequencing_score INTEGER CHECK (priority_for_sequencing_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_sordariales_dna_barcoding_status_species_id ON ord_sordariales_dna_barcoding_status (species_id); CREATE TABLE ord_sordariales_spore_print_data ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, specimen_id INTEGER, print_color_label TEXT, print_color_chip_id INTEGER, spore_density_per_mm2 REAL, collection_substrate TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (print_color_chip_id) REFERENCES mor_color_chips (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_sordariales_spore_print_data_species_id ON ord_sordariales_spore_print_data (species_id); CREATE INDEX ix_ord_sordariales_spore_print_data_specimen_id ON ord_sordariales_spore_print_data (specimen_id); CREATE TABLE ord_sordariales_mating_systems ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, system_type TEXT, mating_loci_count INTEGER, publication_id INTEGER, notes_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_sordariales_mating_systems_species_id ON ord_sordariales_mating_systems (species_id); CREATE INDEX ix_ord_sordariales_mating_systems_publication_id ON ord_sordariales_mating_systems (publication_id); CREATE TABLE ord_sordariales_nutrient_uptake_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, nitrogen_source TEXT, carbon_source TEXT, growth_response TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_sordariales_nutrient_uptake_studies_species_id ON ord_sordariales_nutrient_uptake_studies (species_id); CREATE INDEX ix_ord_sordariales_nutrient_uptake_studies_strain_id ON ord_sordariales_nutrient_uptake_studies (strain_id); CREATE TABLE ord_sordariales_range_maps ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, polygon_file_uri TEXT NOT NULL, source_methodology TEXT, area_km2 REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_sordariales_range_maps_species_id ON ord_sordariales_range_maps (species_id); CREATE INDEX ix_ord_sordariales_range_maps_publication_id ON ord_sordariales_range_maps (publication_id); CREATE TABLE ord_sordariales_abundance_estimates ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, estimate_kind TEXT, value_min REAL, value_max REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_sordariales_abundance_estimates_species_id ON ord_sordariales_abundance_estimates (species_id); CREATE INDEX ix_ord_sordariales_abundance_estimates_country_id ON ord_sordariales_abundance_estimates (country_id); CREATE TABLE ord_sordariales_toxin_profiles ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, presence TEXT, typical_concentration_mg_per_kg REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_sordariales_toxin_profiles_species_id ON ord_sordariales_toxin_profiles (species_id); CREATE INDEX ix_ord_sordariales_toxin_profiles_compound_id ON ord_sordariales_toxin_profiles (compound_id); CREATE TABLE ord_sordariales_enzyme_activity_assays ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, enzyme_id INTEGER NOT NULL, strain_id INTEGER, activity_u_per_mg REAL, temperature_c REAL, ph REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (enzyme_id) REFERENCES bio_enzymes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_sordariales_enzyme_activity_assays_species_id ON ord_sordariales_enzyme_activity_assays (species_id); CREATE INDEX ix_ord_sordariales_enzyme_activity_assays_enzyme_id ON ord_sordariales_enzyme_activity_assays (enzyme_id); CREATE TABLE ord_sordariales_biocontrol_evaluations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, target_pest_text TEXT NOT NULL, efficacy_pct REAL, trial_setting TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_sordariales_biocontrol_evaluations_species_id ON ord_sordariales_biocontrol_evaluations (species_id); CREATE INDEX ix_ord_sordariales_biocontrol_evaluations_publication_id ON ord_sordariales_biocontrol_evaluations (publication_id); CREATE TABLE ord_sordariales_regional_checklists ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, checklist_publication_id INTEGER, status TEXT, checklist_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (checklist_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_sordariales_regional_checklists_species_id ON ord_sordariales_regional_checklists (species_id); CREATE INDEX ix_ord_sordariales_regional_checklists_country_id ON ord_sordariales_regional_checklists (country_id); CREATE TABLE ord_diaporthales_morphology ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, hymenium_color_at_maturity TEXT, context_color_at_maturity TEXT, characteristic_microstructure TEXT, diagnostic_features_text TEXT, notes_kohler_reaction TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_diaporthales_morphology_specimen_id ON ord_diaporthales_morphology (specimen_id); CREATE INDEX ix_ord_diaporthales_morphology_species_id ON ord_diaporthales_morphology (species_id); CREATE TABLE ord_diaporthales_ecology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, dominant_habitat_id INTEGER, dominant_substrate_id INTEGER, dominant_biome_id INTEGER, trophic_strategy TEXT, typical_fruiting_period TEXT, known_distribution_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_habitat_id) REFERENCES eco_habitat_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_substrate_id) REFERENCES eco_substrate_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_biome_id) REFERENCES geo_biomes (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_diaporthales_ecology_species_id ON ord_diaporthales_ecology (species_id); CREATE INDEX ix_ord_diaporthales_ecology_dominant_habitat_id ON ord_diaporthales_ecology (dominant_habitat_id); CREATE TABLE ord_diaporthales_phenology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, season_name TEXT, region_country_id INTEGER, first_doy INTEGER, peak_doy INTEGER, last_doy INTEGER, years_observed INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_diaporthales_phenology_species_id ON ord_diaporthales_phenology (species_id); CREATE INDEX ix_ord_diaporthales_phenology_region_country_id ON ord_diaporthales_phenology (region_country_id); CREATE TABLE ord_diaporthales_host_associations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, association_type TEXT, specificity TEXT, evidence_publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (evidence_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_diaporthales_host_associations_species_id ON ord_diaporthales_host_associations (species_id); CREATE INDEX ix_ord_diaporthales_host_associations_host_id ON ord_diaporthales_host_associations (host_id); CREATE TABLE ord_diaporthales_substrate_preferences ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, substrate_id INTEGER NOT NULL, preference_score REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (substrate_id) REFERENCES eco_substrate_types (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_diaporthales_substrate_preferences_species_id ON ord_diaporthales_substrate_preferences (species_id); CREATE INDEX ix_ord_diaporthales_substrate_preferences_substrate_id ON ord_diaporthales_substrate_preferences (substrate_id); CREATE TABLE ord_diaporthales_geographic_distribution ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, occurrence_status TEXT, first_record_year INTEGER, record_count INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_diaporthales_geographic_distribution_species_id ON ord_diaporthales_geographic_distribution (species_id); CREATE INDEX ix_ord_diaporthales_geographic_distribution_country_id ON ord_diaporthales_geographic_distribution (country_id); CREATE TABLE ord_diaporthales_phylogeny ( id INTEGER PRIMARY KEY AUTOINCREMENT, tree_id INTEGER NOT NULL, focal_genus_id INTEGER, publication_id INTEGER, notes_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (tree_id) REFERENCES phy_trees (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_diaporthales_phylogeny_tree_id ON ord_diaporthales_phylogeny (tree_id); CREATE INDEX ix_ord_diaporthales_phylogeny_focal_genus_id ON ord_diaporthales_phylogeny (focal_genus_id); CREATE TABLE ord_diaporthales_genomics ( id INTEGER PRIMARY KEY AUTOINCREMENT, assembly_id INTEGER NOT NULL, species_id INTEGER, avg_genome_size_mb REAL, avg_gene_count INTEGER, avg_busco_complete_pct REAL, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (assembly_id) REFERENCES gen_assemblies (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_diaporthales_genomics_assembly_id ON ord_diaporthales_genomics (assembly_id); CREATE INDEX ix_ord_diaporthales_genomics_species_id ON ord_diaporthales_genomics (species_id); CREATE TABLE ord_diaporthales_biochemistry ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, typicality TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_diaporthales_biochemistry_species_id ON ord_diaporthales_biochemistry (species_id); CREATE INDEX ix_ord_diaporthales_biochemistry_compound_id ON ord_diaporthales_biochemistry (compound_id); CREATE TABLE ord_diaporthales_cultivation_notes ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, typical_growth_rate_mm_per_day REAL, preferred_media_type_id INTEGER, optimal_temperature_c REAL, difficulty_score INTEGER CHECK (difficulty_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (preferred_media_type_id) REFERENCES cul_media_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_diaporthales_cultivation_notes_species_id ON ord_diaporthales_cultivation_notes (species_id); CREATE INDEX ix_ord_diaporthales_cultivation_notes_strain_id ON ord_diaporthales_cultivation_notes (strain_id); CREATE TABLE ord_diaporthales_pathogenicity ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, disease_id INTEGER, severity_score INTEGER CHECK (severity_score BETWEEN 1 AND 5), publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (disease_id) REFERENCES pat_diseases (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_diaporthales_pathogenicity_species_id ON ord_diaporthales_pathogenicity (species_id); CREATE INDEX ix_ord_diaporthales_pathogenicity_host_id ON ord_diaporthales_pathogenicity (host_id); CREATE TABLE ord_diaporthales_edibility ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, edibility_class TEXT, preparation_notes TEXT, regional_tradition_country_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (regional_tradition_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_diaporthales_edibility_species_id ON ord_diaporthales_edibility (species_id); CREATE INDEX ix_ord_diaporthales_edibility_regional_tradition_country_id ON ord_diaporthales_edibility (regional_tradition_country_id); CREATE TABLE ord_diaporthales_medicinal_uses ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, traditional_use_text TEXT, modern_evidence_level TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_diaporthales_medicinal_uses_species_id ON ord_diaporthales_medicinal_uses (species_id); CREATE INDEX ix_ord_diaporthales_medicinal_uses_publication_id ON ord_diaporthales_medicinal_uses (publication_id); CREATE TABLE ord_diaporthales_taxonomic_revisions ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER NOT NULL, affected_family_id INTEGER, affected_genus_id INTEGER, revision_summary TEXT, revision_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_family_id) REFERENCES tax_families (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_diaporthales_taxonomic_revisions_publication_id ON ord_diaporthales_taxonomic_revisions (publication_id); CREATE INDEX ix_ord_diaporthales_taxonomic_revisions_affected_family_id ON ord_diaporthales_taxonomic_revisions (affected_family_id); CREATE TABLE ord_diaporthales_conservation_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, national_redlist_category TEXT, habitat_pressure_text TEXT, last_assessment_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_diaporthales_conservation_status_species_id ON ord_diaporthales_conservation_status (species_id); CREATE INDEX ix_ord_diaporthales_conservation_status_country_id ON ord_diaporthales_conservation_status (country_id); CREATE TABLE ord_diaporthales_diagnostic_keys ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER, key_title TEXT NOT NULL, region_country_id INTEGER, n_taxa_covered INTEGER, key_format TEXT, includes_microscopy INTEGER NOT NULL DEFAULT 0, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_diaporthales_diagnostic_keys_publication_id ON ord_diaporthales_diagnostic_keys (publication_id); CREATE INDEX ix_ord_diaporthales_diagnostic_keys_region_country_id ON ord_diaporthales_diagnostic_keys (region_country_id); CREATE TABLE ord_diaporthales_type_species_register ( id INTEGER PRIMARY KEY AUTOINCREMENT, focal_genus_id INTEGER NOT NULL, type_species_id INTEGER, designation_publication_id INTEGER, designation_year INTEGER, designated_by_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (designation_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_diaporthales_type_species_register_focal_genus_id ON ord_diaporthales_type_species_register (focal_genus_id); CREATE INDEX ix_ord_diaporthales_type_species_register_type_species_id ON ord_diaporthales_type_species_register (type_species_id); CREATE TABLE ord_diaporthales_distribution_grids ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, grid_cell_code TEXT NOT NULL, centroid_lat REAL, centroid_lon REAL, record_count INTEGER, first_record_year INTEGER, most_recent_record_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_diaporthales_distribution_grids_species_id ON ord_diaporthales_distribution_grids (species_id); CREATE INDEX ix_ord_diaporthales_distribution_grids_country_id ON ord_diaporthales_distribution_grids (country_id); CREATE TABLE ord_diaporthales_microclimate_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER, publication_id INTEGER, substrate_temperature_c REAL, substrate_moisture_pct REAL, canopy_closure_pct REAL, photosynthetic_par_umol_m2_s REAL, days_post_rainfall INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_diaporthales_microclimate_studies_species_id ON ord_diaporthales_microclimate_studies (species_id); CREATE INDEX ix_ord_diaporthales_microclimate_studies_publication_id ON ord_diaporthales_microclimate_studies (publication_id); CREATE TABLE ord_diaporthales_dna_barcoding_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, its_sequenced INTEGER NOT NULL DEFAULT 0, lsu_sequenced INTEGER NOT NULL DEFAULT 0, rpb2_sequenced INTEGER NOT NULL DEFAULT 0, ef1a_sequenced INTEGER NOT NULL DEFAULT 0, genome_assembled INTEGER NOT NULL DEFAULT 0, priority_for_sequencing_score INTEGER CHECK (priority_for_sequencing_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_diaporthales_dna_barcoding_status_species_id ON ord_diaporthales_dna_barcoding_status (species_id); CREATE TABLE ord_diaporthales_spore_print_data ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, specimen_id INTEGER, print_color_label TEXT, print_color_chip_id INTEGER, spore_density_per_mm2 REAL, collection_substrate TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (print_color_chip_id) REFERENCES mor_color_chips (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_diaporthales_spore_print_data_species_id ON ord_diaporthales_spore_print_data (species_id); CREATE INDEX ix_ord_diaporthales_spore_print_data_specimen_id ON ord_diaporthales_spore_print_data (specimen_id); CREATE TABLE ord_diaporthales_mating_systems ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, system_type TEXT, mating_loci_count INTEGER, publication_id INTEGER, notes_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_diaporthales_mating_systems_species_id ON ord_diaporthales_mating_systems (species_id); CREATE INDEX ix_ord_diaporthales_mating_systems_publication_id ON ord_diaporthales_mating_systems (publication_id); CREATE TABLE ord_diaporthales_nutrient_uptake_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, nitrogen_source TEXT, carbon_source TEXT, growth_response TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_diaporthales_nutrient_uptake_studies_species_id ON ord_diaporthales_nutrient_uptake_studies (species_id); CREATE INDEX ix_ord_diaporthales_nutrient_uptake_studies_strain_id ON ord_diaporthales_nutrient_uptake_studies (strain_id); CREATE TABLE ord_diaporthales_range_maps ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, polygon_file_uri TEXT NOT NULL, source_methodology TEXT, area_km2 REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_diaporthales_range_maps_species_id ON ord_diaporthales_range_maps (species_id); CREATE INDEX ix_ord_diaporthales_range_maps_publication_id ON ord_diaporthales_range_maps (publication_id); CREATE TABLE ord_diaporthales_abundance_estimates ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, estimate_kind TEXT, value_min REAL, value_max REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_diaporthales_abundance_estimates_species_id ON ord_diaporthales_abundance_estimates (species_id); CREATE INDEX ix_ord_diaporthales_abundance_estimates_country_id ON ord_diaporthales_abundance_estimates (country_id); CREATE TABLE ord_diaporthales_toxin_profiles ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, presence TEXT, typical_concentration_mg_per_kg REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_diaporthales_toxin_profiles_species_id ON ord_diaporthales_toxin_profiles (species_id); CREATE INDEX ix_ord_diaporthales_toxin_profiles_compound_id ON ord_diaporthales_toxin_profiles (compound_id); CREATE TABLE ord_diaporthales_enzyme_activity_assays ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, enzyme_id INTEGER NOT NULL, strain_id INTEGER, activity_u_per_mg REAL, temperature_c REAL, ph REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (enzyme_id) REFERENCES bio_enzymes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_diaporthales_enzyme_activity_assays_species_id ON ord_diaporthales_enzyme_activity_assays (species_id); CREATE INDEX ix_ord_diaporthales_enzyme_activity_assays_enzyme_id ON ord_diaporthales_enzyme_activity_assays (enzyme_id); CREATE TABLE ord_diaporthales_biocontrol_evaluations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, target_pest_text TEXT NOT NULL, efficacy_pct REAL, trial_setting TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_diaporthales_biocontrol_evaluations_species_id ON ord_diaporthales_biocontrol_evaluations (species_id); CREATE INDEX ix_ord_diaporthales_biocontrol_evaluations_publication_id ON ord_diaporthales_biocontrol_evaluations (publication_id); CREATE TABLE ord_diaporthales_regional_checklists ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, checklist_publication_id INTEGER, status TEXT, checklist_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (checklist_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_diaporthales_regional_checklists_species_id ON ord_diaporthales_regional_checklists (species_id); CREATE INDEX ix_ord_diaporthales_regional_checklists_country_id ON ord_diaporthales_regional_checklists (country_id); CREATE TABLE ord_magnaporthales_morphology ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, hymenium_color_at_maturity TEXT, context_color_at_maturity TEXT, characteristic_microstructure TEXT, diagnostic_features_text TEXT, notes_kohler_reaction TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_magnaporthales_morphology_specimen_id ON ord_magnaporthales_morphology (specimen_id); CREATE INDEX ix_ord_magnaporthales_morphology_species_id ON ord_magnaporthales_morphology (species_id); CREATE TABLE ord_magnaporthales_ecology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, dominant_habitat_id INTEGER, dominant_substrate_id INTEGER, dominant_biome_id INTEGER, trophic_strategy TEXT, typical_fruiting_period TEXT, known_distribution_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_habitat_id) REFERENCES eco_habitat_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_substrate_id) REFERENCES eco_substrate_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_biome_id) REFERENCES geo_biomes (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_magnaporthales_ecology_species_id ON ord_magnaporthales_ecology (species_id); CREATE INDEX ix_ord_magnaporthales_ecology_dominant_habitat_id ON ord_magnaporthales_ecology (dominant_habitat_id); CREATE TABLE ord_magnaporthales_phenology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, season_name TEXT, region_country_id INTEGER, first_doy INTEGER, peak_doy INTEGER, last_doy INTEGER, years_observed INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_magnaporthales_phenology_species_id ON ord_magnaporthales_phenology (species_id); CREATE INDEX ix_ord_magnaporthales_phenology_region_country_id ON ord_magnaporthales_phenology (region_country_id); CREATE TABLE ord_magnaporthales_host_associations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, association_type TEXT, specificity TEXT, evidence_publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (evidence_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_magnaporthales_host_associations_species_id ON ord_magnaporthales_host_associations (species_id); CREATE INDEX ix_ord_magnaporthales_host_associations_host_id ON ord_magnaporthales_host_associations (host_id); CREATE TABLE ord_magnaporthales_substrate_preferences ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, substrate_id INTEGER NOT NULL, preference_score REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (substrate_id) REFERENCES eco_substrate_types (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_magnaporthales_substrate_preferences_species_id ON ord_magnaporthales_substrate_preferences (species_id); CREATE INDEX ix_ord_magnaporthales_substrate_preferences_substrate_id ON ord_magnaporthales_substrate_preferences (substrate_id); CREATE TABLE ord_magnaporthales_geographic_distribution ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, occurrence_status TEXT, first_record_year INTEGER, record_count INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_magnaporthales_geographic_distribution_species_id ON ord_magnaporthales_geographic_distribution (species_id); CREATE INDEX ix_ord_magnaporthales_geographic_distribution_country_id ON ord_magnaporthales_geographic_distribution (country_id); CREATE TABLE ord_magnaporthales_phylogeny ( id INTEGER PRIMARY KEY AUTOINCREMENT, tree_id INTEGER NOT NULL, focal_genus_id INTEGER, publication_id INTEGER, notes_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (tree_id) REFERENCES phy_trees (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_magnaporthales_phylogeny_tree_id ON ord_magnaporthales_phylogeny (tree_id); CREATE INDEX ix_ord_magnaporthales_phylogeny_focal_genus_id ON ord_magnaporthales_phylogeny (focal_genus_id); CREATE TABLE ord_magnaporthales_genomics ( id INTEGER PRIMARY KEY AUTOINCREMENT, assembly_id INTEGER NOT NULL, species_id INTEGER, avg_genome_size_mb REAL, avg_gene_count INTEGER, avg_busco_complete_pct REAL, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (assembly_id) REFERENCES gen_assemblies (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_magnaporthales_genomics_assembly_id ON ord_magnaporthales_genomics (assembly_id); CREATE INDEX ix_ord_magnaporthales_genomics_species_id ON ord_magnaporthales_genomics (species_id); CREATE TABLE ord_magnaporthales_biochemistry ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, typicality TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_magnaporthales_biochemistry_species_id ON ord_magnaporthales_biochemistry (species_id); CREATE INDEX ix_ord_magnaporthales_biochemistry_compound_id ON ord_magnaporthales_biochemistry (compound_id); CREATE TABLE ord_magnaporthales_cultivation_notes ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, typical_growth_rate_mm_per_day REAL, preferred_media_type_id INTEGER, optimal_temperature_c REAL, difficulty_score INTEGER CHECK (difficulty_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (preferred_media_type_id) REFERENCES cul_media_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_magnaporthales_cultivation_notes_species_id ON ord_magnaporthales_cultivation_notes (species_id); CREATE INDEX ix_ord_magnaporthales_cultivation_notes_strain_id ON ord_magnaporthales_cultivation_notes (strain_id); CREATE TABLE ord_magnaporthales_pathogenicity ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, disease_id INTEGER, severity_score INTEGER CHECK (severity_score BETWEEN 1 AND 5), publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (disease_id) REFERENCES pat_diseases (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_magnaporthales_pathogenicity_species_id ON ord_magnaporthales_pathogenicity (species_id); CREATE INDEX ix_ord_magnaporthales_pathogenicity_host_id ON ord_magnaporthales_pathogenicity (host_id); CREATE TABLE ord_magnaporthales_edibility ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, edibility_class TEXT, preparation_notes TEXT, regional_tradition_country_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (regional_tradition_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_magnaporthales_edibility_species_id ON ord_magnaporthales_edibility (species_id); CREATE INDEX ix_ord_magnaporthales_edibility_1 ON ord_magnaporthales_edibility (regional_tradition_country_id); CREATE TABLE ord_magnaporthales_medicinal_uses ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, traditional_use_text TEXT, modern_evidence_level TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_magnaporthales_medicinal_uses_species_id ON ord_magnaporthales_medicinal_uses (species_id); CREATE INDEX ix_ord_magnaporthales_medicinal_uses_publication_id ON ord_magnaporthales_medicinal_uses (publication_id); CREATE TABLE ord_magnaporthales_taxonomic_revisions ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER NOT NULL, affected_family_id INTEGER, affected_genus_id INTEGER, revision_summary TEXT, revision_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_family_id) REFERENCES tax_families (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_magnaporthales_taxonomic_revisions_publication_id ON ord_magnaporthales_taxonomic_revisions (publication_id); CREATE INDEX ix_ord_magnaporthales_taxonomic_revisions_affected_family_id ON ord_magnaporthales_taxonomic_revisions (affected_family_id); CREATE TABLE ord_magnaporthales_conservation_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, national_redlist_category TEXT, habitat_pressure_text TEXT, last_assessment_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_magnaporthales_conservation_status_species_id ON ord_magnaporthales_conservation_status (species_id); CREATE INDEX ix_ord_magnaporthales_conservation_status_country_id ON ord_magnaporthales_conservation_status (country_id); CREATE TABLE ord_magnaporthales_diagnostic_keys ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER, key_title TEXT NOT NULL, region_country_id INTEGER, n_taxa_covered INTEGER, key_format TEXT, includes_microscopy INTEGER NOT NULL DEFAULT 0, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_magnaporthales_diagnostic_keys_publication_id ON ord_magnaporthales_diagnostic_keys (publication_id); CREATE INDEX ix_ord_magnaporthales_diagnostic_keys_region_country_id ON ord_magnaporthales_diagnostic_keys (region_country_id); CREATE TABLE ord_magnaporthales_type_species_register ( id INTEGER PRIMARY KEY AUTOINCREMENT, focal_genus_id INTEGER NOT NULL, type_species_id INTEGER, designation_publication_id INTEGER, designation_year INTEGER, designated_by_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (designation_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_magnaporthales_type_species_register_focal_genus_id ON ord_magnaporthales_type_species_register (focal_genus_id); CREATE INDEX ix_ord_magnaporthales_type_species_register_type_species_id ON ord_magnaporthales_type_species_register (type_species_id); CREATE TABLE ord_magnaporthales_distribution_grids ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, grid_cell_code TEXT NOT NULL, centroid_lat REAL, centroid_lon REAL, record_count INTEGER, first_record_year INTEGER, most_recent_record_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_magnaporthales_distribution_grids_species_id ON ord_magnaporthales_distribution_grids (species_id); CREATE INDEX ix_ord_magnaporthales_distribution_grids_country_id ON ord_magnaporthales_distribution_grids (country_id); CREATE TABLE ord_magnaporthales_microclimate_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER, publication_id INTEGER, substrate_temperature_c REAL, substrate_moisture_pct REAL, canopy_closure_pct REAL, photosynthetic_par_umol_m2_s REAL, days_post_rainfall INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_magnaporthales_microclimate_studies_species_id ON ord_magnaporthales_microclimate_studies (species_id); CREATE INDEX ix_ord_magnaporthales_microclimate_studies_publication_id ON ord_magnaporthales_microclimate_studies (publication_id); CREATE TABLE ord_magnaporthales_dna_barcoding_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, its_sequenced INTEGER NOT NULL DEFAULT 0, lsu_sequenced INTEGER NOT NULL DEFAULT 0, rpb2_sequenced INTEGER NOT NULL DEFAULT 0, ef1a_sequenced INTEGER NOT NULL DEFAULT 0, genome_assembled INTEGER NOT NULL DEFAULT 0, priority_for_sequencing_score INTEGER CHECK (priority_for_sequencing_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_magnaporthales_dna_barcoding_status_species_id ON ord_magnaporthales_dna_barcoding_status (species_id); CREATE TABLE ord_magnaporthales_spore_print_data ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, specimen_id INTEGER, print_color_label TEXT, print_color_chip_id INTEGER, spore_density_per_mm2 REAL, collection_substrate TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (print_color_chip_id) REFERENCES mor_color_chips (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_magnaporthales_spore_print_data_species_id ON ord_magnaporthales_spore_print_data (species_id); CREATE INDEX ix_ord_magnaporthales_spore_print_data_specimen_id ON ord_magnaporthales_spore_print_data (specimen_id); CREATE TABLE ord_magnaporthales_mating_systems ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, system_type TEXT, mating_loci_count INTEGER, publication_id INTEGER, notes_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_magnaporthales_mating_systems_species_id ON ord_magnaporthales_mating_systems (species_id); CREATE INDEX ix_ord_magnaporthales_mating_systems_publication_id ON ord_magnaporthales_mating_systems (publication_id); CREATE TABLE ord_magnaporthales_nutrient_uptake_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, nitrogen_source TEXT, carbon_source TEXT, growth_response TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_magnaporthales_nutrient_uptake_studies_species_id ON ord_magnaporthales_nutrient_uptake_studies (species_id); CREATE INDEX ix_ord_magnaporthales_nutrient_uptake_studies_strain_id ON ord_magnaporthales_nutrient_uptake_studies (strain_id); CREATE TABLE ord_magnaporthales_range_maps ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, polygon_file_uri TEXT NOT NULL, source_methodology TEXT, area_km2 REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_magnaporthales_range_maps_species_id ON ord_magnaporthales_range_maps (species_id); CREATE INDEX ix_ord_magnaporthales_range_maps_publication_id ON ord_magnaporthales_range_maps (publication_id); CREATE TABLE ord_magnaporthales_abundance_estimates ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, estimate_kind TEXT, value_min REAL, value_max REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_magnaporthales_abundance_estimates_species_id ON ord_magnaporthales_abundance_estimates (species_id); CREATE INDEX ix_ord_magnaporthales_abundance_estimates_country_id ON ord_magnaporthales_abundance_estimates (country_id); CREATE TABLE ord_magnaporthales_toxin_profiles ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, presence TEXT, typical_concentration_mg_per_kg REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_magnaporthales_toxin_profiles_species_id ON ord_magnaporthales_toxin_profiles (species_id); CREATE INDEX ix_ord_magnaporthales_toxin_profiles_compound_id ON ord_magnaporthales_toxin_profiles (compound_id); CREATE TABLE ord_magnaporthales_enzyme_activity_assays ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, enzyme_id INTEGER NOT NULL, strain_id INTEGER, activity_u_per_mg REAL, temperature_c REAL, ph REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (enzyme_id) REFERENCES bio_enzymes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_magnaporthales_enzyme_activity_assays_species_id ON ord_magnaporthales_enzyme_activity_assays (species_id); CREATE INDEX ix_ord_magnaporthales_enzyme_activity_assays_enzyme_id ON ord_magnaporthales_enzyme_activity_assays (enzyme_id); CREATE TABLE ord_magnaporthales_biocontrol_evaluations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, target_pest_text TEXT NOT NULL, efficacy_pct REAL, trial_setting TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_magnaporthales_biocontrol_evaluations_species_id ON ord_magnaporthales_biocontrol_evaluations (species_id); CREATE INDEX ix_ord_magnaporthales_biocontrol_evaluations_publication_id ON ord_magnaporthales_biocontrol_evaluations (publication_id); CREATE TABLE ord_magnaporthales_regional_checklists ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, checklist_publication_id INTEGER, status TEXT, checklist_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (checklist_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_magnaporthales_regional_checklists_species_id ON ord_magnaporthales_regional_checklists (species_id); CREATE INDEX ix_ord_magnaporthales_regional_checklists_country_id ON ord_magnaporthales_regional_checklists (country_id); CREATE TABLE ord_ophiostomatales_morphology ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, hymenium_color_at_maturity TEXT, context_color_at_maturity TEXT, characteristic_microstructure TEXT, diagnostic_features_text TEXT, notes_kohler_reaction TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ophiostomatales_morphology_specimen_id ON ord_ophiostomatales_morphology (specimen_id); CREATE INDEX ix_ord_ophiostomatales_morphology_species_id ON ord_ophiostomatales_morphology (species_id); CREATE TABLE ord_ophiostomatales_ecology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, dominant_habitat_id INTEGER, dominant_substrate_id INTEGER, dominant_biome_id INTEGER, trophic_strategy TEXT, typical_fruiting_period TEXT, known_distribution_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_habitat_id) REFERENCES eco_habitat_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_substrate_id) REFERENCES eco_substrate_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_biome_id) REFERENCES geo_biomes (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ophiostomatales_ecology_species_id ON ord_ophiostomatales_ecology (species_id); CREATE INDEX ix_ord_ophiostomatales_ecology_dominant_habitat_id ON ord_ophiostomatales_ecology (dominant_habitat_id); CREATE TABLE ord_ophiostomatales_phenology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, season_name TEXT, region_country_id INTEGER, first_doy INTEGER, peak_doy INTEGER, last_doy INTEGER, years_observed INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ophiostomatales_phenology_species_id ON ord_ophiostomatales_phenology (species_id); CREATE INDEX ix_ord_ophiostomatales_phenology_region_country_id ON ord_ophiostomatales_phenology (region_country_id); CREATE TABLE ord_ophiostomatales_host_associations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, association_type TEXT, specificity TEXT, evidence_publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (evidence_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ophiostomatales_host_associations_species_id ON ord_ophiostomatales_host_associations (species_id); CREATE INDEX ix_ord_ophiostomatales_host_associations_host_id ON ord_ophiostomatales_host_associations (host_id); CREATE TABLE ord_ophiostomatales_substrate_preferences ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, substrate_id INTEGER NOT NULL, preference_score REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (substrate_id) REFERENCES eco_substrate_types (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ophiostomatales_substrate_preferences_species_id ON ord_ophiostomatales_substrate_preferences (species_id); CREATE INDEX ix_ord_ophiostomatales_substrate_preferences_substrate_id ON ord_ophiostomatales_substrate_preferences (substrate_id); CREATE TABLE ord_ophiostomatales_geographic_distribution ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, occurrence_status TEXT, first_record_year INTEGER, record_count INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ophiostomatales_geographic_distribution_species_id ON ord_ophiostomatales_geographic_distribution (species_id); CREATE INDEX ix_ord_ophiostomatales_geographic_distribution_country_id ON ord_ophiostomatales_geographic_distribution (country_id); CREATE TABLE ord_ophiostomatales_phylogeny ( id INTEGER PRIMARY KEY AUTOINCREMENT, tree_id INTEGER NOT NULL, focal_genus_id INTEGER, publication_id INTEGER, notes_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (tree_id) REFERENCES phy_trees (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ophiostomatales_phylogeny_tree_id ON ord_ophiostomatales_phylogeny (tree_id); CREATE INDEX ix_ord_ophiostomatales_phylogeny_focal_genus_id ON ord_ophiostomatales_phylogeny (focal_genus_id); CREATE TABLE ord_ophiostomatales_genomics ( id INTEGER PRIMARY KEY AUTOINCREMENT, assembly_id INTEGER NOT NULL, species_id INTEGER, avg_genome_size_mb REAL, avg_gene_count INTEGER, avg_busco_complete_pct REAL, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (assembly_id) REFERENCES gen_assemblies (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ophiostomatales_genomics_assembly_id ON ord_ophiostomatales_genomics (assembly_id); CREATE INDEX ix_ord_ophiostomatales_genomics_species_id ON ord_ophiostomatales_genomics (species_id); CREATE TABLE ord_ophiostomatales_biochemistry ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, typicality TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ophiostomatales_biochemistry_species_id ON ord_ophiostomatales_biochemistry (species_id); CREATE INDEX ix_ord_ophiostomatales_biochemistry_compound_id ON ord_ophiostomatales_biochemistry (compound_id); CREATE TABLE ord_ophiostomatales_cultivation_notes ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, typical_growth_rate_mm_per_day REAL, preferred_media_type_id INTEGER, optimal_temperature_c REAL, difficulty_score INTEGER CHECK (difficulty_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (preferred_media_type_id) REFERENCES cul_media_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ophiostomatales_cultivation_notes_species_id ON ord_ophiostomatales_cultivation_notes (species_id); CREATE INDEX ix_ord_ophiostomatales_cultivation_notes_strain_id ON ord_ophiostomatales_cultivation_notes (strain_id); CREATE TABLE ord_ophiostomatales_pathogenicity ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, disease_id INTEGER, severity_score INTEGER CHECK (severity_score BETWEEN 1 AND 5), publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (disease_id) REFERENCES pat_diseases (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ophiostomatales_pathogenicity_species_id ON ord_ophiostomatales_pathogenicity (species_id); CREATE INDEX ix_ord_ophiostomatales_pathogenicity_host_id ON ord_ophiostomatales_pathogenicity (host_id); CREATE TABLE ord_ophiostomatales_edibility ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, edibility_class TEXT, preparation_notes TEXT, regional_tradition_country_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (regional_tradition_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ophiostomatales_edibility_species_id ON ord_ophiostomatales_edibility (species_id); CREATE INDEX ix_ord_ophiostomatales_edibility_1 ON ord_ophiostomatales_edibility (regional_tradition_country_id); CREATE TABLE ord_ophiostomatales_medicinal_uses ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, traditional_use_text TEXT, modern_evidence_level TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ophiostomatales_medicinal_uses_species_id ON ord_ophiostomatales_medicinal_uses (species_id); CREATE INDEX ix_ord_ophiostomatales_medicinal_uses_publication_id ON ord_ophiostomatales_medicinal_uses (publication_id); CREATE TABLE ord_ophiostomatales_taxonomic_revisions ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER NOT NULL, affected_family_id INTEGER, affected_genus_id INTEGER, revision_summary TEXT, revision_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_family_id) REFERENCES tax_families (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ophiostomatales_taxonomic_revisions_publication_id ON ord_ophiostomatales_taxonomic_revisions (publication_id); CREATE INDEX ix_ord_ophiostomatales_taxonomic_revisions_1 ON ord_ophiostomatales_taxonomic_revisions (affected_family_id); CREATE TABLE ord_ophiostomatales_conservation_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, national_redlist_category TEXT, habitat_pressure_text TEXT, last_assessment_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ophiostomatales_conservation_status_species_id ON ord_ophiostomatales_conservation_status (species_id); CREATE INDEX ix_ord_ophiostomatales_conservation_status_country_id ON ord_ophiostomatales_conservation_status (country_id); CREATE TABLE ord_ophiostomatales_diagnostic_keys ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER, key_title TEXT NOT NULL, region_country_id INTEGER, n_taxa_covered INTEGER, key_format TEXT, includes_microscopy INTEGER NOT NULL DEFAULT 0, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ophiostomatales_diagnostic_keys_publication_id ON ord_ophiostomatales_diagnostic_keys (publication_id); CREATE INDEX ix_ord_ophiostomatales_diagnostic_keys_region_country_id ON ord_ophiostomatales_diagnostic_keys (region_country_id); CREATE TABLE ord_ophiostomatales_type_species_register ( id INTEGER PRIMARY KEY AUTOINCREMENT, focal_genus_id INTEGER NOT NULL, type_species_id INTEGER, designation_publication_id INTEGER, designation_year INTEGER, designated_by_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (designation_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ophiostomatales_type_species_register_focal_genus_id ON ord_ophiostomatales_type_species_register (focal_genus_id); CREATE INDEX ix_ord_ophiostomatales_type_species_register_type_species_id ON ord_ophiostomatales_type_species_register (type_species_id); CREATE TABLE ord_ophiostomatales_distribution_grids ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, grid_cell_code TEXT NOT NULL, centroid_lat REAL, centroid_lon REAL, record_count INTEGER, first_record_year INTEGER, most_recent_record_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ophiostomatales_distribution_grids_species_id ON ord_ophiostomatales_distribution_grids (species_id); CREATE INDEX ix_ord_ophiostomatales_distribution_grids_country_id ON ord_ophiostomatales_distribution_grids (country_id); CREATE TABLE ord_ophiostomatales_microclimate_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER, publication_id INTEGER, substrate_temperature_c REAL, substrate_moisture_pct REAL, canopy_closure_pct REAL, photosynthetic_par_umol_m2_s REAL, days_post_rainfall INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ophiostomatales_microclimate_studies_species_id ON ord_ophiostomatales_microclimate_studies (species_id); CREATE INDEX ix_ord_ophiostomatales_microclimate_studies_publication_id ON ord_ophiostomatales_microclimate_studies (publication_id); CREATE TABLE ord_ophiostomatales_dna_barcoding_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, its_sequenced INTEGER NOT NULL DEFAULT 0, lsu_sequenced INTEGER NOT NULL DEFAULT 0, rpb2_sequenced INTEGER NOT NULL DEFAULT 0, ef1a_sequenced INTEGER NOT NULL DEFAULT 0, genome_assembled INTEGER NOT NULL DEFAULT 0, priority_for_sequencing_score INTEGER CHECK (priority_for_sequencing_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ophiostomatales_dna_barcoding_status_species_id ON ord_ophiostomatales_dna_barcoding_status (species_id); CREATE TABLE ord_ophiostomatales_spore_print_data ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, specimen_id INTEGER, print_color_label TEXT, print_color_chip_id INTEGER, spore_density_per_mm2 REAL, collection_substrate TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (print_color_chip_id) REFERENCES mor_color_chips (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ophiostomatales_spore_print_data_species_id ON ord_ophiostomatales_spore_print_data (species_id); CREATE INDEX ix_ord_ophiostomatales_spore_print_data_specimen_id ON ord_ophiostomatales_spore_print_data (specimen_id); CREATE TABLE ord_ophiostomatales_mating_systems ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, system_type TEXT, mating_loci_count INTEGER, publication_id INTEGER, notes_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ophiostomatales_mating_systems_species_id ON ord_ophiostomatales_mating_systems (species_id); CREATE INDEX ix_ord_ophiostomatales_mating_systems_publication_id ON ord_ophiostomatales_mating_systems (publication_id); CREATE TABLE ord_ophiostomatales_nutrient_uptake_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, nitrogen_source TEXT, carbon_source TEXT, growth_response TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ophiostomatales_nutrient_uptake_studies_species_id ON ord_ophiostomatales_nutrient_uptake_studies (species_id); CREATE INDEX ix_ord_ophiostomatales_nutrient_uptake_studies_strain_id ON ord_ophiostomatales_nutrient_uptake_studies (strain_id); CREATE TABLE ord_ophiostomatales_range_maps ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, polygon_file_uri TEXT NOT NULL, source_methodology TEXT, area_km2 REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ophiostomatales_range_maps_species_id ON ord_ophiostomatales_range_maps (species_id); CREATE INDEX ix_ord_ophiostomatales_range_maps_publication_id ON ord_ophiostomatales_range_maps (publication_id); CREATE TABLE ord_ophiostomatales_abundance_estimates ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, estimate_kind TEXT, value_min REAL, value_max REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ophiostomatales_abundance_estimates_species_id ON ord_ophiostomatales_abundance_estimates (species_id); CREATE INDEX ix_ord_ophiostomatales_abundance_estimates_country_id ON ord_ophiostomatales_abundance_estimates (country_id); CREATE TABLE ord_ophiostomatales_toxin_profiles ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, presence TEXT, typical_concentration_mg_per_kg REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ophiostomatales_toxin_profiles_species_id ON ord_ophiostomatales_toxin_profiles (species_id); CREATE INDEX ix_ord_ophiostomatales_toxin_profiles_compound_id ON ord_ophiostomatales_toxin_profiles (compound_id); CREATE TABLE ord_ophiostomatales_enzyme_activity_assays ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, enzyme_id INTEGER NOT NULL, strain_id INTEGER, activity_u_per_mg REAL, temperature_c REAL, ph REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (enzyme_id) REFERENCES bio_enzymes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ophiostomatales_enzyme_activity_assays_species_id ON ord_ophiostomatales_enzyme_activity_assays (species_id); CREATE INDEX ix_ord_ophiostomatales_enzyme_activity_assays_enzyme_id ON ord_ophiostomatales_enzyme_activity_assays (enzyme_id); CREATE TABLE ord_ophiostomatales_biocontrol_evaluations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, target_pest_text TEXT NOT NULL, efficacy_pct REAL, trial_setting TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ophiostomatales_biocontrol_evaluations_species_id ON ord_ophiostomatales_biocontrol_evaluations (species_id); CREATE INDEX ix_ord_ophiostomatales_biocontrol_evaluations_publication_id ON ord_ophiostomatales_biocontrol_evaluations (publication_id); CREATE TABLE ord_ophiostomatales_regional_checklists ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, checklist_publication_id INTEGER, status TEXT, checklist_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (checklist_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ophiostomatales_regional_checklists_species_id ON ord_ophiostomatales_regional_checklists (species_id); CREATE INDEX ix_ord_ophiostomatales_regional_checklists_country_id ON ord_ophiostomatales_regional_checklists (country_id); CREATE TABLE ord_lecanorales_morphology ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, hymenium_color_at_maturity TEXT, context_color_at_maturity TEXT, characteristic_microstructure TEXT, diagnostic_features_text TEXT, notes_kohler_reaction TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lecanorales_morphology_specimen_id ON ord_lecanorales_morphology (specimen_id); CREATE INDEX ix_ord_lecanorales_morphology_species_id ON ord_lecanorales_morphology (species_id); CREATE TABLE ord_lecanorales_ecology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, dominant_habitat_id INTEGER, dominant_substrate_id INTEGER, dominant_biome_id INTEGER, trophic_strategy TEXT, typical_fruiting_period TEXT, known_distribution_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_habitat_id) REFERENCES eco_habitat_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_substrate_id) REFERENCES eco_substrate_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_biome_id) REFERENCES geo_biomes (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lecanorales_ecology_species_id ON ord_lecanorales_ecology (species_id); CREATE INDEX ix_ord_lecanorales_ecology_dominant_habitat_id ON ord_lecanorales_ecology (dominant_habitat_id); CREATE TABLE ord_lecanorales_phenology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, season_name TEXT, region_country_id INTEGER, first_doy INTEGER, peak_doy INTEGER, last_doy INTEGER, years_observed INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lecanorales_phenology_species_id ON ord_lecanorales_phenology (species_id); CREATE INDEX ix_ord_lecanorales_phenology_region_country_id ON ord_lecanorales_phenology (region_country_id); CREATE TABLE ord_lecanorales_host_associations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, association_type TEXT, specificity TEXT, evidence_publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (evidence_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lecanorales_host_associations_species_id ON ord_lecanorales_host_associations (species_id); CREATE INDEX ix_ord_lecanorales_host_associations_host_id ON ord_lecanorales_host_associations (host_id); CREATE TABLE ord_lecanorales_substrate_preferences ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, substrate_id INTEGER NOT NULL, preference_score REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (substrate_id) REFERENCES eco_substrate_types (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lecanorales_substrate_preferences_species_id ON ord_lecanorales_substrate_preferences (species_id); CREATE INDEX ix_ord_lecanorales_substrate_preferences_substrate_id ON ord_lecanorales_substrate_preferences (substrate_id); CREATE TABLE ord_lecanorales_geographic_distribution ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, occurrence_status TEXT, first_record_year INTEGER, record_count INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lecanorales_geographic_distribution_species_id ON ord_lecanorales_geographic_distribution (species_id); CREATE INDEX ix_ord_lecanorales_geographic_distribution_country_id ON ord_lecanorales_geographic_distribution (country_id); CREATE TABLE ord_lecanorales_phylogeny ( id INTEGER PRIMARY KEY AUTOINCREMENT, tree_id INTEGER NOT NULL, focal_genus_id INTEGER, publication_id INTEGER, notes_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (tree_id) REFERENCES phy_trees (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lecanorales_phylogeny_tree_id ON ord_lecanorales_phylogeny (tree_id); CREATE INDEX ix_ord_lecanorales_phylogeny_focal_genus_id ON ord_lecanorales_phylogeny (focal_genus_id); CREATE TABLE ord_lecanorales_genomics ( id INTEGER PRIMARY KEY AUTOINCREMENT, assembly_id INTEGER NOT NULL, species_id INTEGER, avg_genome_size_mb REAL, avg_gene_count INTEGER, avg_busco_complete_pct REAL, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (assembly_id) REFERENCES gen_assemblies (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lecanorales_genomics_assembly_id ON ord_lecanorales_genomics (assembly_id); CREATE INDEX ix_ord_lecanorales_genomics_species_id ON ord_lecanorales_genomics (species_id); CREATE TABLE ord_lecanorales_biochemistry ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, typicality TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lecanorales_biochemistry_species_id ON ord_lecanorales_biochemistry (species_id); CREATE INDEX ix_ord_lecanorales_biochemistry_compound_id ON ord_lecanorales_biochemistry (compound_id); CREATE TABLE ord_lecanorales_cultivation_notes ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, typical_growth_rate_mm_per_day REAL, preferred_media_type_id INTEGER, optimal_temperature_c REAL, difficulty_score INTEGER CHECK (difficulty_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (preferred_media_type_id) REFERENCES cul_media_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lecanorales_cultivation_notes_species_id ON ord_lecanorales_cultivation_notes (species_id); CREATE INDEX ix_ord_lecanorales_cultivation_notes_strain_id ON ord_lecanorales_cultivation_notes (strain_id); CREATE TABLE ord_lecanorales_pathogenicity ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, disease_id INTEGER, severity_score INTEGER CHECK (severity_score BETWEEN 1 AND 5), publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (disease_id) REFERENCES pat_diseases (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lecanorales_pathogenicity_species_id ON ord_lecanorales_pathogenicity (species_id); CREATE INDEX ix_ord_lecanorales_pathogenicity_host_id ON ord_lecanorales_pathogenicity (host_id); CREATE TABLE ord_lecanorales_edibility ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, edibility_class TEXT, preparation_notes TEXT, regional_tradition_country_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (regional_tradition_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lecanorales_edibility_species_id ON ord_lecanorales_edibility (species_id); CREATE INDEX ix_ord_lecanorales_edibility_regional_tradition_country_id ON ord_lecanorales_edibility (regional_tradition_country_id); CREATE TABLE ord_lecanorales_medicinal_uses ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, traditional_use_text TEXT, modern_evidence_level TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lecanorales_medicinal_uses_species_id ON ord_lecanorales_medicinal_uses (species_id); CREATE INDEX ix_ord_lecanorales_medicinal_uses_publication_id ON ord_lecanorales_medicinal_uses (publication_id); CREATE TABLE ord_lecanorales_taxonomic_revisions ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER NOT NULL, affected_family_id INTEGER, affected_genus_id INTEGER, revision_summary TEXT, revision_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_family_id) REFERENCES tax_families (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lecanorales_taxonomic_revisions_publication_id ON ord_lecanorales_taxonomic_revisions (publication_id); CREATE INDEX ix_ord_lecanorales_taxonomic_revisions_affected_family_id ON ord_lecanorales_taxonomic_revisions (affected_family_id); CREATE TABLE ord_lecanorales_conservation_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, national_redlist_category TEXT, habitat_pressure_text TEXT, last_assessment_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lecanorales_conservation_status_species_id ON ord_lecanorales_conservation_status (species_id); CREATE INDEX ix_ord_lecanorales_conservation_status_country_id ON ord_lecanorales_conservation_status (country_id); CREATE TABLE ord_lecanorales_diagnostic_keys ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER, key_title TEXT NOT NULL, region_country_id INTEGER, n_taxa_covered INTEGER, key_format TEXT, includes_microscopy INTEGER NOT NULL DEFAULT 0, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lecanorales_diagnostic_keys_publication_id ON ord_lecanorales_diagnostic_keys (publication_id); CREATE INDEX ix_ord_lecanorales_diagnostic_keys_region_country_id ON ord_lecanorales_diagnostic_keys (region_country_id); CREATE TABLE ord_lecanorales_type_species_register ( id INTEGER PRIMARY KEY AUTOINCREMENT, focal_genus_id INTEGER NOT NULL, type_species_id INTEGER, designation_publication_id INTEGER, designation_year INTEGER, designated_by_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (designation_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lecanorales_type_species_register_focal_genus_id ON ord_lecanorales_type_species_register (focal_genus_id); CREATE INDEX ix_ord_lecanorales_type_species_register_type_species_id ON ord_lecanorales_type_species_register (type_species_id); CREATE TABLE ord_lecanorales_distribution_grids ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, grid_cell_code TEXT NOT NULL, centroid_lat REAL, centroid_lon REAL, record_count INTEGER, first_record_year INTEGER, most_recent_record_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lecanorales_distribution_grids_species_id ON ord_lecanorales_distribution_grids (species_id); CREATE INDEX ix_ord_lecanorales_distribution_grids_country_id ON ord_lecanorales_distribution_grids (country_id); CREATE TABLE ord_lecanorales_microclimate_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER, publication_id INTEGER, substrate_temperature_c REAL, substrate_moisture_pct REAL, canopy_closure_pct REAL, photosynthetic_par_umol_m2_s REAL, days_post_rainfall INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lecanorales_microclimate_studies_species_id ON ord_lecanorales_microclimate_studies (species_id); CREATE INDEX ix_ord_lecanorales_microclimate_studies_publication_id ON ord_lecanorales_microclimate_studies (publication_id); CREATE TABLE ord_lecanorales_dna_barcoding_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, its_sequenced INTEGER NOT NULL DEFAULT 0, lsu_sequenced INTEGER NOT NULL DEFAULT 0, rpb2_sequenced INTEGER NOT NULL DEFAULT 0, ef1a_sequenced INTEGER NOT NULL DEFAULT 0, genome_assembled INTEGER NOT NULL DEFAULT 0, priority_for_sequencing_score INTEGER CHECK (priority_for_sequencing_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lecanorales_dna_barcoding_status_species_id ON ord_lecanorales_dna_barcoding_status (species_id); CREATE TABLE ord_lecanorales_spore_print_data ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, specimen_id INTEGER, print_color_label TEXT, print_color_chip_id INTEGER, spore_density_per_mm2 REAL, collection_substrate TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (print_color_chip_id) REFERENCES mor_color_chips (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lecanorales_spore_print_data_species_id ON ord_lecanorales_spore_print_data (species_id); CREATE INDEX ix_ord_lecanorales_spore_print_data_specimen_id ON ord_lecanorales_spore_print_data (specimen_id); CREATE TABLE ord_lecanorales_mating_systems ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, system_type TEXT, mating_loci_count INTEGER, publication_id INTEGER, notes_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lecanorales_mating_systems_species_id ON ord_lecanorales_mating_systems (species_id); CREATE INDEX ix_ord_lecanorales_mating_systems_publication_id ON ord_lecanorales_mating_systems (publication_id); CREATE TABLE ord_lecanorales_nutrient_uptake_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, nitrogen_source TEXT, carbon_source TEXT, growth_response TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lecanorales_nutrient_uptake_studies_species_id ON ord_lecanorales_nutrient_uptake_studies (species_id); CREATE INDEX ix_ord_lecanorales_nutrient_uptake_studies_strain_id ON ord_lecanorales_nutrient_uptake_studies (strain_id); CREATE TABLE ord_lecanorales_range_maps ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, polygon_file_uri TEXT NOT NULL, source_methodology TEXT, area_km2 REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lecanorales_range_maps_species_id ON ord_lecanorales_range_maps (species_id); CREATE INDEX ix_ord_lecanorales_range_maps_publication_id ON ord_lecanorales_range_maps (publication_id); CREATE TABLE ord_lecanorales_abundance_estimates ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, estimate_kind TEXT, value_min REAL, value_max REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lecanorales_abundance_estimates_species_id ON ord_lecanorales_abundance_estimates (species_id); CREATE INDEX ix_ord_lecanorales_abundance_estimates_country_id ON ord_lecanorales_abundance_estimates (country_id); CREATE TABLE ord_lecanorales_toxin_profiles ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, presence TEXT, typical_concentration_mg_per_kg REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lecanorales_toxin_profiles_species_id ON ord_lecanorales_toxin_profiles (species_id); CREATE INDEX ix_ord_lecanorales_toxin_profiles_compound_id ON ord_lecanorales_toxin_profiles (compound_id); CREATE TABLE ord_lecanorales_enzyme_activity_assays ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, enzyme_id INTEGER NOT NULL, strain_id INTEGER, activity_u_per_mg REAL, temperature_c REAL, ph REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (enzyme_id) REFERENCES bio_enzymes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lecanorales_enzyme_activity_assays_species_id ON ord_lecanorales_enzyme_activity_assays (species_id); CREATE INDEX ix_ord_lecanorales_enzyme_activity_assays_enzyme_id ON ord_lecanorales_enzyme_activity_assays (enzyme_id); CREATE TABLE ord_lecanorales_biocontrol_evaluations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, target_pest_text TEXT NOT NULL, efficacy_pct REAL, trial_setting TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lecanorales_biocontrol_evaluations_species_id ON ord_lecanorales_biocontrol_evaluations (species_id); CREATE INDEX ix_ord_lecanorales_biocontrol_evaluations_publication_id ON ord_lecanorales_biocontrol_evaluations (publication_id); CREATE TABLE ord_lecanorales_regional_checklists ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, checklist_publication_id INTEGER, status TEXT, checklist_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (checklist_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lecanorales_regional_checklists_species_id ON ord_lecanorales_regional_checklists (species_id); CREATE INDEX ix_ord_lecanorales_regional_checklists_country_id ON ord_lecanorales_regional_checklists (country_id); CREATE TABLE ord_teloschistales_morphology ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, hymenium_color_at_maturity TEXT, context_color_at_maturity TEXT, characteristic_microstructure TEXT, diagnostic_features_text TEXT, notes_kohler_reaction TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_teloschistales_morphology_specimen_id ON ord_teloschistales_morphology (specimen_id); CREATE INDEX ix_ord_teloschistales_morphology_species_id ON ord_teloschistales_morphology (species_id); CREATE TABLE ord_teloschistales_ecology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, dominant_habitat_id INTEGER, dominant_substrate_id INTEGER, dominant_biome_id INTEGER, trophic_strategy TEXT, typical_fruiting_period TEXT, known_distribution_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_habitat_id) REFERENCES eco_habitat_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_substrate_id) REFERENCES eco_substrate_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_biome_id) REFERENCES geo_biomes (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_teloschistales_ecology_species_id ON ord_teloschistales_ecology (species_id); CREATE INDEX ix_ord_teloschistales_ecology_dominant_habitat_id ON ord_teloschistales_ecology (dominant_habitat_id); CREATE TABLE ord_teloschistales_phenology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, season_name TEXT, region_country_id INTEGER, first_doy INTEGER, peak_doy INTEGER, last_doy INTEGER, years_observed INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_teloschistales_phenology_species_id ON ord_teloschistales_phenology (species_id); CREATE INDEX ix_ord_teloschistales_phenology_region_country_id ON ord_teloschistales_phenology (region_country_id); CREATE TABLE ord_teloschistales_host_associations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, association_type TEXT, specificity TEXT, evidence_publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (evidence_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_teloschistales_host_associations_species_id ON ord_teloschistales_host_associations (species_id); CREATE INDEX ix_ord_teloschistales_host_associations_host_id ON ord_teloschistales_host_associations (host_id); CREATE TABLE ord_teloschistales_substrate_preferences ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, substrate_id INTEGER NOT NULL, preference_score REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (substrate_id) REFERENCES eco_substrate_types (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_teloschistales_substrate_preferences_species_id ON ord_teloschistales_substrate_preferences (species_id); CREATE INDEX ix_ord_teloschistales_substrate_preferences_substrate_id ON ord_teloschistales_substrate_preferences (substrate_id); CREATE TABLE ord_teloschistales_geographic_distribution ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, occurrence_status TEXT, first_record_year INTEGER, record_count INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_teloschistales_geographic_distribution_species_id ON ord_teloschistales_geographic_distribution (species_id); CREATE INDEX ix_ord_teloschistales_geographic_distribution_country_id ON ord_teloschistales_geographic_distribution (country_id); CREATE TABLE ord_teloschistales_phylogeny ( id INTEGER PRIMARY KEY AUTOINCREMENT, tree_id INTEGER NOT NULL, focal_genus_id INTEGER, publication_id INTEGER, notes_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (tree_id) REFERENCES phy_trees (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_teloschistales_phylogeny_tree_id ON ord_teloschistales_phylogeny (tree_id); CREATE INDEX ix_ord_teloschistales_phylogeny_focal_genus_id ON ord_teloschistales_phylogeny (focal_genus_id); CREATE TABLE ord_teloschistales_genomics ( id INTEGER PRIMARY KEY AUTOINCREMENT, assembly_id INTEGER NOT NULL, species_id INTEGER, avg_genome_size_mb REAL, avg_gene_count INTEGER, avg_busco_complete_pct REAL, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (assembly_id) REFERENCES gen_assemblies (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_teloschistales_genomics_assembly_id ON ord_teloschistales_genomics (assembly_id); CREATE INDEX ix_ord_teloschistales_genomics_species_id ON ord_teloschistales_genomics (species_id); CREATE TABLE ord_teloschistales_biochemistry ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, typicality TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_teloschistales_biochemistry_species_id ON ord_teloschistales_biochemistry (species_id); CREATE INDEX ix_ord_teloschistales_biochemistry_compound_id ON ord_teloschistales_biochemistry (compound_id); CREATE TABLE ord_teloschistales_cultivation_notes ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, typical_growth_rate_mm_per_day REAL, preferred_media_type_id INTEGER, optimal_temperature_c REAL, difficulty_score INTEGER CHECK (difficulty_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (preferred_media_type_id) REFERENCES cul_media_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_teloschistales_cultivation_notes_species_id ON ord_teloschistales_cultivation_notes (species_id); CREATE INDEX ix_ord_teloschistales_cultivation_notes_strain_id ON ord_teloschistales_cultivation_notes (strain_id); CREATE TABLE ord_teloschistales_pathogenicity ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, disease_id INTEGER, severity_score INTEGER CHECK (severity_score BETWEEN 1 AND 5), publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (disease_id) REFERENCES pat_diseases (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_teloschistales_pathogenicity_species_id ON ord_teloschistales_pathogenicity (species_id); CREATE INDEX ix_ord_teloschistales_pathogenicity_host_id ON ord_teloschistales_pathogenicity (host_id); CREATE TABLE ord_teloschistales_edibility ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, edibility_class TEXT, preparation_notes TEXT, regional_tradition_country_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (regional_tradition_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_teloschistales_edibility_species_id ON ord_teloschistales_edibility (species_id); CREATE INDEX ix_ord_teloschistales_edibility_1 ON ord_teloschistales_edibility (regional_tradition_country_id); CREATE TABLE ord_teloschistales_medicinal_uses ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, traditional_use_text TEXT, modern_evidence_level TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_teloschistales_medicinal_uses_species_id ON ord_teloschistales_medicinal_uses (species_id); CREATE INDEX ix_ord_teloschistales_medicinal_uses_publication_id ON ord_teloschistales_medicinal_uses (publication_id); CREATE TABLE ord_teloschistales_taxonomic_revisions ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER NOT NULL, affected_family_id INTEGER, affected_genus_id INTEGER, revision_summary TEXT, revision_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_family_id) REFERENCES tax_families (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_teloschistales_taxonomic_revisions_publication_id ON ord_teloschistales_taxonomic_revisions (publication_id); CREATE INDEX ix_ord_teloschistales_taxonomic_revisions_affected_family_id ON ord_teloschistales_taxonomic_revisions (affected_family_id); CREATE TABLE ord_teloschistales_conservation_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, national_redlist_category TEXT, habitat_pressure_text TEXT, last_assessment_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_teloschistales_conservation_status_species_id ON ord_teloschistales_conservation_status (species_id); CREATE INDEX ix_ord_teloschistales_conservation_status_country_id ON ord_teloschistales_conservation_status (country_id); CREATE TABLE ord_teloschistales_diagnostic_keys ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER, key_title TEXT NOT NULL, region_country_id INTEGER, n_taxa_covered INTEGER, key_format TEXT, includes_microscopy INTEGER NOT NULL DEFAULT 0, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_teloschistales_diagnostic_keys_publication_id ON ord_teloschistales_diagnostic_keys (publication_id); CREATE INDEX ix_ord_teloschistales_diagnostic_keys_region_country_id ON ord_teloschistales_diagnostic_keys (region_country_id); CREATE TABLE ord_teloschistales_type_species_register ( id INTEGER PRIMARY KEY AUTOINCREMENT, focal_genus_id INTEGER NOT NULL, type_species_id INTEGER, designation_publication_id INTEGER, designation_year INTEGER, designated_by_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (designation_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_teloschistales_type_species_register_focal_genus_id ON ord_teloschistales_type_species_register (focal_genus_id); CREATE INDEX ix_ord_teloschistales_type_species_register_type_species_id ON ord_teloschistales_type_species_register (type_species_id); CREATE TABLE ord_teloschistales_distribution_grids ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, grid_cell_code TEXT NOT NULL, centroid_lat REAL, centroid_lon REAL, record_count INTEGER, first_record_year INTEGER, most_recent_record_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_teloschistales_distribution_grids_species_id ON ord_teloschistales_distribution_grids (species_id); CREATE INDEX ix_ord_teloschistales_distribution_grids_country_id ON ord_teloschistales_distribution_grids (country_id); CREATE TABLE ord_teloschistales_microclimate_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER, publication_id INTEGER, substrate_temperature_c REAL, substrate_moisture_pct REAL, canopy_closure_pct REAL, photosynthetic_par_umol_m2_s REAL, days_post_rainfall INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_teloschistales_microclimate_studies_species_id ON ord_teloschistales_microclimate_studies (species_id); CREATE INDEX ix_ord_teloschistales_microclimate_studies_publication_id ON ord_teloschistales_microclimate_studies (publication_id); CREATE TABLE ord_teloschistales_dna_barcoding_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, its_sequenced INTEGER NOT NULL DEFAULT 0, lsu_sequenced INTEGER NOT NULL DEFAULT 0, rpb2_sequenced INTEGER NOT NULL DEFAULT 0, ef1a_sequenced INTEGER NOT NULL DEFAULT 0, genome_assembled INTEGER NOT NULL DEFAULT 0, priority_for_sequencing_score INTEGER CHECK (priority_for_sequencing_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_teloschistales_dna_barcoding_status_species_id ON ord_teloschistales_dna_barcoding_status (species_id); CREATE TABLE ord_teloschistales_spore_print_data ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, specimen_id INTEGER, print_color_label TEXT, print_color_chip_id INTEGER, spore_density_per_mm2 REAL, collection_substrate TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (print_color_chip_id) REFERENCES mor_color_chips (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_teloschistales_spore_print_data_species_id ON ord_teloschistales_spore_print_data (species_id); CREATE INDEX ix_ord_teloschistales_spore_print_data_specimen_id ON ord_teloschistales_spore_print_data (specimen_id); CREATE TABLE ord_teloschistales_mating_systems ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, system_type TEXT, mating_loci_count INTEGER, publication_id INTEGER, notes_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_teloschistales_mating_systems_species_id ON ord_teloschistales_mating_systems (species_id); CREATE INDEX ix_ord_teloschistales_mating_systems_publication_id ON ord_teloschistales_mating_systems (publication_id); CREATE TABLE ord_teloschistales_nutrient_uptake_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, nitrogen_source TEXT, carbon_source TEXT, growth_response TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_teloschistales_nutrient_uptake_studies_species_id ON ord_teloschistales_nutrient_uptake_studies (species_id); CREATE INDEX ix_ord_teloschistales_nutrient_uptake_studies_strain_id ON ord_teloschistales_nutrient_uptake_studies (strain_id); CREATE TABLE ord_teloschistales_range_maps ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, polygon_file_uri TEXT NOT NULL, source_methodology TEXT, area_km2 REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_teloschistales_range_maps_species_id ON ord_teloschistales_range_maps (species_id); CREATE INDEX ix_ord_teloschistales_range_maps_publication_id ON ord_teloschistales_range_maps (publication_id); CREATE TABLE ord_teloschistales_abundance_estimates ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, estimate_kind TEXT, value_min REAL, value_max REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_teloschistales_abundance_estimates_species_id ON ord_teloschistales_abundance_estimates (species_id); CREATE INDEX ix_ord_teloschistales_abundance_estimates_country_id ON ord_teloschistales_abundance_estimates (country_id); CREATE TABLE ord_teloschistales_toxin_profiles ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, presence TEXT, typical_concentration_mg_per_kg REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_teloschistales_toxin_profiles_species_id ON ord_teloschistales_toxin_profiles (species_id); CREATE INDEX ix_ord_teloschistales_toxin_profiles_compound_id ON ord_teloschistales_toxin_profiles (compound_id); CREATE TABLE ord_teloschistales_enzyme_activity_assays ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, enzyme_id INTEGER NOT NULL, strain_id INTEGER, activity_u_per_mg REAL, temperature_c REAL, ph REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (enzyme_id) REFERENCES bio_enzymes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_teloschistales_enzyme_activity_assays_species_id ON ord_teloschistales_enzyme_activity_assays (species_id); CREATE INDEX ix_ord_teloschistales_enzyme_activity_assays_enzyme_id ON ord_teloschistales_enzyme_activity_assays (enzyme_id); CREATE TABLE ord_teloschistales_biocontrol_evaluations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, target_pest_text TEXT NOT NULL, efficacy_pct REAL, trial_setting TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_teloschistales_biocontrol_evaluations_species_id ON ord_teloschistales_biocontrol_evaluations (species_id); CREATE INDEX ix_ord_teloschistales_biocontrol_evaluations_publication_id ON ord_teloschistales_biocontrol_evaluations (publication_id); CREATE TABLE ord_teloschistales_regional_checklists ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, checklist_publication_id INTEGER, status TEXT, checklist_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (checklist_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_teloschistales_regional_checklists_species_id ON ord_teloschistales_regional_checklists (species_id); CREATE INDEX ix_ord_teloschistales_regional_checklists_country_id ON ord_teloschistales_regional_checklists (country_id); CREATE TABLE ord_ostropales_morphology ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, hymenium_color_at_maturity TEXT, context_color_at_maturity TEXT, characteristic_microstructure TEXT, diagnostic_features_text TEXT, notes_kohler_reaction TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ostropales_morphology_specimen_id ON ord_ostropales_morphology (specimen_id); CREATE INDEX ix_ord_ostropales_morphology_species_id ON ord_ostropales_morphology (species_id); CREATE TABLE ord_ostropales_ecology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, dominant_habitat_id INTEGER, dominant_substrate_id INTEGER, dominant_biome_id INTEGER, trophic_strategy TEXT, typical_fruiting_period TEXT, known_distribution_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_habitat_id) REFERENCES eco_habitat_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_substrate_id) REFERENCES eco_substrate_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_biome_id) REFERENCES geo_biomes (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ostropales_ecology_species_id ON ord_ostropales_ecology (species_id); CREATE INDEX ix_ord_ostropales_ecology_dominant_habitat_id ON ord_ostropales_ecology (dominant_habitat_id); CREATE TABLE ord_ostropales_phenology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, season_name TEXT, region_country_id INTEGER, first_doy INTEGER, peak_doy INTEGER, last_doy INTEGER, years_observed INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ostropales_phenology_species_id ON ord_ostropales_phenology (species_id); CREATE INDEX ix_ord_ostropales_phenology_region_country_id ON ord_ostropales_phenology (region_country_id); CREATE TABLE ord_ostropales_host_associations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, association_type TEXT, specificity TEXT, evidence_publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (evidence_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ostropales_host_associations_species_id ON ord_ostropales_host_associations (species_id); CREATE INDEX ix_ord_ostropales_host_associations_host_id ON ord_ostropales_host_associations (host_id); CREATE TABLE ord_ostropales_substrate_preferences ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, substrate_id INTEGER NOT NULL, preference_score REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (substrate_id) REFERENCES eco_substrate_types (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ostropales_substrate_preferences_species_id ON ord_ostropales_substrate_preferences (species_id); CREATE INDEX ix_ord_ostropales_substrate_preferences_substrate_id ON ord_ostropales_substrate_preferences (substrate_id); CREATE TABLE ord_ostropales_geographic_distribution ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, occurrence_status TEXT, first_record_year INTEGER, record_count INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ostropales_geographic_distribution_species_id ON ord_ostropales_geographic_distribution (species_id); CREATE INDEX ix_ord_ostropales_geographic_distribution_country_id ON ord_ostropales_geographic_distribution (country_id); CREATE TABLE ord_ostropales_phylogeny ( id INTEGER PRIMARY KEY AUTOINCREMENT, tree_id INTEGER NOT NULL, focal_genus_id INTEGER, publication_id INTEGER, notes_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (tree_id) REFERENCES phy_trees (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ostropales_phylogeny_tree_id ON ord_ostropales_phylogeny (tree_id); CREATE INDEX ix_ord_ostropales_phylogeny_focal_genus_id ON ord_ostropales_phylogeny (focal_genus_id); CREATE TABLE ord_ostropales_genomics ( id INTEGER PRIMARY KEY AUTOINCREMENT, assembly_id INTEGER NOT NULL, species_id INTEGER, avg_genome_size_mb REAL, avg_gene_count INTEGER, avg_busco_complete_pct REAL, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (assembly_id) REFERENCES gen_assemblies (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ostropales_genomics_assembly_id ON ord_ostropales_genomics (assembly_id); CREATE INDEX ix_ord_ostropales_genomics_species_id ON ord_ostropales_genomics (species_id); CREATE TABLE ord_ostropales_biochemistry ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, typicality TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ostropales_biochemistry_species_id ON ord_ostropales_biochemistry (species_id); CREATE INDEX ix_ord_ostropales_biochemistry_compound_id ON ord_ostropales_biochemistry (compound_id); CREATE TABLE ord_ostropales_cultivation_notes ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, typical_growth_rate_mm_per_day REAL, preferred_media_type_id INTEGER, optimal_temperature_c REAL, difficulty_score INTEGER CHECK (difficulty_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (preferred_media_type_id) REFERENCES cul_media_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ostropales_cultivation_notes_species_id ON ord_ostropales_cultivation_notes (species_id); CREATE INDEX ix_ord_ostropales_cultivation_notes_strain_id ON ord_ostropales_cultivation_notes (strain_id); CREATE TABLE ord_ostropales_pathogenicity ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, disease_id INTEGER, severity_score INTEGER CHECK (severity_score BETWEEN 1 AND 5), publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (disease_id) REFERENCES pat_diseases (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ostropales_pathogenicity_species_id ON ord_ostropales_pathogenicity (species_id); CREATE INDEX ix_ord_ostropales_pathogenicity_host_id ON ord_ostropales_pathogenicity (host_id); CREATE TABLE ord_ostropales_edibility ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, edibility_class TEXT, preparation_notes TEXT, regional_tradition_country_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (regional_tradition_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ostropales_edibility_species_id ON ord_ostropales_edibility (species_id); CREATE INDEX ix_ord_ostropales_edibility_regional_tradition_country_id ON ord_ostropales_edibility (regional_tradition_country_id); CREATE TABLE ord_ostropales_medicinal_uses ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, traditional_use_text TEXT, modern_evidence_level TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ostropales_medicinal_uses_species_id ON ord_ostropales_medicinal_uses (species_id); CREATE INDEX ix_ord_ostropales_medicinal_uses_publication_id ON ord_ostropales_medicinal_uses (publication_id); CREATE TABLE ord_ostropales_taxonomic_revisions ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER NOT NULL, affected_family_id INTEGER, affected_genus_id INTEGER, revision_summary TEXT, revision_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_family_id) REFERENCES tax_families (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ostropales_taxonomic_revisions_publication_id ON ord_ostropales_taxonomic_revisions (publication_id); CREATE INDEX ix_ord_ostropales_taxonomic_revisions_affected_family_id ON ord_ostropales_taxonomic_revisions (affected_family_id); CREATE TABLE ord_ostropales_conservation_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, national_redlist_category TEXT, habitat_pressure_text TEXT, last_assessment_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ostropales_conservation_status_species_id ON ord_ostropales_conservation_status (species_id); CREATE INDEX ix_ord_ostropales_conservation_status_country_id ON ord_ostropales_conservation_status (country_id); CREATE TABLE ord_ostropales_diagnostic_keys ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER, key_title TEXT NOT NULL, region_country_id INTEGER, n_taxa_covered INTEGER, key_format TEXT, includes_microscopy INTEGER NOT NULL DEFAULT 0, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ostropales_diagnostic_keys_publication_id ON ord_ostropales_diagnostic_keys (publication_id); CREATE INDEX ix_ord_ostropales_diagnostic_keys_region_country_id ON ord_ostropales_diagnostic_keys (region_country_id); CREATE TABLE ord_ostropales_type_species_register ( id INTEGER PRIMARY KEY AUTOINCREMENT, focal_genus_id INTEGER NOT NULL, type_species_id INTEGER, designation_publication_id INTEGER, designation_year INTEGER, designated_by_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (designation_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ostropales_type_species_register_focal_genus_id ON ord_ostropales_type_species_register (focal_genus_id); CREATE INDEX ix_ord_ostropales_type_species_register_type_species_id ON ord_ostropales_type_species_register (type_species_id); CREATE TABLE ord_ostropales_distribution_grids ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, grid_cell_code TEXT NOT NULL, centroid_lat REAL, centroid_lon REAL, record_count INTEGER, first_record_year INTEGER, most_recent_record_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ostropales_distribution_grids_species_id ON ord_ostropales_distribution_grids (species_id); CREATE INDEX ix_ord_ostropales_distribution_grids_country_id ON ord_ostropales_distribution_grids (country_id); CREATE TABLE ord_ostropales_microclimate_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER, publication_id INTEGER, substrate_temperature_c REAL, substrate_moisture_pct REAL, canopy_closure_pct REAL, photosynthetic_par_umol_m2_s REAL, days_post_rainfall INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ostropales_microclimate_studies_species_id ON ord_ostropales_microclimate_studies (species_id); CREATE INDEX ix_ord_ostropales_microclimate_studies_publication_id ON ord_ostropales_microclimate_studies (publication_id); CREATE TABLE ord_ostropales_dna_barcoding_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, its_sequenced INTEGER NOT NULL DEFAULT 0, lsu_sequenced INTEGER NOT NULL DEFAULT 0, rpb2_sequenced INTEGER NOT NULL DEFAULT 0, ef1a_sequenced INTEGER NOT NULL DEFAULT 0, genome_assembled INTEGER NOT NULL DEFAULT 0, priority_for_sequencing_score INTEGER CHECK (priority_for_sequencing_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ostropales_dna_barcoding_status_species_id ON ord_ostropales_dna_barcoding_status (species_id); CREATE TABLE ord_ostropales_spore_print_data ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, specimen_id INTEGER, print_color_label TEXT, print_color_chip_id INTEGER, spore_density_per_mm2 REAL, collection_substrate TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (print_color_chip_id) REFERENCES mor_color_chips (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ostropales_spore_print_data_species_id ON ord_ostropales_spore_print_data (species_id); CREATE INDEX ix_ord_ostropales_spore_print_data_specimen_id ON ord_ostropales_spore_print_data (specimen_id); CREATE TABLE ord_ostropales_mating_systems ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, system_type TEXT, mating_loci_count INTEGER, publication_id INTEGER, notes_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ostropales_mating_systems_species_id ON ord_ostropales_mating_systems (species_id); CREATE INDEX ix_ord_ostropales_mating_systems_publication_id ON ord_ostropales_mating_systems (publication_id); CREATE TABLE ord_ostropales_nutrient_uptake_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, nitrogen_source TEXT, carbon_source TEXT, growth_response TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ostropales_nutrient_uptake_studies_species_id ON ord_ostropales_nutrient_uptake_studies (species_id); CREATE INDEX ix_ord_ostropales_nutrient_uptake_studies_strain_id ON ord_ostropales_nutrient_uptake_studies (strain_id); CREATE TABLE ord_ostropales_range_maps ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, polygon_file_uri TEXT NOT NULL, source_methodology TEXT, area_km2 REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ostropales_range_maps_species_id ON ord_ostropales_range_maps (species_id); CREATE INDEX ix_ord_ostropales_range_maps_publication_id ON ord_ostropales_range_maps (publication_id); CREATE TABLE ord_ostropales_abundance_estimates ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, estimate_kind TEXT, value_min REAL, value_max REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ostropales_abundance_estimates_species_id ON ord_ostropales_abundance_estimates (species_id); CREATE INDEX ix_ord_ostropales_abundance_estimates_country_id ON ord_ostropales_abundance_estimates (country_id); CREATE TABLE ord_ostropales_toxin_profiles ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, presence TEXT, typical_concentration_mg_per_kg REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ostropales_toxin_profiles_species_id ON ord_ostropales_toxin_profiles (species_id); CREATE INDEX ix_ord_ostropales_toxin_profiles_compound_id ON ord_ostropales_toxin_profiles (compound_id); CREATE TABLE ord_ostropales_enzyme_activity_assays ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, enzyme_id INTEGER NOT NULL, strain_id INTEGER, activity_u_per_mg REAL, temperature_c REAL, ph REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (enzyme_id) REFERENCES bio_enzymes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ostropales_enzyme_activity_assays_species_id ON ord_ostropales_enzyme_activity_assays (species_id); CREATE INDEX ix_ord_ostropales_enzyme_activity_assays_enzyme_id ON ord_ostropales_enzyme_activity_assays (enzyme_id); CREATE TABLE ord_ostropales_biocontrol_evaluations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, target_pest_text TEXT NOT NULL, efficacy_pct REAL, trial_setting TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ostropales_biocontrol_evaluations_species_id ON ord_ostropales_biocontrol_evaluations (species_id); CREATE INDEX ix_ord_ostropales_biocontrol_evaluations_publication_id ON ord_ostropales_biocontrol_evaluations (publication_id); CREATE TABLE ord_ostropales_regional_checklists ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, checklist_publication_id INTEGER, status TEXT, checklist_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (checklist_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_ostropales_regional_checklists_species_id ON ord_ostropales_regional_checklists (species_id); CREATE INDEX ix_ord_ostropales_regional_checklists_country_id ON ord_ostropales_regional_checklists (country_id); CREATE TABLE ord_verrucariales_morphology ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, hymenium_color_at_maturity TEXT, context_color_at_maturity TEXT, characteristic_microstructure TEXT, diagnostic_features_text TEXT, notes_kohler_reaction TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_verrucariales_morphology_specimen_id ON ord_verrucariales_morphology (specimen_id); CREATE INDEX ix_ord_verrucariales_morphology_species_id ON ord_verrucariales_morphology (species_id); CREATE TABLE ord_verrucariales_ecology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, dominant_habitat_id INTEGER, dominant_substrate_id INTEGER, dominant_biome_id INTEGER, trophic_strategy TEXT, typical_fruiting_period TEXT, known_distribution_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_habitat_id) REFERENCES eco_habitat_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_substrate_id) REFERENCES eco_substrate_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_biome_id) REFERENCES geo_biomes (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_verrucariales_ecology_species_id ON ord_verrucariales_ecology (species_id); CREATE INDEX ix_ord_verrucariales_ecology_dominant_habitat_id ON ord_verrucariales_ecology (dominant_habitat_id); CREATE TABLE ord_verrucariales_phenology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, season_name TEXT, region_country_id INTEGER, first_doy INTEGER, peak_doy INTEGER, last_doy INTEGER, years_observed INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_verrucariales_phenology_species_id ON ord_verrucariales_phenology (species_id); CREATE INDEX ix_ord_verrucariales_phenology_region_country_id ON ord_verrucariales_phenology (region_country_id); CREATE TABLE ord_verrucariales_host_associations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, association_type TEXT, specificity TEXT, evidence_publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (evidence_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_verrucariales_host_associations_species_id ON ord_verrucariales_host_associations (species_id); CREATE INDEX ix_ord_verrucariales_host_associations_host_id ON ord_verrucariales_host_associations (host_id); CREATE TABLE ord_verrucariales_substrate_preferences ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, substrate_id INTEGER NOT NULL, preference_score REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (substrate_id) REFERENCES eco_substrate_types (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_verrucariales_substrate_preferences_species_id ON ord_verrucariales_substrate_preferences (species_id); CREATE INDEX ix_ord_verrucariales_substrate_preferences_substrate_id ON ord_verrucariales_substrate_preferences (substrate_id); CREATE TABLE ord_verrucariales_geographic_distribution ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, occurrence_status TEXT, first_record_year INTEGER, record_count INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_verrucariales_geographic_distribution_species_id ON ord_verrucariales_geographic_distribution (species_id); CREATE INDEX ix_ord_verrucariales_geographic_distribution_country_id ON ord_verrucariales_geographic_distribution (country_id); CREATE TABLE ord_verrucariales_phylogeny ( id INTEGER PRIMARY KEY AUTOINCREMENT, tree_id INTEGER NOT NULL, focal_genus_id INTEGER, publication_id INTEGER, notes_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (tree_id) REFERENCES phy_trees (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_verrucariales_phylogeny_tree_id ON ord_verrucariales_phylogeny (tree_id); CREATE INDEX ix_ord_verrucariales_phylogeny_focal_genus_id ON ord_verrucariales_phylogeny (focal_genus_id); CREATE TABLE ord_verrucariales_genomics ( id INTEGER PRIMARY KEY AUTOINCREMENT, assembly_id INTEGER NOT NULL, species_id INTEGER, avg_genome_size_mb REAL, avg_gene_count INTEGER, avg_busco_complete_pct REAL, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (assembly_id) REFERENCES gen_assemblies (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_verrucariales_genomics_assembly_id ON ord_verrucariales_genomics (assembly_id); CREATE INDEX ix_ord_verrucariales_genomics_species_id ON ord_verrucariales_genomics (species_id); CREATE TABLE ord_verrucariales_biochemistry ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, typicality TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_verrucariales_biochemistry_species_id ON ord_verrucariales_biochemistry (species_id); CREATE INDEX ix_ord_verrucariales_biochemistry_compound_id ON ord_verrucariales_biochemistry (compound_id); CREATE TABLE ord_verrucariales_cultivation_notes ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, typical_growth_rate_mm_per_day REAL, preferred_media_type_id INTEGER, optimal_temperature_c REAL, difficulty_score INTEGER CHECK (difficulty_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (preferred_media_type_id) REFERENCES cul_media_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_verrucariales_cultivation_notes_species_id ON ord_verrucariales_cultivation_notes (species_id); CREATE INDEX ix_ord_verrucariales_cultivation_notes_strain_id ON ord_verrucariales_cultivation_notes (strain_id); CREATE TABLE ord_verrucariales_pathogenicity ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, disease_id INTEGER, severity_score INTEGER CHECK (severity_score BETWEEN 1 AND 5), publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (disease_id) REFERENCES pat_diseases (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_verrucariales_pathogenicity_species_id ON ord_verrucariales_pathogenicity (species_id); CREATE INDEX ix_ord_verrucariales_pathogenicity_host_id ON ord_verrucariales_pathogenicity (host_id); CREATE TABLE ord_verrucariales_edibility ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, edibility_class TEXT, preparation_notes TEXT, regional_tradition_country_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (regional_tradition_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_verrucariales_edibility_species_id ON ord_verrucariales_edibility (species_id); CREATE INDEX ix_ord_verrucariales_edibility_regional_tradition_country_id ON ord_verrucariales_edibility (regional_tradition_country_id); CREATE TABLE ord_verrucariales_medicinal_uses ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, traditional_use_text TEXT, modern_evidence_level TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_verrucariales_medicinal_uses_species_id ON ord_verrucariales_medicinal_uses (species_id); CREATE INDEX ix_ord_verrucariales_medicinal_uses_publication_id ON ord_verrucariales_medicinal_uses (publication_id); CREATE TABLE ord_verrucariales_taxonomic_revisions ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER NOT NULL, affected_family_id INTEGER, affected_genus_id INTEGER, revision_summary TEXT, revision_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_family_id) REFERENCES tax_families (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_verrucariales_taxonomic_revisions_publication_id ON ord_verrucariales_taxonomic_revisions (publication_id); CREATE INDEX ix_ord_verrucariales_taxonomic_revisions_affected_family_id ON ord_verrucariales_taxonomic_revisions (affected_family_id); CREATE TABLE ord_verrucariales_conservation_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, national_redlist_category TEXT, habitat_pressure_text TEXT, last_assessment_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_verrucariales_conservation_status_species_id ON ord_verrucariales_conservation_status (species_id); CREATE INDEX ix_ord_verrucariales_conservation_status_country_id ON ord_verrucariales_conservation_status (country_id); CREATE TABLE ord_verrucariales_diagnostic_keys ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER, key_title TEXT NOT NULL, region_country_id INTEGER, n_taxa_covered INTEGER, key_format TEXT, includes_microscopy INTEGER NOT NULL DEFAULT 0, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_verrucariales_diagnostic_keys_publication_id ON ord_verrucariales_diagnostic_keys (publication_id); CREATE INDEX ix_ord_verrucariales_diagnostic_keys_region_country_id ON ord_verrucariales_diagnostic_keys (region_country_id); CREATE TABLE ord_verrucariales_type_species_register ( id INTEGER PRIMARY KEY AUTOINCREMENT, focal_genus_id INTEGER NOT NULL, type_species_id INTEGER, designation_publication_id INTEGER, designation_year INTEGER, designated_by_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (designation_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_verrucariales_type_species_register_focal_genus_id ON ord_verrucariales_type_species_register (focal_genus_id); CREATE INDEX ix_ord_verrucariales_type_species_register_type_species_id ON ord_verrucariales_type_species_register (type_species_id); CREATE TABLE ord_verrucariales_distribution_grids ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, grid_cell_code TEXT NOT NULL, centroid_lat REAL, centroid_lon REAL, record_count INTEGER, first_record_year INTEGER, most_recent_record_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_verrucariales_distribution_grids_species_id ON ord_verrucariales_distribution_grids (species_id); CREATE INDEX ix_ord_verrucariales_distribution_grids_country_id ON ord_verrucariales_distribution_grids (country_id); CREATE TABLE ord_verrucariales_microclimate_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER, publication_id INTEGER, substrate_temperature_c REAL, substrate_moisture_pct REAL, canopy_closure_pct REAL, photosynthetic_par_umol_m2_s REAL, days_post_rainfall INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_verrucariales_microclimate_studies_species_id ON ord_verrucariales_microclimate_studies (species_id); CREATE INDEX ix_ord_verrucariales_microclimate_studies_publication_id ON ord_verrucariales_microclimate_studies (publication_id); CREATE TABLE ord_verrucariales_dna_barcoding_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, its_sequenced INTEGER NOT NULL DEFAULT 0, lsu_sequenced INTEGER NOT NULL DEFAULT 0, rpb2_sequenced INTEGER NOT NULL DEFAULT 0, ef1a_sequenced INTEGER NOT NULL DEFAULT 0, genome_assembled INTEGER NOT NULL DEFAULT 0, priority_for_sequencing_score INTEGER CHECK (priority_for_sequencing_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_verrucariales_dna_barcoding_status_species_id ON ord_verrucariales_dna_barcoding_status (species_id); CREATE TABLE ord_verrucariales_spore_print_data ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, specimen_id INTEGER, print_color_label TEXT, print_color_chip_id INTEGER, spore_density_per_mm2 REAL, collection_substrate TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (print_color_chip_id) REFERENCES mor_color_chips (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_verrucariales_spore_print_data_species_id ON ord_verrucariales_spore_print_data (species_id); CREATE INDEX ix_ord_verrucariales_spore_print_data_specimen_id ON ord_verrucariales_spore_print_data (specimen_id); CREATE TABLE ord_verrucariales_mating_systems ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, system_type TEXT, mating_loci_count INTEGER, publication_id INTEGER, notes_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_verrucariales_mating_systems_species_id ON ord_verrucariales_mating_systems (species_id); CREATE INDEX ix_ord_verrucariales_mating_systems_publication_id ON ord_verrucariales_mating_systems (publication_id); CREATE TABLE ord_verrucariales_nutrient_uptake_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, nitrogen_source TEXT, carbon_source TEXT, growth_response TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_verrucariales_nutrient_uptake_studies_species_id ON ord_verrucariales_nutrient_uptake_studies (species_id); CREATE INDEX ix_ord_verrucariales_nutrient_uptake_studies_strain_id ON ord_verrucariales_nutrient_uptake_studies (strain_id); CREATE TABLE ord_verrucariales_range_maps ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, polygon_file_uri TEXT NOT NULL, source_methodology TEXT, area_km2 REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_verrucariales_range_maps_species_id ON ord_verrucariales_range_maps (species_id); CREATE INDEX ix_ord_verrucariales_range_maps_publication_id ON ord_verrucariales_range_maps (publication_id); CREATE TABLE ord_verrucariales_abundance_estimates ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, estimate_kind TEXT, value_min REAL, value_max REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_verrucariales_abundance_estimates_species_id ON ord_verrucariales_abundance_estimates (species_id); CREATE INDEX ix_ord_verrucariales_abundance_estimates_country_id ON ord_verrucariales_abundance_estimates (country_id); CREATE TABLE ord_verrucariales_toxin_profiles ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, presence TEXT, typical_concentration_mg_per_kg REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_verrucariales_toxin_profiles_species_id ON ord_verrucariales_toxin_profiles (species_id); CREATE INDEX ix_ord_verrucariales_toxin_profiles_compound_id ON ord_verrucariales_toxin_profiles (compound_id); CREATE TABLE ord_verrucariales_enzyme_activity_assays ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, enzyme_id INTEGER NOT NULL, strain_id INTEGER, activity_u_per_mg REAL, temperature_c REAL, ph REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (enzyme_id) REFERENCES bio_enzymes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_verrucariales_enzyme_activity_assays_species_id ON ord_verrucariales_enzyme_activity_assays (species_id); CREATE INDEX ix_ord_verrucariales_enzyme_activity_assays_enzyme_id ON ord_verrucariales_enzyme_activity_assays (enzyme_id); CREATE TABLE ord_verrucariales_biocontrol_evaluations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, target_pest_text TEXT NOT NULL, efficacy_pct REAL, trial_setting TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_verrucariales_biocontrol_evaluations_species_id ON ord_verrucariales_biocontrol_evaluations (species_id); CREATE INDEX ix_ord_verrucariales_biocontrol_evaluations_publication_id ON ord_verrucariales_biocontrol_evaluations (publication_id); CREATE TABLE ord_verrucariales_regional_checklists ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, checklist_publication_id INTEGER, status TEXT, checklist_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (checklist_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_verrucariales_regional_checklists_species_id ON ord_verrucariales_regional_checklists (species_id); CREATE INDEX ix_ord_verrucariales_regional_checklists_country_id ON ord_verrucariales_regional_checklists (country_id); CREATE TABLE ord_lichinales_morphology ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, hymenium_color_at_maturity TEXT, context_color_at_maturity TEXT, characteristic_microstructure TEXT, diagnostic_features_text TEXT, notes_kohler_reaction TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lichinales_morphology_specimen_id ON ord_lichinales_morphology (specimen_id); CREATE INDEX ix_ord_lichinales_morphology_species_id ON ord_lichinales_morphology (species_id); CREATE TABLE ord_lichinales_ecology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, dominant_habitat_id INTEGER, dominant_substrate_id INTEGER, dominant_biome_id INTEGER, trophic_strategy TEXT, typical_fruiting_period TEXT, known_distribution_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_habitat_id) REFERENCES eco_habitat_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_substrate_id) REFERENCES eco_substrate_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_biome_id) REFERENCES geo_biomes (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lichinales_ecology_species_id ON ord_lichinales_ecology (species_id); CREATE INDEX ix_ord_lichinales_ecology_dominant_habitat_id ON ord_lichinales_ecology (dominant_habitat_id); CREATE TABLE ord_lichinales_phenology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, season_name TEXT, region_country_id INTEGER, first_doy INTEGER, peak_doy INTEGER, last_doy INTEGER, years_observed INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lichinales_phenology_species_id ON ord_lichinales_phenology (species_id); CREATE INDEX ix_ord_lichinales_phenology_region_country_id ON ord_lichinales_phenology (region_country_id); CREATE TABLE ord_lichinales_host_associations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, association_type TEXT, specificity TEXT, evidence_publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (evidence_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lichinales_host_associations_species_id ON ord_lichinales_host_associations (species_id); CREATE INDEX ix_ord_lichinales_host_associations_host_id ON ord_lichinales_host_associations (host_id); CREATE TABLE ord_lichinales_substrate_preferences ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, substrate_id INTEGER NOT NULL, preference_score REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (substrate_id) REFERENCES eco_substrate_types (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lichinales_substrate_preferences_species_id ON ord_lichinales_substrate_preferences (species_id); CREATE INDEX ix_ord_lichinales_substrate_preferences_substrate_id ON ord_lichinales_substrate_preferences (substrate_id); CREATE TABLE ord_lichinales_geographic_distribution ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, occurrence_status TEXT, first_record_year INTEGER, record_count INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lichinales_geographic_distribution_species_id ON ord_lichinales_geographic_distribution (species_id); CREATE INDEX ix_ord_lichinales_geographic_distribution_country_id ON ord_lichinales_geographic_distribution (country_id); CREATE TABLE ord_lichinales_phylogeny ( id INTEGER PRIMARY KEY AUTOINCREMENT, tree_id INTEGER NOT NULL, focal_genus_id INTEGER, publication_id INTEGER, notes_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (tree_id) REFERENCES phy_trees (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lichinales_phylogeny_tree_id ON ord_lichinales_phylogeny (tree_id); CREATE INDEX ix_ord_lichinales_phylogeny_focal_genus_id ON ord_lichinales_phylogeny (focal_genus_id); CREATE TABLE ord_lichinales_genomics ( id INTEGER PRIMARY KEY AUTOINCREMENT, assembly_id INTEGER NOT NULL, species_id INTEGER, avg_genome_size_mb REAL, avg_gene_count INTEGER, avg_busco_complete_pct REAL, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (assembly_id) REFERENCES gen_assemblies (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lichinales_genomics_assembly_id ON ord_lichinales_genomics (assembly_id); CREATE INDEX ix_ord_lichinales_genomics_species_id ON ord_lichinales_genomics (species_id); CREATE TABLE ord_lichinales_biochemistry ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, typicality TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lichinales_biochemistry_species_id ON ord_lichinales_biochemistry (species_id); CREATE INDEX ix_ord_lichinales_biochemistry_compound_id ON ord_lichinales_biochemistry (compound_id); CREATE TABLE ord_lichinales_cultivation_notes ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, typical_growth_rate_mm_per_day REAL, preferred_media_type_id INTEGER, optimal_temperature_c REAL, difficulty_score INTEGER CHECK (difficulty_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (preferred_media_type_id) REFERENCES cul_media_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lichinales_cultivation_notes_species_id ON ord_lichinales_cultivation_notes (species_id); CREATE INDEX ix_ord_lichinales_cultivation_notes_strain_id ON ord_lichinales_cultivation_notes (strain_id); CREATE TABLE ord_lichinales_pathogenicity ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, disease_id INTEGER, severity_score INTEGER CHECK (severity_score BETWEEN 1 AND 5), publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (disease_id) REFERENCES pat_diseases (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lichinales_pathogenicity_species_id ON ord_lichinales_pathogenicity (species_id); CREATE INDEX ix_ord_lichinales_pathogenicity_host_id ON ord_lichinales_pathogenicity (host_id); CREATE TABLE ord_lichinales_edibility ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, edibility_class TEXT, preparation_notes TEXT, regional_tradition_country_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (regional_tradition_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lichinales_edibility_species_id ON ord_lichinales_edibility (species_id); CREATE INDEX ix_ord_lichinales_edibility_regional_tradition_country_id ON ord_lichinales_edibility (regional_tradition_country_id); CREATE TABLE ord_lichinales_medicinal_uses ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, traditional_use_text TEXT, modern_evidence_level TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lichinales_medicinal_uses_species_id ON ord_lichinales_medicinal_uses (species_id); CREATE INDEX ix_ord_lichinales_medicinal_uses_publication_id ON ord_lichinales_medicinal_uses (publication_id); CREATE TABLE ord_lichinales_taxonomic_revisions ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER NOT NULL, affected_family_id INTEGER, affected_genus_id INTEGER, revision_summary TEXT, revision_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_family_id) REFERENCES tax_families (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lichinales_taxonomic_revisions_publication_id ON ord_lichinales_taxonomic_revisions (publication_id); CREATE INDEX ix_ord_lichinales_taxonomic_revisions_affected_family_id ON ord_lichinales_taxonomic_revisions (affected_family_id); CREATE TABLE ord_lichinales_conservation_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, national_redlist_category TEXT, habitat_pressure_text TEXT, last_assessment_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lichinales_conservation_status_species_id ON ord_lichinales_conservation_status (species_id); CREATE INDEX ix_ord_lichinales_conservation_status_country_id ON ord_lichinales_conservation_status (country_id); CREATE TABLE ord_lichinales_diagnostic_keys ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER, key_title TEXT NOT NULL, region_country_id INTEGER, n_taxa_covered INTEGER, key_format TEXT, includes_microscopy INTEGER NOT NULL DEFAULT 0, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lichinales_diagnostic_keys_publication_id ON ord_lichinales_diagnostic_keys (publication_id); CREATE INDEX ix_ord_lichinales_diagnostic_keys_region_country_id ON ord_lichinales_diagnostic_keys (region_country_id); CREATE TABLE ord_lichinales_type_species_register ( id INTEGER PRIMARY KEY AUTOINCREMENT, focal_genus_id INTEGER NOT NULL, type_species_id INTEGER, designation_publication_id INTEGER, designation_year INTEGER, designated_by_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (designation_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lichinales_type_species_register_focal_genus_id ON ord_lichinales_type_species_register (focal_genus_id); CREATE INDEX ix_ord_lichinales_type_species_register_type_species_id ON ord_lichinales_type_species_register (type_species_id); CREATE TABLE ord_lichinales_distribution_grids ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, grid_cell_code TEXT NOT NULL, centroid_lat REAL, centroid_lon REAL, record_count INTEGER, first_record_year INTEGER, most_recent_record_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lichinales_distribution_grids_species_id ON ord_lichinales_distribution_grids (species_id); CREATE INDEX ix_ord_lichinales_distribution_grids_country_id ON ord_lichinales_distribution_grids (country_id); CREATE TABLE ord_lichinales_microclimate_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER, publication_id INTEGER, substrate_temperature_c REAL, substrate_moisture_pct REAL, canopy_closure_pct REAL, photosynthetic_par_umol_m2_s REAL, days_post_rainfall INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lichinales_microclimate_studies_species_id ON ord_lichinales_microclimate_studies (species_id); CREATE INDEX ix_ord_lichinales_microclimate_studies_publication_id ON ord_lichinales_microclimate_studies (publication_id); CREATE TABLE ord_lichinales_dna_barcoding_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, its_sequenced INTEGER NOT NULL DEFAULT 0, lsu_sequenced INTEGER NOT NULL DEFAULT 0, rpb2_sequenced INTEGER NOT NULL DEFAULT 0, ef1a_sequenced INTEGER NOT NULL DEFAULT 0, genome_assembled INTEGER NOT NULL DEFAULT 0, priority_for_sequencing_score INTEGER CHECK (priority_for_sequencing_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lichinales_dna_barcoding_status_species_id ON ord_lichinales_dna_barcoding_status (species_id); CREATE TABLE ord_lichinales_spore_print_data ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, specimen_id INTEGER, print_color_label TEXT, print_color_chip_id INTEGER, spore_density_per_mm2 REAL, collection_substrate TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (print_color_chip_id) REFERENCES mor_color_chips (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lichinales_spore_print_data_species_id ON ord_lichinales_spore_print_data (species_id); CREATE INDEX ix_ord_lichinales_spore_print_data_specimen_id ON ord_lichinales_spore_print_data (specimen_id); CREATE TABLE ord_lichinales_mating_systems ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, system_type TEXT, mating_loci_count INTEGER, publication_id INTEGER, notes_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lichinales_mating_systems_species_id ON ord_lichinales_mating_systems (species_id); CREATE INDEX ix_ord_lichinales_mating_systems_publication_id ON ord_lichinales_mating_systems (publication_id); CREATE TABLE ord_lichinales_nutrient_uptake_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, nitrogen_source TEXT, carbon_source TEXT, growth_response TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lichinales_nutrient_uptake_studies_species_id ON ord_lichinales_nutrient_uptake_studies (species_id); CREATE INDEX ix_ord_lichinales_nutrient_uptake_studies_strain_id ON ord_lichinales_nutrient_uptake_studies (strain_id); CREATE TABLE ord_lichinales_range_maps ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, polygon_file_uri TEXT NOT NULL, source_methodology TEXT, area_km2 REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lichinales_range_maps_species_id ON ord_lichinales_range_maps (species_id); CREATE INDEX ix_ord_lichinales_range_maps_publication_id ON ord_lichinales_range_maps (publication_id); CREATE TABLE ord_lichinales_abundance_estimates ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, estimate_kind TEXT, value_min REAL, value_max REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lichinales_abundance_estimates_species_id ON ord_lichinales_abundance_estimates (species_id); CREATE INDEX ix_ord_lichinales_abundance_estimates_country_id ON ord_lichinales_abundance_estimates (country_id); CREATE TABLE ord_lichinales_toxin_profiles ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, presence TEXT, typical_concentration_mg_per_kg REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lichinales_toxin_profiles_species_id ON ord_lichinales_toxin_profiles (species_id); CREATE INDEX ix_ord_lichinales_toxin_profiles_compound_id ON ord_lichinales_toxin_profiles (compound_id); CREATE TABLE ord_lichinales_enzyme_activity_assays ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, enzyme_id INTEGER NOT NULL, strain_id INTEGER, activity_u_per_mg REAL, temperature_c REAL, ph REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (enzyme_id) REFERENCES bio_enzymes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lichinales_enzyme_activity_assays_species_id ON ord_lichinales_enzyme_activity_assays (species_id); CREATE INDEX ix_ord_lichinales_enzyme_activity_assays_enzyme_id ON ord_lichinales_enzyme_activity_assays (enzyme_id); CREATE TABLE ord_lichinales_biocontrol_evaluations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, target_pest_text TEXT NOT NULL, efficacy_pct REAL, trial_setting TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lichinales_biocontrol_evaluations_species_id ON ord_lichinales_biocontrol_evaluations (species_id); CREATE INDEX ix_ord_lichinales_biocontrol_evaluations_publication_id ON ord_lichinales_biocontrol_evaluations (publication_id); CREATE TABLE ord_lichinales_regional_checklists ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, checklist_publication_id INTEGER, status TEXT, checklist_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (checklist_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_lichinales_regional_checklists_species_id ON ord_lichinales_regional_checklists (species_id); CREATE INDEX ix_ord_lichinales_regional_checklists_country_id ON ord_lichinales_regional_checklists (country_id); CREATE TABLE ord_umbilicariales_morphology ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, hymenium_color_at_maturity TEXT, context_color_at_maturity TEXT, characteristic_microstructure TEXT, diagnostic_features_text TEXT, notes_kohler_reaction TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_umbilicariales_morphology_specimen_id ON ord_umbilicariales_morphology (specimen_id); CREATE INDEX ix_ord_umbilicariales_morphology_species_id ON ord_umbilicariales_morphology (species_id); CREATE TABLE ord_umbilicariales_ecology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, dominant_habitat_id INTEGER, dominant_substrate_id INTEGER, dominant_biome_id INTEGER, trophic_strategy TEXT, typical_fruiting_period TEXT, known_distribution_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_habitat_id) REFERENCES eco_habitat_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_substrate_id) REFERENCES eco_substrate_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_biome_id) REFERENCES geo_biomes (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_umbilicariales_ecology_species_id ON ord_umbilicariales_ecology (species_id); CREATE INDEX ix_ord_umbilicariales_ecology_dominant_habitat_id ON ord_umbilicariales_ecology (dominant_habitat_id); CREATE TABLE ord_umbilicariales_phenology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, season_name TEXT, region_country_id INTEGER, first_doy INTEGER, peak_doy INTEGER, last_doy INTEGER, years_observed INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_umbilicariales_phenology_species_id ON ord_umbilicariales_phenology (species_id); CREATE INDEX ix_ord_umbilicariales_phenology_region_country_id ON ord_umbilicariales_phenology (region_country_id); CREATE TABLE ord_umbilicariales_host_associations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, association_type TEXT, specificity TEXT, evidence_publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (evidence_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_umbilicariales_host_associations_species_id ON ord_umbilicariales_host_associations (species_id); CREATE INDEX ix_ord_umbilicariales_host_associations_host_id ON ord_umbilicariales_host_associations (host_id); CREATE TABLE ord_umbilicariales_substrate_preferences ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, substrate_id INTEGER NOT NULL, preference_score REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (substrate_id) REFERENCES eco_substrate_types (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_umbilicariales_substrate_preferences_species_id ON ord_umbilicariales_substrate_preferences (species_id); CREATE INDEX ix_ord_umbilicariales_substrate_preferences_substrate_id ON ord_umbilicariales_substrate_preferences (substrate_id); CREATE TABLE ord_umbilicariales_geographic_distribution ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, occurrence_status TEXT, first_record_year INTEGER, record_count INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_umbilicariales_geographic_distribution_species_id ON ord_umbilicariales_geographic_distribution (species_id); CREATE INDEX ix_ord_umbilicariales_geographic_distribution_country_id ON ord_umbilicariales_geographic_distribution (country_id); CREATE TABLE ord_umbilicariales_phylogeny ( id INTEGER PRIMARY KEY AUTOINCREMENT, tree_id INTEGER NOT NULL, focal_genus_id INTEGER, publication_id INTEGER, notes_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (tree_id) REFERENCES phy_trees (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_umbilicariales_phylogeny_tree_id ON ord_umbilicariales_phylogeny (tree_id); CREATE INDEX ix_ord_umbilicariales_phylogeny_focal_genus_id ON ord_umbilicariales_phylogeny (focal_genus_id); CREATE TABLE ord_umbilicariales_genomics ( id INTEGER PRIMARY KEY AUTOINCREMENT, assembly_id INTEGER NOT NULL, species_id INTEGER, avg_genome_size_mb REAL, avg_gene_count INTEGER, avg_busco_complete_pct REAL, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (assembly_id) REFERENCES gen_assemblies (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_umbilicariales_genomics_assembly_id ON ord_umbilicariales_genomics (assembly_id); CREATE INDEX ix_ord_umbilicariales_genomics_species_id ON ord_umbilicariales_genomics (species_id); CREATE TABLE ord_umbilicariales_biochemistry ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, typicality TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_umbilicariales_biochemistry_species_id ON ord_umbilicariales_biochemistry (species_id); CREATE INDEX ix_ord_umbilicariales_biochemistry_compound_id ON ord_umbilicariales_biochemistry (compound_id); CREATE TABLE ord_umbilicariales_cultivation_notes ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, typical_growth_rate_mm_per_day REAL, preferred_media_type_id INTEGER, optimal_temperature_c REAL, difficulty_score INTEGER CHECK (difficulty_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (preferred_media_type_id) REFERENCES cul_media_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_umbilicariales_cultivation_notes_species_id ON ord_umbilicariales_cultivation_notes (species_id); CREATE INDEX ix_ord_umbilicariales_cultivation_notes_strain_id ON ord_umbilicariales_cultivation_notes (strain_id); CREATE TABLE ord_umbilicariales_pathogenicity ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, disease_id INTEGER, severity_score INTEGER CHECK (severity_score BETWEEN 1 AND 5), publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (disease_id) REFERENCES pat_diseases (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_umbilicariales_pathogenicity_species_id ON ord_umbilicariales_pathogenicity (species_id); CREATE INDEX ix_ord_umbilicariales_pathogenicity_host_id ON ord_umbilicariales_pathogenicity (host_id); CREATE TABLE ord_umbilicariales_edibility ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, edibility_class TEXT, preparation_notes TEXT, regional_tradition_country_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (regional_tradition_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_umbilicariales_edibility_species_id ON ord_umbilicariales_edibility (species_id); CREATE INDEX ix_ord_umbilicariales_edibility_1 ON ord_umbilicariales_edibility (regional_tradition_country_id); CREATE TABLE ord_umbilicariales_medicinal_uses ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, traditional_use_text TEXT, modern_evidence_level TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_umbilicariales_medicinal_uses_species_id ON ord_umbilicariales_medicinal_uses (species_id); CREATE INDEX ix_ord_umbilicariales_medicinal_uses_publication_id ON ord_umbilicariales_medicinal_uses (publication_id); CREATE TABLE ord_umbilicariales_taxonomic_revisions ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER NOT NULL, affected_family_id INTEGER, affected_genus_id INTEGER, revision_summary TEXT, revision_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_family_id) REFERENCES tax_families (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_umbilicariales_taxonomic_revisions_publication_id ON ord_umbilicariales_taxonomic_revisions (publication_id); CREATE INDEX ix_ord_umbilicariales_taxonomic_revisions_affected_family_id ON ord_umbilicariales_taxonomic_revisions (affected_family_id); CREATE TABLE ord_umbilicariales_conservation_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, national_redlist_category TEXT, habitat_pressure_text TEXT, last_assessment_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_umbilicariales_conservation_status_species_id ON ord_umbilicariales_conservation_status (species_id); CREATE INDEX ix_ord_umbilicariales_conservation_status_country_id ON ord_umbilicariales_conservation_status (country_id); CREATE TABLE ord_umbilicariales_diagnostic_keys ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER, key_title TEXT NOT NULL, region_country_id INTEGER, n_taxa_covered INTEGER, key_format TEXT, includes_microscopy INTEGER NOT NULL DEFAULT 0, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_umbilicariales_diagnostic_keys_publication_id ON ord_umbilicariales_diagnostic_keys (publication_id); CREATE INDEX ix_ord_umbilicariales_diagnostic_keys_region_country_id ON ord_umbilicariales_diagnostic_keys (region_country_id); CREATE TABLE ord_umbilicariales_type_species_register ( id INTEGER PRIMARY KEY AUTOINCREMENT, focal_genus_id INTEGER NOT NULL, type_species_id INTEGER, designation_publication_id INTEGER, designation_year INTEGER, designated_by_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (designation_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_umbilicariales_type_species_register_focal_genus_id ON ord_umbilicariales_type_species_register (focal_genus_id); CREATE INDEX ix_ord_umbilicariales_type_species_register_type_species_id ON ord_umbilicariales_type_species_register (type_species_id); CREATE TABLE ord_umbilicariales_distribution_grids ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, grid_cell_code TEXT NOT NULL, centroid_lat REAL, centroid_lon REAL, record_count INTEGER, first_record_year INTEGER, most_recent_record_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_umbilicariales_distribution_grids_species_id ON ord_umbilicariales_distribution_grids (species_id); CREATE INDEX ix_ord_umbilicariales_distribution_grids_country_id ON ord_umbilicariales_distribution_grids (country_id); CREATE TABLE ord_umbilicariales_microclimate_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER, publication_id INTEGER, substrate_temperature_c REAL, substrate_moisture_pct REAL, canopy_closure_pct REAL, photosynthetic_par_umol_m2_s REAL, days_post_rainfall INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_umbilicariales_microclimate_studies_species_id ON ord_umbilicariales_microclimate_studies (species_id); CREATE INDEX ix_ord_umbilicariales_microclimate_studies_publication_id ON ord_umbilicariales_microclimate_studies (publication_id); CREATE TABLE ord_umbilicariales_dna_barcoding_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, its_sequenced INTEGER NOT NULL DEFAULT 0, lsu_sequenced INTEGER NOT NULL DEFAULT 0, rpb2_sequenced INTEGER NOT NULL DEFAULT 0, ef1a_sequenced INTEGER NOT NULL DEFAULT 0, genome_assembled INTEGER NOT NULL DEFAULT 0, priority_for_sequencing_score INTEGER CHECK (priority_for_sequencing_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_umbilicariales_dna_barcoding_status_species_id ON ord_umbilicariales_dna_barcoding_status (species_id); CREATE TABLE ord_umbilicariales_spore_print_data ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, specimen_id INTEGER, print_color_label TEXT, print_color_chip_id INTEGER, spore_density_per_mm2 REAL, collection_substrate TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (print_color_chip_id) REFERENCES mor_color_chips (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_umbilicariales_spore_print_data_species_id ON ord_umbilicariales_spore_print_data (species_id); CREATE INDEX ix_ord_umbilicariales_spore_print_data_specimen_id ON ord_umbilicariales_spore_print_data (specimen_id); CREATE TABLE ord_umbilicariales_mating_systems ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, system_type TEXT, mating_loci_count INTEGER, publication_id INTEGER, notes_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_umbilicariales_mating_systems_species_id ON ord_umbilicariales_mating_systems (species_id); CREATE INDEX ix_ord_umbilicariales_mating_systems_publication_id ON ord_umbilicariales_mating_systems (publication_id); CREATE TABLE ord_umbilicariales_nutrient_uptake_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, nitrogen_source TEXT, carbon_source TEXT, growth_response TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_umbilicariales_nutrient_uptake_studies_species_id ON ord_umbilicariales_nutrient_uptake_studies (species_id); CREATE INDEX ix_ord_umbilicariales_nutrient_uptake_studies_strain_id ON ord_umbilicariales_nutrient_uptake_studies (strain_id); CREATE TABLE ord_umbilicariales_range_maps ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, polygon_file_uri TEXT NOT NULL, source_methodology TEXT, area_km2 REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_umbilicariales_range_maps_species_id ON ord_umbilicariales_range_maps (species_id); CREATE INDEX ix_ord_umbilicariales_range_maps_publication_id ON ord_umbilicariales_range_maps (publication_id); CREATE TABLE ord_umbilicariales_abundance_estimates ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, estimate_kind TEXT, value_min REAL, value_max REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_umbilicariales_abundance_estimates_species_id ON ord_umbilicariales_abundance_estimates (species_id); CREATE INDEX ix_ord_umbilicariales_abundance_estimates_country_id ON ord_umbilicariales_abundance_estimates (country_id); CREATE TABLE ord_umbilicariales_toxin_profiles ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, presence TEXT, typical_concentration_mg_per_kg REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_umbilicariales_toxin_profiles_species_id ON ord_umbilicariales_toxin_profiles (species_id); CREATE INDEX ix_ord_umbilicariales_toxin_profiles_compound_id ON ord_umbilicariales_toxin_profiles (compound_id); CREATE TABLE ord_umbilicariales_enzyme_activity_assays ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, enzyme_id INTEGER NOT NULL, strain_id INTEGER, activity_u_per_mg REAL, temperature_c REAL, ph REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (enzyme_id) REFERENCES bio_enzymes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_umbilicariales_enzyme_activity_assays_species_id ON ord_umbilicariales_enzyme_activity_assays (species_id); CREATE INDEX ix_ord_umbilicariales_enzyme_activity_assays_enzyme_id ON ord_umbilicariales_enzyme_activity_assays (enzyme_id); CREATE TABLE ord_umbilicariales_biocontrol_evaluations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, target_pest_text TEXT NOT NULL, efficacy_pct REAL, trial_setting TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_umbilicariales_biocontrol_evaluations_species_id ON ord_umbilicariales_biocontrol_evaluations (species_id); CREATE INDEX ix_ord_umbilicariales_biocontrol_evaluations_publication_id ON ord_umbilicariales_biocontrol_evaluations (publication_id); CREATE TABLE ord_umbilicariales_regional_checklists ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, checklist_publication_id INTEGER, status TEXT, checklist_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (checklist_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_umbilicariales_regional_checklists_species_id ON ord_umbilicariales_regional_checklists (species_id); CREATE INDEX ix_ord_umbilicariales_regional_checklists_country_id ON ord_umbilicariales_regional_checklists (country_id); CREATE TABLE ord_candelariales_morphology ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, hymenium_color_at_maturity TEXT, context_color_at_maturity TEXT, characteristic_microstructure TEXT, diagnostic_features_text TEXT, notes_kohler_reaction TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_candelariales_morphology_specimen_id ON ord_candelariales_morphology (specimen_id); CREATE INDEX ix_ord_candelariales_morphology_species_id ON ord_candelariales_morphology (species_id); CREATE TABLE ord_candelariales_ecology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, dominant_habitat_id INTEGER, dominant_substrate_id INTEGER, dominant_biome_id INTEGER, trophic_strategy TEXT, typical_fruiting_period TEXT, known_distribution_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_habitat_id) REFERENCES eco_habitat_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_substrate_id) REFERENCES eco_substrate_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_biome_id) REFERENCES geo_biomes (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_candelariales_ecology_species_id ON ord_candelariales_ecology (species_id); CREATE INDEX ix_ord_candelariales_ecology_dominant_habitat_id ON ord_candelariales_ecology (dominant_habitat_id); CREATE TABLE ord_candelariales_phenology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, season_name TEXT, region_country_id INTEGER, first_doy INTEGER, peak_doy INTEGER, last_doy INTEGER, years_observed INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_candelariales_phenology_species_id ON ord_candelariales_phenology (species_id); CREATE INDEX ix_ord_candelariales_phenology_region_country_id ON ord_candelariales_phenology (region_country_id); CREATE TABLE ord_candelariales_host_associations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, association_type TEXT, specificity TEXT, evidence_publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (evidence_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_candelariales_host_associations_species_id ON ord_candelariales_host_associations (species_id); CREATE INDEX ix_ord_candelariales_host_associations_host_id ON ord_candelariales_host_associations (host_id); CREATE TABLE ord_candelariales_substrate_preferences ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, substrate_id INTEGER NOT NULL, preference_score REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (substrate_id) REFERENCES eco_substrate_types (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_candelariales_substrate_preferences_species_id ON ord_candelariales_substrate_preferences (species_id); CREATE INDEX ix_ord_candelariales_substrate_preferences_substrate_id ON ord_candelariales_substrate_preferences (substrate_id); CREATE TABLE ord_candelariales_geographic_distribution ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, occurrence_status TEXT, first_record_year INTEGER, record_count INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_candelariales_geographic_distribution_species_id ON ord_candelariales_geographic_distribution (species_id); CREATE INDEX ix_ord_candelariales_geographic_distribution_country_id ON ord_candelariales_geographic_distribution (country_id); CREATE TABLE ord_candelariales_phylogeny ( id INTEGER PRIMARY KEY AUTOINCREMENT, tree_id INTEGER NOT NULL, focal_genus_id INTEGER, publication_id INTEGER, notes_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (tree_id) REFERENCES phy_trees (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_candelariales_phylogeny_tree_id ON ord_candelariales_phylogeny (tree_id); CREATE INDEX ix_ord_candelariales_phylogeny_focal_genus_id ON ord_candelariales_phylogeny (focal_genus_id); CREATE TABLE ord_candelariales_genomics ( id INTEGER PRIMARY KEY AUTOINCREMENT, assembly_id INTEGER NOT NULL, species_id INTEGER, avg_genome_size_mb REAL, avg_gene_count INTEGER, avg_busco_complete_pct REAL, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (assembly_id) REFERENCES gen_assemblies (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_candelariales_genomics_assembly_id ON ord_candelariales_genomics (assembly_id); CREATE INDEX ix_ord_candelariales_genomics_species_id ON ord_candelariales_genomics (species_id); CREATE TABLE ord_candelariales_biochemistry ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, typicality TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_candelariales_biochemistry_species_id ON ord_candelariales_biochemistry (species_id); CREATE INDEX ix_ord_candelariales_biochemistry_compound_id ON ord_candelariales_biochemistry (compound_id); CREATE TABLE ord_candelariales_cultivation_notes ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, typical_growth_rate_mm_per_day REAL, preferred_media_type_id INTEGER, optimal_temperature_c REAL, difficulty_score INTEGER CHECK (difficulty_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (preferred_media_type_id) REFERENCES cul_media_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_candelariales_cultivation_notes_species_id ON ord_candelariales_cultivation_notes (species_id); CREATE INDEX ix_ord_candelariales_cultivation_notes_strain_id ON ord_candelariales_cultivation_notes (strain_id); CREATE TABLE ord_candelariales_pathogenicity ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, disease_id INTEGER, severity_score INTEGER CHECK (severity_score BETWEEN 1 AND 5), publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (disease_id) REFERENCES pat_diseases (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_candelariales_pathogenicity_species_id ON ord_candelariales_pathogenicity (species_id); CREATE INDEX ix_ord_candelariales_pathogenicity_host_id ON ord_candelariales_pathogenicity (host_id); CREATE TABLE ord_candelariales_edibility ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, edibility_class TEXT, preparation_notes TEXT, regional_tradition_country_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (regional_tradition_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_candelariales_edibility_species_id ON ord_candelariales_edibility (species_id); CREATE INDEX ix_ord_candelariales_edibility_regional_tradition_country_id ON ord_candelariales_edibility (regional_tradition_country_id); CREATE TABLE ord_candelariales_medicinal_uses ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, traditional_use_text TEXT, modern_evidence_level TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_candelariales_medicinal_uses_species_id ON ord_candelariales_medicinal_uses (species_id); CREATE INDEX ix_ord_candelariales_medicinal_uses_publication_id ON ord_candelariales_medicinal_uses (publication_id); CREATE TABLE ord_candelariales_taxonomic_revisions ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER NOT NULL, affected_family_id INTEGER, affected_genus_id INTEGER, revision_summary TEXT, revision_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_family_id) REFERENCES tax_families (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_candelariales_taxonomic_revisions_publication_id ON ord_candelariales_taxonomic_revisions (publication_id); CREATE INDEX ix_ord_candelariales_taxonomic_revisions_affected_family_id ON ord_candelariales_taxonomic_revisions (affected_family_id); CREATE TABLE ord_candelariales_conservation_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, national_redlist_category TEXT, habitat_pressure_text TEXT, last_assessment_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_candelariales_conservation_status_species_id ON ord_candelariales_conservation_status (species_id); CREATE INDEX ix_ord_candelariales_conservation_status_country_id ON ord_candelariales_conservation_status (country_id); CREATE TABLE ord_candelariales_diagnostic_keys ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER, key_title TEXT NOT NULL, region_country_id INTEGER, n_taxa_covered INTEGER, key_format TEXT, includes_microscopy INTEGER NOT NULL DEFAULT 0, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_candelariales_diagnostic_keys_publication_id ON ord_candelariales_diagnostic_keys (publication_id); CREATE INDEX ix_ord_candelariales_diagnostic_keys_region_country_id ON ord_candelariales_diagnostic_keys (region_country_id); CREATE TABLE ord_candelariales_type_species_register ( id INTEGER PRIMARY KEY AUTOINCREMENT, focal_genus_id INTEGER NOT NULL, type_species_id INTEGER, designation_publication_id INTEGER, designation_year INTEGER, designated_by_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (designation_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_candelariales_type_species_register_focal_genus_id ON ord_candelariales_type_species_register (focal_genus_id); CREATE INDEX ix_ord_candelariales_type_species_register_type_species_id ON ord_candelariales_type_species_register (type_species_id); CREATE TABLE ord_candelariales_distribution_grids ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, grid_cell_code TEXT NOT NULL, centroid_lat REAL, centroid_lon REAL, record_count INTEGER, first_record_year INTEGER, most_recent_record_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_candelariales_distribution_grids_species_id ON ord_candelariales_distribution_grids (species_id); CREATE INDEX ix_ord_candelariales_distribution_grids_country_id ON ord_candelariales_distribution_grids (country_id); CREATE TABLE ord_candelariales_microclimate_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER, publication_id INTEGER, substrate_temperature_c REAL, substrate_moisture_pct REAL, canopy_closure_pct REAL, photosynthetic_par_umol_m2_s REAL, days_post_rainfall INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_candelariales_microclimate_studies_species_id ON ord_candelariales_microclimate_studies (species_id); CREATE INDEX ix_ord_candelariales_microclimate_studies_publication_id ON ord_candelariales_microclimate_studies (publication_id); CREATE TABLE ord_candelariales_dna_barcoding_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, its_sequenced INTEGER NOT NULL DEFAULT 0, lsu_sequenced INTEGER NOT NULL DEFAULT 0, rpb2_sequenced INTEGER NOT NULL DEFAULT 0, ef1a_sequenced INTEGER NOT NULL DEFAULT 0, genome_assembled INTEGER NOT NULL DEFAULT 0, priority_for_sequencing_score INTEGER CHECK (priority_for_sequencing_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_candelariales_dna_barcoding_status_species_id ON ord_candelariales_dna_barcoding_status (species_id); CREATE TABLE ord_candelariales_spore_print_data ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, specimen_id INTEGER, print_color_label TEXT, print_color_chip_id INTEGER, spore_density_per_mm2 REAL, collection_substrate TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (print_color_chip_id) REFERENCES mor_color_chips (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_candelariales_spore_print_data_species_id ON ord_candelariales_spore_print_data (species_id); CREATE INDEX ix_ord_candelariales_spore_print_data_specimen_id ON ord_candelariales_spore_print_data (specimen_id); CREATE TABLE ord_candelariales_mating_systems ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, system_type TEXT, mating_loci_count INTEGER, publication_id INTEGER, notes_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_candelariales_mating_systems_species_id ON ord_candelariales_mating_systems (species_id); CREATE INDEX ix_ord_candelariales_mating_systems_publication_id ON ord_candelariales_mating_systems (publication_id); CREATE TABLE ord_candelariales_nutrient_uptake_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, nitrogen_source TEXT, carbon_source TEXT, growth_response TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_candelariales_nutrient_uptake_studies_species_id ON ord_candelariales_nutrient_uptake_studies (species_id); CREATE INDEX ix_ord_candelariales_nutrient_uptake_studies_strain_id ON ord_candelariales_nutrient_uptake_studies (strain_id); CREATE TABLE ord_candelariales_range_maps ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, polygon_file_uri TEXT NOT NULL, source_methodology TEXT, area_km2 REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_candelariales_range_maps_species_id ON ord_candelariales_range_maps (species_id); CREATE INDEX ix_ord_candelariales_range_maps_publication_id ON ord_candelariales_range_maps (publication_id); CREATE TABLE ord_candelariales_abundance_estimates ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, estimate_kind TEXT, value_min REAL, value_max REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_candelariales_abundance_estimates_species_id ON ord_candelariales_abundance_estimates (species_id); CREATE INDEX ix_ord_candelariales_abundance_estimates_country_id ON ord_candelariales_abundance_estimates (country_id); CREATE TABLE ord_candelariales_toxin_profiles ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, presence TEXT, typical_concentration_mg_per_kg REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_candelariales_toxin_profiles_species_id ON ord_candelariales_toxin_profiles (species_id); CREATE INDEX ix_ord_candelariales_toxin_profiles_compound_id ON ord_candelariales_toxin_profiles (compound_id); CREATE TABLE ord_candelariales_enzyme_activity_assays ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, enzyme_id INTEGER NOT NULL, strain_id INTEGER, activity_u_per_mg REAL, temperature_c REAL, ph REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (enzyme_id) REFERENCES bio_enzymes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_candelariales_enzyme_activity_assays_species_id ON ord_candelariales_enzyme_activity_assays (species_id); CREATE INDEX ix_ord_candelariales_enzyme_activity_assays_enzyme_id ON ord_candelariales_enzyme_activity_assays (enzyme_id); CREATE TABLE ord_candelariales_biocontrol_evaluations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, target_pest_text TEXT NOT NULL, efficacy_pct REAL, trial_setting TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_candelariales_biocontrol_evaluations_species_id ON ord_candelariales_biocontrol_evaluations (species_id); CREATE INDEX ix_ord_candelariales_biocontrol_evaluations_publication_id ON ord_candelariales_biocontrol_evaluations (publication_id); CREATE TABLE ord_candelariales_regional_checklists ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, checklist_publication_id INTEGER, status TEXT, checklist_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (checklist_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_candelariales_regional_checklists_species_id ON ord_candelariales_regional_checklists (species_id); CREATE INDEX ix_ord_candelariales_regional_checklists_country_id ON ord_candelariales_regional_checklists (country_id); CREATE TABLE ord_pertusariales_morphology ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, hymenium_color_at_maturity TEXT, context_color_at_maturity TEXT, characteristic_microstructure TEXT, diagnostic_features_text TEXT, notes_kohler_reaction TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pertusariales_morphology_specimen_id ON ord_pertusariales_morphology (specimen_id); CREATE INDEX ix_ord_pertusariales_morphology_species_id ON ord_pertusariales_morphology (species_id); CREATE TABLE ord_pertusariales_ecology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, dominant_habitat_id INTEGER, dominant_substrate_id INTEGER, dominant_biome_id INTEGER, trophic_strategy TEXT, typical_fruiting_period TEXT, known_distribution_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_habitat_id) REFERENCES eco_habitat_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_substrate_id) REFERENCES eco_substrate_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_biome_id) REFERENCES geo_biomes (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pertusariales_ecology_species_id ON ord_pertusariales_ecology (species_id); CREATE INDEX ix_ord_pertusariales_ecology_dominant_habitat_id ON ord_pertusariales_ecology (dominant_habitat_id); CREATE TABLE ord_pertusariales_phenology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, season_name TEXT, region_country_id INTEGER, first_doy INTEGER, peak_doy INTEGER, last_doy INTEGER, years_observed INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pertusariales_phenology_species_id ON ord_pertusariales_phenology (species_id); CREATE INDEX ix_ord_pertusariales_phenology_region_country_id ON ord_pertusariales_phenology (region_country_id); CREATE TABLE ord_pertusariales_host_associations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, association_type TEXT, specificity TEXT, evidence_publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (evidence_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pertusariales_host_associations_species_id ON ord_pertusariales_host_associations (species_id); CREATE INDEX ix_ord_pertusariales_host_associations_host_id ON ord_pertusariales_host_associations (host_id); CREATE TABLE ord_pertusariales_substrate_preferences ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, substrate_id INTEGER NOT NULL, preference_score REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (substrate_id) REFERENCES eco_substrate_types (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pertusariales_substrate_preferences_species_id ON ord_pertusariales_substrate_preferences (species_id); CREATE INDEX ix_ord_pertusariales_substrate_preferences_substrate_id ON ord_pertusariales_substrate_preferences (substrate_id); CREATE TABLE ord_pertusariales_geographic_distribution ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, occurrence_status TEXT, first_record_year INTEGER, record_count INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pertusariales_geographic_distribution_species_id ON ord_pertusariales_geographic_distribution (species_id); CREATE INDEX ix_ord_pertusariales_geographic_distribution_country_id ON ord_pertusariales_geographic_distribution (country_id); CREATE TABLE ord_pertusariales_phylogeny ( id INTEGER PRIMARY KEY AUTOINCREMENT, tree_id INTEGER NOT NULL, focal_genus_id INTEGER, publication_id INTEGER, notes_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (tree_id) REFERENCES phy_trees (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pertusariales_phylogeny_tree_id ON ord_pertusariales_phylogeny (tree_id); CREATE INDEX ix_ord_pertusariales_phylogeny_focal_genus_id ON ord_pertusariales_phylogeny (focal_genus_id); CREATE TABLE ord_pertusariales_genomics ( id INTEGER PRIMARY KEY AUTOINCREMENT, assembly_id INTEGER NOT NULL, species_id INTEGER, avg_genome_size_mb REAL, avg_gene_count INTEGER, avg_busco_complete_pct REAL, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (assembly_id) REFERENCES gen_assemblies (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pertusariales_genomics_assembly_id ON ord_pertusariales_genomics (assembly_id); CREATE INDEX ix_ord_pertusariales_genomics_species_id ON ord_pertusariales_genomics (species_id); CREATE TABLE ord_pertusariales_biochemistry ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, typicality TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pertusariales_biochemistry_species_id ON ord_pertusariales_biochemistry (species_id); CREATE INDEX ix_ord_pertusariales_biochemistry_compound_id ON ord_pertusariales_biochemistry (compound_id); CREATE TABLE ord_pertusariales_cultivation_notes ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, typical_growth_rate_mm_per_day REAL, preferred_media_type_id INTEGER, optimal_temperature_c REAL, difficulty_score INTEGER CHECK (difficulty_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (preferred_media_type_id) REFERENCES cul_media_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pertusariales_cultivation_notes_species_id ON ord_pertusariales_cultivation_notes (species_id); CREATE INDEX ix_ord_pertusariales_cultivation_notes_strain_id ON ord_pertusariales_cultivation_notes (strain_id); CREATE TABLE ord_pertusariales_pathogenicity ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, disease_id INTEGER, severity_score INTEGER CHECK (severity_score BETWEEN 1 AND 5), publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (disease_id) REFERENCES pat_diseases (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pertusariales_pathogenicity_species_id ON ord_pertusariales_pathogenicity (species_id); CREATE INDEX ix_ord_pertusariales_pathogenicity_host_id ON ord_pertusariales_pathogenicity (host_id); CREATE TABLE ord_pertusariales_edibility ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, edibility_class TEXT, preparation_notes TEXT, regional_tradition_country_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (regional_tradition_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pertusariales_edibility_species_id ON ord_pertusariales_edibility (species_id); CREATE INDEX ix_ord_pertusariales_edibility_regional_tradition_country_id ON ord_pertusariales_edibility (regional_tradition_country_id); CREATE TABLE ord_pertusariales_medicinal_uses ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, traditional_use_text TEXT, modern_evidence_level TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pertusariales_medicinal_uses_species_id ON ord_pertusariales_medicinal_uses (species_id); CREATE INDEX ix_ord_pertusariales_medicinal_uses_publication_id ON ord_pertusariales_medicinal_uses (publication_id); CREATE TABLE ord_pertusariales_taxonomic_revisions ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER NOT NULL, affected_family_id INTEGER, affected_genus_id INTEGER, revision_summary TEXT, revision_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_family_id) REFERENCES tax_families (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pertusariales_taxonomic_revisions_publication_id ON ord_pertusariales_taxonomic_revisions (publication_id); CREATE INDEX ix_ord_pertusariales_taxonomic_revisions_affected_family_id ON ord_pertusariales_taxonomic_revisions (affected_family_id); CREATE TABLE ord_pertusariales_conservation_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, national_redlist_category TEXT, habitat_pressure_text TEXT, last_assessment_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pertusariales_conservation_status_species_id ON ord_pertusariales_conservation_status (species_id); CREATE INDEX ix_ord_pertusariales_conservation_status_country_id ON ord_pertusariales_conservation_status (country_id); CREATE TABLE ord_pertusariales_diagnostic_keys ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER, key_title TEXT NOT NULL, region_country_id INTEGER, n_taxa_covered INTEGER, key_format TEXT, includes_microscopy INTEGER NOT NULL DEFAULT 0, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pertusariales_diagnostic_keys_publication_id ON ord_pertusariales_diagnostic_keys (publication_id); CREATE INDEX ix_ord_pertusariales_diagnostic_keys_region_country_id ON ord_pertusariales_diagnostic_keys (region_country_id); CREATE TABLE ord_pertusariales_type_species_register ( id INTEGER PRIMARY KEY AUTOINCREMENT, focal_genus_id INTEGER NOT NULL, type_species_id INTEGER, designation_publication_id INTEGER, designation_year INTEGER, designated_by_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (designation_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pertusariales_type_species_register_focal_genus_id ON ord_pertusariales_type_species_register (focal_genus_id); CREATE INDEX ix_ord_pertusariales_type_species_register_type_species_id ON ord_pertusariales_type_species_register (type_species_id); CREATE TABLE ord_pertusariales_distribution_grids ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, grid_cell_code TEXT NOT NULL, centroid_lat REAL, centroid_lon REAL, record_count INTEGER, first_record_year INTEGER, most_recent_record_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pertusariales_distribution_grids_species_id ON ord_pertusariales_distribution_grids (species_id); CREATE INDEX ix_ord_pertusariales_distribution_grids_country_id ON ord_pertusariales_distribution_grids (country_id); CREATE TABLE ord_pertusariales_microclimate_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER, publication_id INTEGER, substrate_temperature_c REAL, substrate_moisture_pct REAL, canopy_closure_pct REAL, photosynthetic_par_umol_m2_s REAL, days_post_rainfall INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pertusariales_microclimate_studies_species_id ON ord_pertusariales_microclimate_studies (species_id); CREATE INDEX ix_ord_pertusariales_microclimate_studies_publication_id ON ord_pertusariales_microclimate_studies (publication_id); CREATE TABLE ord_pertusariales_dna_barcoding_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, its_sequenced INTEGER NOT NULL DEFAULT 0, lsu_sequenced INTEGER NOT NULL DEFAULT 0, rpb2_sequenced INTEGER NOT NULL DEFAULT 0, ef1a_sequenced INTEGER NOT NULL DEFAULT 0, genome_assembled INTEGER NOT NULL DEFAULT 0, priority_for_sequencing_score INTEGER CHECK (priority_for_sequencing_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pertusariales_dna_barcoding_status_species_id ON ord_pertusariales_dna_barcoding_status (species_id); CREATE TABLE ord_pertusariales_spore_print_data ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, specimen_id INTEGER, print_color_label TEXT, print_color_chip_id INTEGER, spore_density_per_mm2 REAL, collection_substrate TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (print_color_chip_id) REFERENCES mor_color_chips (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pertusariales_spore_print_data_species_id ON ord_pertusariales_spore_print_data (species_id); CREATE INDEX ix_ord_pertusariales_spore_print_data_specimen_id ON ord_pertusariales_spore_print_data (specimen_id); CREATE TABLE ord_pertusariales_mating_systems ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, system_type TEXT, mating_loci_count INTEGER, publication_id INTEGER, notes_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pertusariales_mating_systems_species_id ON ord_pertusariales_mating_systems (species_id); CREATE INDEX ix_ord_pertusariales_mating_systems_publication_id ON ord_pertusariales_mating_systems (publication_id); CREATE TABLE ord_pertusariales_nutrient_uptake_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, nitrogen_source TEXT, carbon_source TEXT, growth_response TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pertusariales_nutrient_uptake_studies_species_id ON ord_pertusariales_nutrient_uptake_studies (species_id); CREATE INDEX ix_ord_pertusariales_nutrient_uptake_studies_strain_id ON ord_pertusariales_nutrient_uptake_studies (strain_id); CREATE TABLE ord_pertusariales_range_maps ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, polygon_file_uri TEXT NOT NULL, source_methodology TEXT, area_km2 REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pertusariales_range_maps_species_id ON ord_pertusariales_range_maps (species_id); CREATE INDEX ix_ord_pertusariales_range_maps_publication_id ON ord_pertusariales_range_maps (publication_id); CREATE TABLE ord_pertusariales_abundance_estimates ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, estimate_kind TEXT, value_min REAL, value_max REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pertusariales_abundance_estimates_species_id ON ord_pertusariales_abundance_estimates (species_id); CREATE INDEX ix_ord_pertusariales_abundance_estimates_country_id ON ord_pertusariales_abundance_estimates (country_id); CREATE TABLE ord_pertusariales_toxin_profiles ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, presence TEXT, typical_concentration_mg_per_kg REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pertusariales_toxin_profiles_species_id ON ord_pertusariales_toxin_profiles (species_id); CREATE INDEX ix_ord_pertusariales_toxin_profiles_compound_id ON ord_pertusariales_toxin_profiles (compound_id); CREATE TABLE ord_pertusariales_enzyme_activity_assays ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, enzyme_id INTEGER NOT NULL, strain_id INTEGER, activity_u_per_mg REAL, temperature_c REAL, ph REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (enzyme_id) REFERENCES bio_enzymes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pertusariales_enzyme_activity_assays_species_id ON ord_pertusariales_enzyme_activity_assays (species_id); CREATE INDEX ix_ord_pertusariales_enzyme_activity_assays_enzyme_id ON ord_pertusariales_enzyme_activity_assays (enzyme_id); CREATE TABLE ord_pertusariales_biocontrol_evaluations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, target_pest_text TEXT NOT NULL, efficacy_pct REAL, trial_setting TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pertusariales_biocontrol_evaluations_species_id ON ord_pertusariales_biocontrol_evaluations (species_id); CREATE INDEX ix_ord_pertusariales_biocontrol_evaluations_publication_id ON ord_pertusariales_biocontrol_evaluations (publication_id); CREATE TABLE ord_pertusariales_regional_checklists ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, checklist_publication_id INTEGER, status TEXT, checklist_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (checklist_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_pertusariales_regional_checklists_species_id ON ord_pertusariales_regional_checklists (species_id); CREATE INDEX ix_ord_pertusariales_regional_checklists_country_id ON ord_pertusariales_regional_checklists (country_id); CREATE TABLE ord_mycocaliciales_morphology ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, hymenium_color_at_maturity TEXT, context_color_at_maturity TEXT, characteristic_microstructure TEXT, diagnostic_features_text TEXT, notes_kohler_reaction TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mycocaliciales_morphology_specimen_id ON ord_mycocaliciales_morphology (specimen_id); CREATE INDEX ix_ord_mycocaliciales_morphology_species_id ON ord_mycocaliciales_morphology (species_id); CREATE TABLE ord_mycocaliciales_ecology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, dominant_habitat_id INTEGER, dominant_substrate_id INTEGER, dominant_biome_id INTEGER, trophic_strategy TEXT, typical_fruiting_period TEXT, known_distribution_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_habitat_id) REFERENCES eco_habitat_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_substrate_id) REFERENCES eco_substrate_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_biome_id) REFERENCES geo_biomes (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mycocaliciales_ecology_species_id ON ord_mycocaliciales_ecology (species_id); CREATE INDEX ix_ord_mycocaliciales_ecology_dominant_habitat_id ON ord_mycocaliciales_ecology (dominant_habitat_id); CREATE TABLE ord_mycocaliciales_phenology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, season_name TEXT, region_country_id INTEGER, first_doy INTEGER, peak_doy INTEGER, last_doy INTEGER, years_observed INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mycocaliciales_phenology_species_id ON ord_mycocaliciales_phenology (species_id); CREATE INDEX ix_ord_mycocaliciales_phenology_region_country_id ON ord_mycocaliciales_phenology (region_country_id); CREATE TABLE ord_mycocaliciales_host_associations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, association_type TEXT, specificity TEXT, evidence_publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (evidence_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mycocaliciales_host_associations_species_id ON ord_mycocaliciales_host_associations (species_id); CREATE INDEX ix_ord_mycocaliciales_host_associations_host_id ON ord_mycocaliciales_host_associations (host_id); CREATE TABLE ord_mycocaliciales_substrate_preferences ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, substrate_id INTEGER NOT NULL, preference_score REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (substrate_id) REFERENCES eco_substrate_types (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mycocaliciales_substrate_preferences_species_id ON ord_mycocaliciales_substrate_preferences (species_id); CREATE INDEX ix_ord_mycocaliciales_substrate_preferences_substrate_id ON ord_mycocaliciales_substrate_preferences (substrate_id); CREATE TABLE ord_mycocaliciales_geographic_distribution ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, occurrence_status TEXT, first_record_year INTEGER, record_count INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mycocaliciales_geographic_distribution_species_id ON ord_mycocaliciales_geographic_distribution (species_id); CREATE INDEX ix_ord_mycocaliciales_geographic_distribution_country_id ON ord_mycocaliciales_geographic_distribution (country_id); CREATE TABLE ord_mycocaliciales_phylogeny ( id INTEGER PRIMARY KEY AUTOINCREMENT, tree_id INTEGER NOT NULL, focal_genus_id INTEGER, publication_id INTEGER, notes_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (tree_id) REFERENCES phy_trees (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mycocaliciales_phylogeny_tree_id ON ord_mycocaliciales_phylogeny (tree_id); CREATE INDEX ix_ord_mycocaliciales_phylogeny_focal_genus_id ON ord_mycocaliciales_phylogeny (focal_genus_id); CREATE TABLE ord_mycocaliciales_genomics ( id INTEGER PRIMARY KEY AUTOINCREMENT, assembly_id INTEGER NOT NULL, species_id INTEGER, avg_genome_size_mb REAL, avg_gene_count INTEGER, avg_busco_complete_pct REAL, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (assembly_id) REFERENCES gen_assemblies (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mycocaliciales_genomics_assembly_id ON ord_mycocaliciales_genomics (assembly_id); CREATE INDEX ix_ord_mycocaliciales_genomics_species_id ON ord_mycocaliciales_genomics (species_id); CREATE TABLE ord_mycocaliciales_biochemistry ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, typicality TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mycocaliciales_biochemistry_species_id ON ord_mycocaliciales_biochemistry (species_id); CREATE INDEX ix_ord_mycocaliciales_biochemistry_compound_id ON ord_mycocaliciales_biochemistry (compound_id); CREATE TABLE ord_mycocaliciales_cultivation_notes ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, typical_growth_rate_mm_per_day REAL, preferred_media_type_id INTEGER, optimal_temperature_c REAL, difficulty_score INTEGER CHECK (difficulty_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (preferred_media_type_id) REFERENCES cul_media_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mycocaliciales_cultivation_notes_species_id ON ord_mycocaliciales_cultivation_notes (species_id); CREATE INDEX ix_ord_mycocaliciales_cultivation_notes_strain_id ON ord_mycocaliciales_cultivation_notes (strain_id); CREATE TABLE ord_mycocaliciales_pathogenicity ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, disease_id INTEGER, severity_score INTEGER CHECK (severity_score BETWEEN 1 AND 5), publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (disease_id) REFERENCES pat_diseases (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mycocaliciales_pathogenicity_species_id ON ord_mycocaliciales_pathogenicity (species_id); CREATE INDEX ix_ord_mycocaliciales_pathogenicity_host_id ON ord_mycocaliciales_pathogenicity (host_id); CREATE TABLE ord_mycocaliciales_edibility ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, edibility_class TEXT, preparation_notes TEXT, regional_tradition_country_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (regional_tradition_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mycocaliciales_edibility_species_id ON ord_mycocaliciales_edibility (species_id); CREATE INDEX ix_ord_mycocaliciales_edibility_1 ON ord_mycocaliciales_edibility (regional_tradition_country_id); CREATE TABLE ord_mycocaliciales_medicinal_uses ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, traditional_use_text TEXT, modern_evidence_level TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mycocaliciales_medicinal_uses_species_id ON ord_mycocaliciales_medicinal_uses (species_id); CREATE INDEX ix_ord_mycocaliciales_medicinal_uses_publication_id ON ord_mycocaliciales_medicinal_uses (publication_id); CREATE TABLE ord_mycocaliciales_taxonomic_revisions ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER NOT NULL, affected_family_id INTEGER, affected_genus_id INTEGER, revision_summary TEXT, revision_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_family_id) REFERENCES tax_families (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mycocaliciales_taxonomic_revisions_publication_id ON ord_mycocaliciales_taxonomic_revisions (publication_id); CREATE INDEX ix_ord_mycocaliciales_taxonomic_revisions_affected_family_id ON ord_mycocaliciales_taxonomic_revisions (affected_family_id); CREATE TABLE ord_mycocaliciales_conservation_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, national_redlist_category TEXT, habitat_pressure_text TEXT, last_assessment_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mycocaliciales_conservation_status_species_id ON ord_mycocaliciales_conservation_status (species_id); CREATE INDEX ix_ord_mycocaliciales_conservation_status_country_id ON ord_mycocaliciales_conservation_status (country_id); CREATE TABLE ord_mycocaliciales_diagnostic_keys ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER, key_title TEXT NOT NULL, region_country_id INTEGER, n_taxa_covered INTEGER, key_format TEXT, includes_microscopy INTEGER NOT NULL DEFAULT 0, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mycocaliciales_diagnostic_keys_publication_id ON ord_mycocaliciales_diagnostic_keys (publication_id); CREATE INDEX ix_ord_mycocaliciales_diagnostic_keys_region_country_id ON ord_mycocaliciales_diagnostic_keys (region_country_id); CREATE TABLE ord_mycocaliciales_type_species_register ( id INTEGER PRIMARY KEY AUTOINCREMENT, focal_genus_id INTEGER NOT NULL, type_species_id INTEGER, designation_publication_id INTEGER, designation_year INTEGER, designated_by_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (designation_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mycocaliciales_type_species_register_focal_genus_id ON ord_mycocaliciales_type_species_register (focal_genus_id); CREATE INDEX ix_ord_mycocaliciales_type_species_register_type_species_id ON ord_mycocaliciales_type_species_register (type_species_id); CREATE TABLE ord_mycocaliciales_distribution_grids ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, grid_cell_code TEXT NOT NULL, centroid_lat REAL, centroid_lon REAL, record_count INTEGER, first_record_year INTEGER, most_recent_record_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mycocaliciales_distribution_grids_species_id ON ord_mycocaliciales_distribution_grids (species_id); CREATE INDEX ix_ord_mycocaliciales_distribution_grids_country_id ON ord_mycocaliciales_distribution_grids (country_id); CREATE TABLE ord_mycocaliciales_microclimate_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER, publication_id INTEGER, substrate_temperature_c REAL, substrate_moisture_pct REAL, canopy_closure_pct REAL, photosynthetic_par_umol_m2_s REAL, days_post_rainfall INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mycocaliciales_microclimate_studies_species_id ON ord_mycocaliciales_microclimate_studies (species_id); CREATE INDEX ix_ord_mycocaliciales_microclimate_studies_publication_id ON ord_mycocaliciales_microclimate_studies (publication_id); CREATE TABLE ord_mycocaliciales_dna_barcoding_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, its_sequenced INTEGER NOT NULL DEFAULT 0, lsu_sequenced INTEGER NOT NULL DEFAULT 0, rpb2_sequenced INTEGER NOT NULL DEFAULT 0, ef1a_sequenced INTEGER NOT NULL DEFAULT 0, genome_assembled INTEGER NOT NULL DEFAULT 0, priority_for_sequencing_score INTEGER CHECK (priority_for_sequencing_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mycocaliciales_dna_barcoding_status_species_id ON ord_mycocaliciales_dna_barcoding_status (species_id); CREATE TABLE ord_mycocaliciales_spore_print_data ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, specimen_id INTEGER, print_color_label TEXT, print_color_chip_id INTEGER, spore_density_per_mm2 REAL, collection_substrate TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (print_color_chip_id) REFERENCES mor_color_chips (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mycocaliciales_spore_print_data_species_id ON ord_mycocaliciales_spore_print_data (species_id); CREATE INDEX ix_ord_mycocaliciales_spore_print_data_specimen_id ON ord_mycocaliciales_spore_print_data (specimen_id); CREATE TABLE ord_mycocaliciales_mating_systems ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, system_type TEXT, mating_loci_count INTEGER, publication_id INTEGER, notes_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mycocaliciales_mating_systems_species_id ON ord_mycocaliciales_mating_systems (species_id); CREATE INDEX ix_ord_mycocaliciales_mating_systems_publication_id ON ord_mycocaliciales_mating_systems (publication_id); CREATE TABLE ord_mycocaliciales_nutrient_uptake_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, nitrogen_source TEXT, carbon_source TEXT, growth_response TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mycocaliciales_nutrient_uptake_studies_species_id ON ord_mycocaliciales_nutrient_uptake_studies (species_id); CREATE INDEX ix_ord_mycocaliciales_nutrient_uptake_studies_strain_id ON ord_mycocaliciales_nutrient_uptake_studies (strain_id); CREATE TABLE ord_mycocaliciales_range_maps ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, polygon_file_uri TEXT NOT NULL, source_methodology TEXT, area_km2 REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mycocaliciales_range_maps_species_id ON ord_mycocaliciales_range_maps (species_id); CREATE INDEX ix_ord_mycocaliciales_range_maps_publication_id ON ord_mycocaliciales_range_maps (publication_id); CREATE TABLE ord_mycocaliciales_abundance_estimates ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, estimate_kind TEXT, value_min REAL, value_max REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mycocaliciales_abundance_estimates_species_id ON ord_mycocaliciales_abundance_estimates (species_id); CREATE INDEX ix_ord_mycocaliciales_abundance_estimates_country_id ON ord_mycocaliciales_abundance_estimates (country_id); CREATE TABLE ord_mycocaliciales_toxin_profiles ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, presence TEXT, typical_concentration_mg_per_kg REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mycocaliciales_toxin_profiles_species_id ON ord_mycocaliciales_toxin_profiles (species_id); CREATE INDEX ix_ord_mycocaliciales_toxin_profiles_compound_id ON ord_mycocaliciales_toxin_profiles (compound_id); CREATE TABLE ord_mycocaliciales_enzyme_activity_assays ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, enzyme_id INTEGER NOT NULL, strain_id INTEGER, activity_u_per_mg REAL, temperature_c REAL, ph REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (enzyme_id) REFERENCES bio_enzymes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mycocaliciales_enzyme_activity_assays_species_id ON ord_mycocaliciales_enzyme_activity_assays (species_id); CREATE INDEX ix_ord_mycocaliciales_enzyme_activity_assays_enzyme_id ON ord_mycocaliciales_enzyme_activity_assays (enzyme_id); CREATE TABLE ord_mycocaliciales_biocontrol_evaluations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, target_pest_text TEXT NOT NULL, efficacy_pct REAL, trial_setting TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mycocaliciales_biocontrol_evaluations_species_id ON ord_mycocaliciales_biocontrol_evaluations (species_id); CREATE INDEX ix_ord_mycocaliciales_biocontrol_evaluations_publication_id ON ord_mycocaliciales_biocontrol_evaluations (publication_id); CREATE TABLE ord_mycocaliciales_regional_checklists ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, checklist_publication_id INTEGER, status TEXT, checklist_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (checklist_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mycocaliciales_regional_checklists_species_id ON ord_mycocaliciales_regional_checklists (species_id); CREATE INDEX ix_ord_mycocaliciales_regional_checklists_country_id ON ord_mycocaliciales_regional_checklists (country_id); CREATE TABLE ord_graphidales_morphology ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, hymenium_color_at_maturity TEXT, context_color_at_maturity TEXT, characteristic_microstructure TEXT, diagnostic_features_text TEXT, notes_kohler_reaction TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_graphidales_morphology_specimen_id ON ord_graphidales_morphology (specimen_id); CREATE INDEX ix_ord_graphidales_morphology_species_id ON ord_graphidales_morphology (species_id); CREATE TABLE ord_graphidales_ecology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, dominant_habitat_id INTEGER, dominant_substrate_id INTEGER, dominant_biome_id INTEGER, trophic_strategy TEXT, typical_fruiting_period TEXT, known_distribution_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_habitat_id) REFERENCES eco_habitat_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_substrate_id) REFERENCES eco_substrate_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_biome_id) REFERENCES geo_biomes (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_graphidales_ecology_species_id ON ord_graphidales_ecology (species_id); CREATE INDEX ix_ord_graphidales_ecology_dominant_habitat_id ON ord_graphidales_ecology (dominant_habitat_id); CREATE TABLE ord_graphidales_phenology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, season_name TEXT, region_country_id INTEGER, first_doy INTEGER, peak_doy INTEGER, last_doy INTEGER, years_observed INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_graphidales_phenology_species_id ON ord_graphidales_phenology (species_id); CREATE INDEX ix_ord_graphidales_phenology_region_country_id ON ord_graphidales_phenology (region_country_id); CREATE TABLE ord_graphidales_host_associations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, association_type TEXT, specificity TEXT, evidence_publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (evidence_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_graphidales_host_associations_species_id ON ord_graphidales_host_associations (species_id); CREATE INDEX ix_ord_graphidales_host_associations_host_id ON ord_graphidales_host_associations (host_id); CREATE TABLE ord_graphidales_substrate_preferences ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, substrate_id INTEGER NOT NULL, preference_score REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (substrate_id) REFERENCES eco_substrate_types (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_graphidales_substrate_preferences_species_id ON ord_graphidales_substrate_preferences (species_id); CREATE INDEX ix_ord_graphidales_substrate_preferences_substrate_id ON ord_graphidales_substrate_preferences (substrate_id); CREATE TABLE ord_graphidales_geographic_distribution ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, occurrence_status TEXT, first_record_year INTEGER, record_count INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_graphidales_geographic_distribution_species_id ON ord_graphidales_geographic_distribution (species_id); CREATE INDEX ix_ord_graphidales_geographic_distribution_country_id ON ord_graphidales_geographic_distribution (country_id); CREATE TABLE ord_graphidales_phylogeny ( id INTEGER PRIMARY KEY AUTOINCREMENT, tree_id INTEGER NOT NULL, focal_genus_id INTEGER, publication_id INTEGER, notes_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (tree_id) REFERENCES phy_trees (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_graphidales_phylogeny_tree_id ON ord_graphidales_phylogeny (tree_id); CREATE INDEX ix_ord_graphidales_phylogeny_focal_genus_id ON ord_graphidales_phylogeny (focal_genus_id); CREATE TABLE ord_graphidales_genomics ( id INTEGER PRIMARY KEY AUTOINCREMENT, assembly_id INTEGER NOT NULL, species_id INTEGER, avg_genome_size_mb REAL, avg_gene_count INTEGER, avg_busco_complete_pct REAL, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (assembly_id) REFERENCES gen_assemblies (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_graphidales_genomics_assembly_id ON ord_graphidales_genomics (assembly_id); CREATE INDEX ix_ord_graphidales_genomics_species_id ON ord_graphidales_genomics (species_id); CREATE TABLE ord_graphidales_biochemistry ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, typicality TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_graphidales_biochemistry_species_id ON ord_graphidales_biochemistry (species_id); CREATE INDEX ix_ord_graphidales_biochemistry_compound_id ON ord_graphidales_biochemistry (compound_id); CREATE TABLE ord_graphidales_cultivation_notes ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, typical_growth_rate_mm_per_day REAL, preferred_media_type_id INTEGER, optimal_temperature_c REAL, difficulty_score INTEGER CHECK (difficulty_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (preferred_media_type_id) REFERENCES cul_media_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_graphidales_cultivation_notes_species_id ON ord_graphidales_cultivation_notes (species_id); CREATE INDEX ix_ord_graphidales_cultivation_notes_strain_id ON ord_graphidales_cultivation_notes (strain_id); CREATE TABLE ord_graphidales_pathogenicity ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, disease_id INTEGER, severity_score INTEGER CHECK (severity_score BETWEEN 1 AND 5), publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (disease_id) REFERENCES pat_diseases (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_graphidales_pathogenicity_species_id ON ord_graphidales_pathogenicity (species_id); CREATE INDEX ix_ord_graphidales_pathogenicity_host_id ON ord_graphidales_pathogenicity (host_id); CREATE TABLE ord_graphidales_edibility ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, edibility_class TEXT, preparation_notes TEXT, regional_tradition_country_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (regional_tradition_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_graphidales_edibility_species_id ON ord_graphidales_edibility (species_id); CREATE INDEX ix_ord_graphidales_edibility_regional_tradition_country_id ON ord_graphidales_edibility (regional_tradition_country_id); CREATE TABLE ord_graphidales_medicinal_uses ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, traditional_use_text TEXT, modern_evidence_level TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_graphidales_medicinal_uses_species_id ON ord_graphidales_medicinal_uses (species_id); CREATE INDEX ix_ord_graphidales_medicinal_uses_publication_id ON ord_graphidales_medicinal_uses (publication_id); CREATE TABLE ord_graphidales_taxonomic_revisions ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER NOT NULL, affected_family_id INTEGER, affected_genus_id INTEGER, revision_summary TEXT, revision_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_family_id) REFERENCES tax_families (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_graphidales_taxonomic_revisions_publication_id ON ord_graphidales_taxonomic_revisions (publication_id); CREATE INDEX ix_ord_graphidales_taxonomic_revisions_affected_family_id ON ord_graphidales_taxonomic_revisions (affected_family_id); CREATE TABLE ord_graphidales_conservation_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, national_redlist_category TEXT, habitat_pressure_text TEXT, last_assessment_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_graphidales_conservation_status_species_id ON ord_graphidales_conservation_status (species_id); CREATE INDEX ix_ord_graphidales_conservation_status_country_id ON ord_graphidales_conservation_status (country_id); CREATE TABLE ord_graphidales_diagnostic_keys ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER, key_title TEXT NOT NULL, region_country_id INTEGER, n_taxa_covered INTEGER, key_format TEXT, includes_microscopy INTEGER NOT NULL DEFAULT 0, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_graphidales_diagnostic_keys_publication_id ON ord_graphidales_diagnostic_keys (publication_id); CREATE INDEX ix_ord_graphidales_diagnostic_keys_region_country_id ON ord_graphidales_diagnostic_keys (region_country_id); CREATE TABLE ord_graphidales_type_species_register ( id INTEGER PRIMARY KEY AUTOINCREMENT, focal_genus_id INTEGER NOT NULL, type_species_id INTEGER, designation_publication_id INTEGER, designation_year INTEGER, designated_by_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (designation_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_graphidales_type_species_register_focal_genus_id ON ord_graphidales_type_species_register (focal_genus_id); CREATE INDEX ix_ord_graphidales_type_species_register_type_species_id ON ord_graphidales_type_species_register (type_species_id); CREATE TABLE ord_graphidales_distribution_grids ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, grid_cell_code TEXT NOT NULL, centroid_lat REAL, centroid_lon REAL, record_count INTEGER, first_record_year INTEGER, most_recent_record_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_graphidales_distribution_grids_species_id ON ord_graphidales_distribution_grids (species_id); CREATE INDEX ix_ord_graphidales_distribution_grids_country_id ON ord_graphidales_distribution_grids (country_id); CREATE TABLE ord_graphidales_microclimate_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER, publication_id INTEGER, substrate_temperature_c REAL, substrate_moisture_pct REAL, canopy_closure_pct REAL, photosynthetic_par_umol_m2_s REAL, days_post_rainfall INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_graphidales_microclimate_studies_species_id ON ord_graphidales_microclimate_studies (species_id); CREATE INDEX ix_ord_graphidales_microclimate_studies_publication_id ON ord_graphidales_microclimate_studies (publication_id); CREATE TABLE ord_graphidales_dna_barcoding_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, its_sequenced INTEGER NOT NULL DEFAULT 0, lsu_sequenced INTEGER NOT NULL DEFAULT 0, rpb2_sequenced INTEGER NOT NULL DEFAULT 0, ef1a_sequenced INTEGER NOT NULL DEFAULT 0, genome_assembled INTEGER NOT NULL DEFAULT 0, priority_for_sequencing_score INTEGER CHECK (priority_for_sequencing_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_graphidales_dna_barcoding_status_species_id ON ord_graphidales_dna_barcoding_status (species_id); CREATE TABLE ord_graphidales_spore_print_data ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, specimen_id INTEGER, print_color_label TEXT, print_color_chip_id INTEGER, spore_density_per_mm2 REAL, collection_substrate TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (print_color_chip_id) REFERENCES mor_color_chips (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_graphidales_spore_print_data_species_id ON ord_graphidales_spore_print_data (species_id); CREATE INDEX ix_ord_graphidales_spore_print_data_specimen_id ON ord_graphidales_spore_print_data (specimen_id); CREATE TABLE ord_graphidales_mating_systems ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, system_type TEXT, mating_loci_count INTEGER, publication_id INTEGER, notes_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_graphidales_mating_systems_species_id ON ord_graphidales_mating_systems (species_id); CREATE INDEX ix_ord_graphidales_mating_systems_publication_id ON ord_graphidales_mating_systems (publication_id); CREATE TABLE ord_graphidales_nutrient_uptake_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, nitrogen_source TEXT, carbon_source TEXT, growth_response TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_graphidales_nutrient_uptake_studies_species_id ON ord_graphidales_nutrient_uptake_studies (species_id); CREATE INDEX ix_ord_graphidales_nutrient_uptake_studies_strain_id ON ord_graphidales_nutrient_uptake_studies (strain_id); CREATE TABLE ord_graphidales_range_maps ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, polygon_file_uri TEXT NOT NULL, source_methodology TEXT, area_km2 REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_graphidales_range_maps_species_id ON ord_graphidales_range_maps (species_id); CREATE INDEX ix_ord_graphidales_range_maps_publication_id ON ord_graphidales_range_maps (publication_id); CREATE TABLE ord_graphidales_abundance_estimates ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, estimate_kind TEXT, value_min REAL, value_max REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_graphidales_abundance_estimates_species_id ON ord_graphidales_abundance_estimates (species_id); CREATE INDEX ix_ord_graphidales_abundance_estimates_country_id ON ord_graphidales_abundance_estimates (country_id); CREATE TABLE ord_graphidales_toxin_profiles ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, presence TEXT, typical_concentration_mg_per_kg REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_graphidales_toxin_profiles_species_id ON ord_graphidales_toxin_profiles (species_id); CREATE INDEX ix_ord_graphidales_toxin_profiles_compound_id ON ord_graphidales_toxin_profiles (compound_id); CREATE TABLE ord_graphidales_enzyme_activity_assays ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, enzyme_id INTEGER NOT NULL, strain_id INTEGER, activity_u_per_mg REAL, temperature_c REAL, ph REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (enzyme_id) REFERENCES bio_enzymes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_graphidales_enzyme_activity_assays_species_id ON ord_graphidales_enzyme_activity_assays (species_id); CREATE INDEX ix_ord_graphidales_enzyme_activity_assays_enzyme_id ON ord_graphidales_enzyme_activity_assays (enzyme_id); CREATE TABLE ord_graphidales_biocontrol_evaluations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, target_pest_text TEXT NOT NULL, efficacy_pct REAL, trial_setting TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_graphidales_biocontrol_evaluations_species_id ON ord_graphidales_biocontrol_evaluations (species_id); CREATE INDEX ix_ord_graphidales_biocontrol_evaluations_publication_id ON ord_graphidales_biocontrol_evaluations (publication_id); CREATE TABLE ord_graphidales_regional_checklists ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, checklist_publication_id INTEGER, status TEXT, checklist_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (checklist_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_graphidales_regional_checklists_species_id ON ord_graphidales_regional_checklists (species_id); CREATE INDEX ix_ord_graphidales_regional_checklists_country_id ON ord_graphidales_regional_checklists (country_id); CREATE TABLE ord_mucorales_morphology ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, hymenium_color_at_maturity TEXT, context_color_at_maturity TEXT, characteristic_microstructure TEXT, diagnostic_features_text TEXT, notes_kohler_reaction TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mucorales_morphology_specimen_id ON ord_mucorales_morphology (specimen_id); CREATE INDEX ix_ord_mucorales_morphology_species_id ON ord_mucorales_morphology (species_id); CREATE TABLE ord_mucorales_ecology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, dominant_habitat_id INTEGER, dominant_substrate_id INTEGER, dominant_biome_id INTEGER, trophic_strategy TEXT, typical_fruiting_period TEXT, known_distribution_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_habitat_id) REFERENCES eco_habitat_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_substrate_id) REFERENCES eco_substrate_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_biome_id) REFERENCES geo_biomes (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mucorales_ecology_species_id ON ord_mucorales_ecology (species_id); CREATE INDEX ix_ord_mucorales_ecology_dominant_habitat_id ON ord_mucorales_ecology (dominant_habitat_id); CREATE TABLE ord_mucorales_phenology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, season_name TEXT, region_country_id INTEGER, first_doy INTEGER, peak_doy INTEGER, last_doy INTEGER, years_observed INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mucorales_phenology_species_id ON ord_mucorales_phenology (species_id); CREATE INDEX ix_ord_mucorales_phenology_region_country_id ON ord_mucorales_phenology (region_country_id); CREATE TABLE ord_mucorales_host_associations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, association_type TEXT, specificity TEXT, evidence_publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (evidence_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mucorales_host_associations_species_id ON ord_mucorales_host_associations (species_id); CREATE INDEX ix_ord_mucorales_host_associations_host_id ON ord_mucorales_host_associations (host_id); CREATE TABLE ord_mucorales_substrate_preferences ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, substrate_id INTEGER NOT NULL, preference_score REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (substrate_id) REFERENCES eco_substrate_types (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mucorales_substrate_preferences_species_id ON ord_mucorales_substrate_preferences (species_id); CREATE INDEX ix_ord_mucorales_substrate_preferences_substrate_id ON ord_mucorales_substrate_preferences (substrate_id); CREATE TABLE ord_mucorales_geographic_distribution ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, occurrence_status TEXT, first_record_year INTEGER, record_count INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mucorales_geographic_distribution_species_id ON ord_mucorales_geographic_distribution (species_id); CREATE INDEX ix_ord_mucorales_geographic_distribution_country_id ON ord_mucorales_geographic_distribution (country_id); CREATE TABLE ord_mucorales_phylogeny ( id INTEGER PRIMARY KEY AUTOINCREMENT, tree_id INTEGER NOT NULL, focal_genus_id INTEGER, publication_id INTEGER, notes_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (tree_id) REFERENCES phy_trees (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mucorales_phylogeny_tree_id ON ord_mucorales_phylogeny (tree_id); CREATE INDEX ix_ord_mucorales_phylogeny_focal_genus_id ON ord_mucorales_phylogeny (focal_genus_id); CREATE TABLE ord_mucorales_genomics ( id INTEGER PRIMARY KEY AUTOINCREMENT, assembly_id INTEGER NOT NULL, species_id INTEGER, avg_genome_size_mb REAL, avg_gene_count INTEGER, avg_busco_complete_pct REAL, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (assembly_id) REFERENCES gen_assemblies (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mucorales_genomics_assembly_id ON ord_mucorales_genomics (assembly_id); CREATE INDEX ix_ord_mucorales_genomics_species_id ON ord_mucorales_genomics (species_id); CREATE TABLE ord_mucorales_biochemistry ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, typicality TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mucorales_biochemistry_species_id ON ord_mucorales_biochemistry (species_id); CREATE INDEX ix_ord_mucorales_biochemistry_compound_id ON ord_mucorales_biochemistry (compound_id); CREATE TABLE ord_mucorales_cultivation_notes ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, typical_growth_rate_mm_per_day REAL, preferred_media_type_id INTEGER, optimal_temperature_c REAL, difficulty_score INTEGER CHECK (difficulty_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (preferred_media_type_id) REFERENCES cul_media_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mucorales_cultivation_notes_species_id ON ord_mucorales_cultivation_notes (species_id); CREATE INDEX ix_ord_mucorales_cultivation_notes_strain_id ON ord_mucorales_cultivation_notes (strain_id); CREATE TABLE ord_mucorales_pathogenicity ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, disease_id INTEGER, severity_score INTEGER CHECK (severity_score BETWEEN 1 AND 5), publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (disease_id) REFERENCES pat_diseases (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mucorales_pathogenicity_species_id ON ord_mucorales_pathogenicity (species_id); CREATE INDEX ix_ord_mucorales_pathogenicity_host_id ON ord_mucorales_pathogenicity (host_id); CREATE TABLE ord_mucorales_edibility ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, edibility_class TEXT, preparation_notes TEXT, regional_tradition_country_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (regional_tradition_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mucorales_edibility_species_id ON ord_mucorales_edibility (species_id); CREATE INDEX ix_ord_mucorales_edibility_regional_tradition_country_id ON ord_mucorales_edibility (regional_tradition_country_id); CREATE TABLE ord_mucorales_medicinal_uses ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, traditional_use_text TEXT, modern_evidence_level TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mucorales_medicinal_uses_species_id ON ord_mucorales_medicinal_uses (species_id); CREATE INDEX ix_ord_mucorales_medicinal_uses_publication_id ON ord_mucorales_medicinal_uses (publication_id); CREATE TABLE ord_mucorales_taxonomic_revisions ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER NOT NULL, affected_family_id INTEGER, affected_genus_id INTEGER, revision_summary TEXT, revision_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_family_id) REFERENCES tax_families (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mucorales_taxonomic_revisions_publication_id ON ord_mucorales_taxonomic_revisions (publication_id); CREATE INDEX ix_ord_mucorales_taxonomic_revisions_affected_family_id ON ord_mucorales_taxonomic_revisions (affected_family_id); CREATE TABLE ord_mucorales_conservation_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, national_redlist_category TEXT, habitat_pressure_text TEXT, last_assessment_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mucorales_conservation_status_species_id ON ord_mucorales_conservation_status (species_id); CREATE INDEX ix_ord_mucorales_conservation_status_country_id ON ord_mucorales_conservation_status (country_id); CREATE TABLE ord_mucorales_diagnostic_keys ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER, key_title TEXT NOT NULL, region_country_id INTEGER, n_taxa_covered INTEGER, key_format TEXT, includes_microscopy INTEGER NOT NULL DEFAULT 0, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mucorales_diagnostic_keys_publication_id ON ord_mucorales_diagnostic_keys (publication_id); CREATE INDEX ix_ord_mucorales_diagnostic_keys_region_country_id ON ord_mucorales_diagnostic_keys (region_country_id); CREATE TABLE ord_mucorales_type_species_register ( id INTEGER PRIMARY KEY AUTOINCREMENT, focal_genus_id INTEGER NOT NULL, type_species_id INTEGER, designation_publication_id INTEGER, designation_year INTEGER, designated_by_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (designation_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mucorales_type_species_register_focal_genus_id ON ord_mucorales_type_species_register (focal_genus_id); CREATE INDEX ix_ord_mucorales_type_species_register_type_species_id ON ord_mucorales_type_species_register (type_species_id); CREATE TABLE ord_mucorales_distribution_grids ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, grid_cell_code TEXT NOT NULL, centroid_lat REAL, centroid_lon REAL, record_count INTEGER, first_record_year INTEGER, most_recent_record_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mucorales_distribution_grids_species_id ON ord_mucorales_distribution_grids (species_id); CREATE INDEX ix_ord_mucorales_distribution_grids_country_id ON ord_mucorales_distribution_grids (country_id); CREATE TABLE ord_mucorales_microclimate_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER, publication_id INTEGER, substrate_temperature_c REAL, substrate_moisture_pct REAL, canopy_closure_pct REAL, photosynthetic_par_umol_m2_s REAL, days_post_rainfall INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mucorales_microclimate_studies_species_id ON ord_mucorales_microclimate_studies (species_id); CREATE INDEX ix_ord_mucorales_microclimate_studies_publication_id ON ord_mucorales_microclimate_studies (publication_id); CREATE TABLE ord_mucorales_dna_barcoding_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, its_sequenced INTEGER NOT NULL DEFAULT 0, lsu_sequenced INTEGER NOT NULL DEFAULT 0, rpb2_sequenced INTEGER NOT NULL DEFAULT 0, ef1a_sequenced INTEGER NOT NULL DEFAULT 0, genome_assembled INTEGER NOT NULL DEFAULT 0, priority_for_sequencing_score INTEGER CHECK (priority_for_sequencing_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mucorales_dna_barcoding_status_species_id ON ord_mucorales_dna_barcoding_status (species_id); CREATE TABLE ord_mucorales_spore_print_data ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, specimen_id INTEGER, print_color_label TEXT, print_color_chip_id INTEGER, spore_density_per_mm2 REAL, collection_substrate TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (print_color_chip_id) REFERENCES mor_color_chips (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mucorales_spore_print_data_species_id ON ord_mucorales_spore_print_data (species_id); CREATE INDEX ix_ord_mucorales_spore_print_data_specimen_id ON ord_mucorales_spore_print_data (specimen_id); CREATE TABLE ord_mucorales_mating_systems ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, system_type TEXT, mating_loci_count INTEGER, publication_id INTEGER, notes_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mucorales_mating_systems_species_id ON ord_mucorales_mating_systems (species_id); CREATE INDEX ix_ord_mucorales_mating_systems_publication_id ON ord_mucorales_mating_systems (publication_id); CREATE TABLE ord_mucorales_nutrient_uptake_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, nitrogen_source TEXT, carbon_source TEXT, growth_response TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mucorales_nutrient_uptake_studies_species_id ON ord_mucorales_nutrient_uptake_studies (species_id); CREATE INDEX ix_ord_mucorales_nutrient_uptake_studies_strain_id ON ord_mucorales_nutrient_uptake_studies (strain_id); CREATE TABLE ord_mucorales_range_maps ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, polygon_file_uri TEXT NOT NULL, source_methodology TEXT, area_km2 REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mucorales_range_maps_species_id ON ord_mucorales_range_maps (species_id); CREATE INDEX ix_ord_mucorales_range_maps_publication_id ON ord_mucorales_range_maps (publication_id); CREATE TABLE ord_mucorales_abundance_estimates ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, estimate_kind TEXT, value_min REAL, value_max REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mucorales_abundance_estimates_species_id ON ord_mucorales_abundance_estimates (species_id); CREATE INDEX ix_ord_mucorales_abundance_estimates_country_id ON ord_mucorales_abundance_estimates (country_id); CREATE TABLE ord_mucorales_toxin_profiles ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, presence TEXT, typical_concentration_mg_per_kg REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mucorales_toxin_profiles_species_id ON ord_mucorales_toxin_profiles (species_id); CREATE INDEX ix_ord_mucorales_toxin_profiles_compound_id ON ord_mucorales_toxin_profiles (compound_id); CREATE TABLE ord_mucorales_enzyme_activity_assays ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, enzyme_id INTEGER NOT NULL, strain_id INTEGER, activity_u_per_mg REAL, temperature_c REAL, ph REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (enzyme_id) REFERENCES bio_enzymes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mucorales_enzyme_activity_assays_species_id ON ord_mucorales_enzyme_activity_assays (species_id); CREATE INDEX ix_ord_mucorales_enzyme_activity_assays_enzyme_id ON ord_mucorales_enzyme_activity_assays (enzyme_id); CREATE TABLE ord_mucorales_biocontrol_evaluations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, target_pest_text TEXT NOT NULL, efficacy_pct REAL, trial_setting TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mucorales_biocontrol_evaluations_species_id ON ord_mucorales_biocontrol_evaluations (species_id); CREATE INDEX ix_ord_mucorales_biocontrol_evaluations_publication_id ON ord_mucorales_biocontrol_evaluations (publication_id); CREATE TABLE ord_mucorales_regional_checklists ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, checklist_publication_id INTEGER, status TEXT, checklist_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (checklist_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mucorales_regional_checklists_species_id ON ord_mucorales_regional_checklists (species_id); CREATE INDEX ix_ord_mucorales_regional_checklists_country_id ON ord_mucorales_regional_checklists (country_id); CREATE TABLE ord_endogonales_morphology ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, hymenium_color_at_maturity TEXT, context_color_at_maturity TEXT, characteristic_microstructure TEXT, diagnostic_features_text TEXT, notes_kohler_reaction TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_endogonales_morphology_specimen_id ON ord_endogonales_morphology (specimen_id); CREATE INDEX ix_ord_endogonales_morphology_species_id ON ord_endogonales_morphology (species_id); CREATE TABLE ord_endogonales_ecology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, dominant_habitat_id INTEGER, dominant_substrate_id INTEGER, dominant_biome_id INTEGER, trophic_strategy TEXT, typical_fruiting_period TEXT, known_distribution_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_habitat_id) REFERENCES eco_habitat_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_substrate_id) REFERENCES eco_substrate_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_biome_id) REFERENCES geo_biomes (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_endogonales_ecology_species_id ON ord_endogonales_ecology (species_id); CREATE INDEX ix_ord_endogonales_ecology_dominant_habitat_id ON ord_endogonales_ecology (dominant_habitat_id); CREATE TABLE ord_endogonales_phenology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, season_name TEXT, region_country_id INTEGER, first_doy INTEGER, peak_doy INTEGER, last_doy INTEGER, years_observed INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_endogonales_phenology_species_id ON ord_endogonales_phenology (species_id); CREATE INDEX ix_ord_endogonales_phenology_region_country_id ON ord_endogonales_phenology (region_country_id); CREATE TABLE ord_endogonales_host_associations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, association_type TEXT, specificity TEXT, evidence_publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (evidence_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_endogonales_host_associations_species_id ON ord_endogonales_host_associations (species_id); CREATE INDEX ix_ord_endogonales_host_associations_host_id ON ord_endogonales_host_associations (host_id); CREATE TABLE ord_endogonales_substrate_preferences ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, substrate_id INTEGER NOT NULL, preference_score REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (substrate_id) REFERENCES eco_substrate_types (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_endogonales_substrate_preferences_species_id ON ord_endogonales_substrate_preferences (species_id); CREATE INDEX ix_ord_endogonales_substrate_preferences_substrate_id ON ord_endogonales_substrate_preferences (substrate_id); CREATE TABLE ord_endogonales_geographic_distribution ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, occurrence_status TEXT, first_record_year INTEGER, record_count INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_endogonales_geographic_distribution_species_id ON ord_endogonales_geographic_distribution (species_id); CREATE INDEX ix_ord_endogonales_geographic_distribution_country_id ON ord_endogonales_geographic_distribution (country_id); CREATE TABLE ord_endogonales_phylogeny ( id INTEGER PRIMARY KEY AUTOINCREMENT, tree_id INTEGER NOT NULL, focal_genus_id INTEGER, publication_id INTEGER, notes_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (tree_id) REFERENCES phy_trees (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_endogonales_phylogeny_tree_id ON ord_endogonales_phylogeny (tree_id); CREATE INDEX ix_ord_endogonales_phylogeny_focal_genus_id ON ord_endogonales_phylogeny (focal_genus_id); CREATE TABLE ord_endogonales_genomics ( id INTEGER PRIMARY KEY AUTOINCREMENT, assembly_id INTEGER NOT NULL, species_id INTEGER, avg_genome_size_mb REAL, avg_gene_count INTEGER, avg_busco_complete_pct REAL, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (assembly_id) REFERENCES gen_assemblies (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_endogonales_genomics_assembly_id ON ord_endogonales_genomics (assembly_id); CREATE INDEX ix_ord_endogonales_genomics_species_id ON ord_endogonales_genomics (species_id); CREATE TABLE ord_endogonales_biochemistry ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, typicality TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_endogonales_biochemistry_species_id ON ord_endogonales_biochemistry (species_id); CREATE INDEX ix_ord_endogonales_biochemistry_compound_id ON ord_endogonales_biochemistry (compound_id); CREATE TABLE ord_endogonales_cultivation_notes ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, typical_growth_rate_mm_per_day REAL, preferred_media_type_id INTEGER, optimal_temperature_c REAL, difficulty_score INTEGER CHECK (difficulty_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (preferred_media_type_id) REFERENCES cul_media_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_endogonales_cultivation_notes_species_id ON ord_endogonales_cultivation_notes (species_id); CREATE INDEX ix_ord_endogonales_cultivation_notes_strain_id ON ord_endogonales_cultivation_notes (strain_id); CREATE TABLE ord_endogonales_pathogenicity ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, disease_id INTEGER, severity_score INTEGER CHECK (severity_score BETWEEN 1 AND 5), publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (disease_id) REFERENCES pat_diseases (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_endogonales_pathogenicity_species_id ON ord_endogonales_pathogenicity (species_id); CREATE INDEX ix_ord_endogonales_pathogenicity_host_id ON ord_endogonales_pathogenicity (host_id); CREATE TABLE ord_endogonales_edibility ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, edibility_class TEXT, preparation_notes TEXT, regional_tradition_country_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (regional_tradition_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_endogonales_edibility_species_id ON ord_endogonales_edibility (species_id); CREATE INDEX ix_ord_endogonales_edibility_regional_tradition_country_id ON ord_endogonales_edibility (regional_tradition_country_id); CREATE TABLE ord_endogonales_medicinal_uses ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, traditional_use_text TEXT, modern_evidence_level TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_endogonales_medicinal_uses_species_id ON ord_endogonales_medicinal_uses (species_id); CREATE INDEX ix_ord_endogonales_medicinal_uses_publication_id ON ord_endogonales_medicinal_uses (publication_id); CREATE TABLE ord_endogonales_taxonomic_revisions ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER NOT NULL, affected_family_id INTEGER, affected_genus_id INTEGER, revision_summary TEXT, revision_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_family_id) REFERENCES tax_families (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_endogonales_taxonomic_revisions_publication_id ON ord_endogonales_taxonomic_revisions (publication_id); CREATE INDEX ix_ord_endogonales_taxonomic_revisions_affected_family_id ON ord_endogonales_taxonomic_revisions (affected_family_id); CREATE TABLE ord_endogonales_conservation_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, national_redlist_category TEXT, habitat_pressure_text TEXT, last_assessment_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_endogonales_conservation_status_species_id ON ord_endogonales_conservation_status (species_id); CREATE INDEX ix_ord_endogonales_conservation_status_country_id ON ord_endogonales_conservation_status (country_id); CREATE TABLE ord_endogonales_diagnostic_keys ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER, key_title TEXT NOT NULL, region_country_id INTEGER, n_taxa_covered INTEGER, key_format TEXT, includes_microscopy INTEGER NOT NULL DEFAULT 0, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_endogonales_diagnostic_keys_publication_id ON ord_endogonales_diagnostic_keys (publication_id); CREATE INDEX ix_ord_endogonales_diagnostic_keys_region_country_id ON ord_endogonales_diagnostic_keys (region_country_id); CREATE TABLE ord_endogonales_type_species_register ( id INTEGER PRIMARY KEY AUTOINCREMENT, focal_genus_id INTEGER NOT NULL, type_species_id INTEGER, designation_publication_id INTEGER, designation_year INTEGER, designated_by_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (designation_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_endogonales_type_species_register_focal_genus_id ON ord_endogonales_type_species_register (focal_genus_id); CREATE INDEX ix_ord_endogonales_type_species_register_type_species_id ON ord_endogonales_type_species_register (type_species_id); CREATE TABLE ord_endogonales_distribution_grids ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, grid_cell_code TEXT NOT NULL, centroid_lat REAL, centroid_lon REAL, record_count INTEGER, first_record_year INTEGER, most_recent_record_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_endogonales_distribution_grids_species_id ON ord_endogonales_distribution_grids (species_id); CREATE INDEX ix_ord_endogonales_distribution_grids_country_id ON ord_endogonales_distribution_grids (country_id); CREATE TABLE ord_endogonales_microclimate_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER, publication_id INTEGER, substrate_temperature_c REAL, substrate_moisture_pct REAL, canopy_closure_pct REAL, photosynthetic_par_umol_m2_s REAL, days_post_rainfall INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_endogonales_microclimate_studies_species_id ON ord_endogonales_microclimate_studies (species_id); CREATE INDEX ix_ord_endogonales_microclimate_studies_publication_id ON ord_endogonales_microclimate_studies (publication_id); CREATE TABLE ord_endogonales_dna_barcoding_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, its_sequenced INTEGER NOT NULL DEFAULT 0, lsu_sequenced INTEGER NOT NULL DEFAULT 0, rpb2_sequenced INTEGER NOT NULL DEFAULT 0, ef1a_sequenced INTEGER NOT NULL DEFAULT 0, genome_assembled INTEGER NOT NULL DEFAULT 0, priority_for_sequencing_score INTEGER CHECK (priority_for_sequencing_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_endogonales_dna_barcoding_status_species_id ON ord_endogonales_dna_barcoding_status (species_id); CREATE TABLE ord_endogonales_spore_print_data ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, specimen_id INTEGER, print_color_label TEXT, print_color_chip_id INTEGER, spore_density_per_mm2 REAL, collection_substrate TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (print_color_chip_id) REFERENCES mor_color_chips (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_endogonales_spore_print_data_species_id ON ord_endogonales_spore_print_data (species_id); CREATE INDEX ix_ord_endogonales_spore_print_data_specimen_id ON ord_endogonales_spore_print_data (specimen_id); CREATE TABLE ord_endogonales_mating_systems ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, system_type TEXT, mating_loci_count INTEGER, publication_id INTEGER, notes_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_endogonales_mating_systems_species_id ON ord_endogonales_mating_systems (species_id); CREATE INDEX ix_ord_endogonales_mating_systems_publication_id ON ord_endogonales_mating_systems (publication_id); CREATE TABLE ord_endogonales_nutrient_uptake_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, nitrogen_source TEXT, carbon_source TEXT, growth_response TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_endogonales_nutrient_uptake_studies_species_id ON ord_endogonales_nutrient_uptake_studies (species_id); CREATE INDEX ix_ord_endogonales_nutrient_uptake_studies_strain_id ON ord_endogonales_nutrient_uptake_studies (strain_id); CREATE TABLE ord_endogonales_range_maps ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, polygon_file_uri TEXT NOT NULL, source_methodology TEXT, area_km2 REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_endogonales_range_maps_species_id ON ord_endogonales_range_maps (species_id); CREATE INDEX ix_ord_endogonales_range_maps_publication_id ON ord_endogonales_range_maps (publication_id); CREATE TABLE ord_endogonales_abundance_estimates ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, estimate_kind TEXT, value_min REAL, value_max REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_endogonales_abundance_estimates_species_id ON ord_endogonales_abundance_estimates (species_id); CREATE INDEX ix_ord_endogonales_abundance_estimates_country_id ON ord_endogonales_abundance_estimates (country_id); CREATE TABLE ord_endogonales_toxin_profiles ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, presence TEXT, typical_concentration_mg_per_kg REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_endogonales_toxin_profiles_species_id ON ord_endogonales_toxin_profiles (species_id); CREATE INDEX ix_ord_endogonales_toxin_profiles_compound_id ON ord_endogonales_toxin_profiles (compound_id); CREATE TABLE ord_endogonales_enzyme_activity_assays ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, enzyme_id INTEGER NOT NULL, strain_id INTEGER, activity_u_per_mg REAL, temperature_c REAL, ph REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (enzyme_id) REFERENCES bio_enzymes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_endogonales_enzyme_activity_assays_species_id ON ord_endogonales_enzyme_activity_assays (species_id); CREATE INDEX ix_ord_endogonales_enzyme_activity_assays_enzyme_id ON ord_endogonales_enzyme_activity_assays (enzyme_id); CREATE TABLE ord_endogonales_biocontrol_evaluations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, target_pest_text TEXT NOT NULL, efficacy_pct REAL, trial_setting TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_endogonales_biocontrol_evaluations_species_id ON ord_endogonales_biocontrol_evaluations (species_id); CREATE INDEX ix_ord_endogonales_biocontrol_evaluations_publication_id ON ord_endogonales_biocontrol_evaluations (publication_id); CREATE TABLE ord_endogonales_regional_checklists ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, checklist_publication_id INTEGER, status TEXT, checklist_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (checklist_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_endogonales_regional_checklists_species_id ON ord_endogonales_regional_checklists (species_id); CREATE INDEX ix_ord_endogonales_regional_checklists_country_id ON ord_endogonales_regional_checklists (country_id); CREATE TABLE ord_kickxellales_morphology ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, hymenium_color_at_maturity TEXT, context_color_at_maturity TEXT, characteristic_microstructure TEXT, diagnostic_features_text TEXT, notes_kohler_reaction TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_kickxellales_morphology_specimen_id ON ord_kickxellales_morphology (specimen_id); CREATE INDEX ix_ord_kickxellales_morphology_species_id ON ord_kickxellales_morphology (species_id); CREATE TABLE ord_kickxellales_ecology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, dominant_habitat_id INTEGER, dominant_substrate_id INTEGER, dominant_biome_id INTEGER, trophic_strategy TEXT, typical_fruiting_period TEXT, known_distribution_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_habitat_id) REFERENCES eco_habitat_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_substrate_id) REFERENCES eco_substrate_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_biome_id) REFERENCES geo_biomes (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_kickxellales_ecology_species_id ON ord_kickxellales_ecology (species_id); CREATE INDEX ix_ord_kickxellales_ecology_dominant_habitat_id ON ord_kickxellales_ecology (dominant_habitat_id); CREATE TABLE ord_kickxellales_phenology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, season_name TEXT, region_country_id INTEGER, first_doy INTEGER, peak_doy INTEGER, last_doy INTEGER, years_observed INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_kickxellales_phenology_species_id ON ord_kickxellales_phenology (species_id); CREATE INDEX ix_ord_kickxellales_phenology_region_country_id ON ord_kickxellales_phenology (region_country_id); CREATE TABLE ord_kickxellales_host_associations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, association_type TEXT, specificity TEXT, evidence_publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (evidence_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_kickxellales_host_associations_species_id ON ord_kickxellales_host_associations (species_id); CREATE INDEX ix_ord_kickxellales_host_associations_host_id ON ord_kickxellales_host_associations (host_id); CREATE TABLE ord_kickxellales_substrate_preferences ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, substrate_id INTEGER NOT NULL, preference_score REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (substrate_id) REFERENCES eco_substrate_types (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_kickxellales_substrate_preferences_species_id ON ord_kickxellales_substrate_preferences (species_id); CREATE INDEX ix_ord_kickxellales_substrate_preferences_substrate_id ON ord_kickxellales_substrate_preferences (substrate_id); CREATE TABLE ord_kickxellales_geographic_distribution ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, occurrence_status TEXT, first_record_year INTEGER, record_count INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_kickxellales_geographic_distribution_species_id ON ord_kickxellales_geographic_distribution (species_id); CREATE INDEX ix_ord_kickxellales_geographic_distribution_country_id ON ord_kickxellales_geographic_distribution (country_id); CREATE TABLE ord_kickxellales_phylogeny ( id INTEGER PRIMARY KEY AUTOINCREMENT, tree_id INTEGER NOT NULL, focal_genus_id INTEGER, publication_id INTEGER, notes_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (tree_id) REFERENCES phy_trees (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_kickxellales_phylogeny_tree_id ON ord_kickxellales_phylogeny (tree_id); CREATE INDEX ix_ord_kickxellales_phylogeny_focal_genus_id ON ord_kickxellales_phylogeny (focal_genus_id); CREATE TABLE ord_kickxellales_genomics ( id INTEGER PRIMARY KEY AUTOINCREMENT, assembly_id INTEGER NOT NULL, species_id INTEGER, avg_genome_size_mb REAL, avg_gene_count INTEGER, avg_busco_complete_pct REAL, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (assembly_id) REFERENCES gen_assemblies (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_kickxellales_genomics_assembly_id ON ord_kickxellales_genomics (assembly_id); CREATE INDEX ix_ord_kickxellales_genomics_species_id ON ord_kickxellales_genomics (species_id); CREATE TABLE ord_kickxellales_biochemistry ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, typicality TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_kickxellales_biochemistry_species_id ON ord_kickxellales_biochemistry (species_id); CREATE INDEX ix_ord_kickxellales_biochemistry_compound_id ON ord_kickxellales_biochemistry (compound_id); CREATE TABLE ord_kickxellales_cultivation_notes ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, typical_growth_rate_mm_per_day REAL, preferred_media_type_id INTEGER, optimal_temperature_c REAL, difficulty_score INTEGER CHECK (difficulty_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (preferred_media_type_id) REFERENCES cul_media_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_kickxellales_cultivation_notes_species_id ON ord_kickxellales_cultivation_notes (species_id); CREATE INDEX ix_ord_kickxellales_cultivation_notes_strain_id ON ord_kickxellales_cultivation_notes (strain_id); CREATE TABLE ord_kickxellales_pathogenicity ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, disease_id INTEGER, severity_score INTEGER CHECK (severity_score BETWEEN 1 AND 5), publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (disease_id) REFERENCES pat_diseases (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_kickxellales_pathogenicity_species_id ON ord_kickxellales_pathogenicity (species_id); CREATE INDEX ix_ord_kickxellales_pathogenicity_host_id ON ord_kickxellales_pathogenicity (host_id); CREATE TABLE ord_kickxellales_edibility ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, edibility_class TEXT, preparation_notes TEXT, regional_tradition_country_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (regional_tradition_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_kickxellales_edibility_species_id ON ord_kickxellales_edibility (species_id); CREATE INDEX ix_ord_kickxellales_edibility_regional_tradition_country_id ON ord_kickxellales_edibility (regional_tradition_country_id); CREATE TABLE ord_kickxellales_medicinal_uses ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, traditional_use_text TEXT, modern_evidence_level TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_kickxellales_medicinal_uses_species_id ON ord_kickxellales_medicinal_uses (species_id); CREATE INDEX ix_ord_kickxellales_medicinal_uses_publication_id ON ord_kickxellales_medicinal_uses (publication_id); CREATE TABLE ord_kickxellales_taxonomic_revisions ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER NOT NULL, affected_family_id INTEGER, affected_genus_id INTEGER, revision_summary TEXT, revision_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_family_id) REFERENCES tax_families (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_kickxellales_taxonomic_revisions_publication_id ON ord_kickxellales_taxonomic_revisions (publication_id); CREATE INDEX ix_ord_kickxellales_taxonomic_revisions_affected_family_id ON ord_kickxellales_taxonomic_revisions (affected_family_id); CREATE TABLE ord_kickxellales_conservation_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, national_redlist_category TEXT, habitat_pressure_text TEXT, last_assessment_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_kickxellales_conservation_status_species_id ON ord_kickxellales_conservation_status (species_id); CREATE INDEX ix_ord_kickxellales_conservation_status_country_id ON ord_kickxellales_conservation_status (country_id); CREATE TABLE ord_kickxellales_diagnostic_keys ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER, key_title TEXT NOT NULL, region_country_id INTEGER, n_taxa_covered INTEGER, key_format TEXT, includes_microscopy INTEGER NOT NULL DEFAULT 0, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_kickxellales_diagnostic_keys_publication_id ON ord_kickxellales_diagnostic_keys (publication_id); CREATE INDEX ix_ord_kickxellales_diagnostic_keys_region_country_id ON ord_kickxellales_diagnostic_keys (region_country_id); CREATE TABLE ord_kickxellales_type_species_register ( id INTEGER PRIMARY KEY AUTOINCREMENT, focal_genus_id INTEGER NOT NULL, type_species_id INTEGER, designation_publication_id INTEGER, designation_year INTEGER, designated_by_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (designation_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_kickxellales_type_species_register_focal_genus_id ON ord_kickxellales_type_species_register (focal_genus_id); CREATE INDEX ix_ord_kickxellales_type_species_register_type_species_id ON ord_kickxellales_type_species_register (type_species_id); CREATE TABLE ord_kickxellales_distribution_grids ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, grid_cell_code TEXT NOT NULL, centroid_lat REAL, centroid_lon REAL, record_count INTEGER, first_record_year INTEGER, most_recent_record_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_kickxellales_distribution_grids_species_id ON ord_kickxellales_distribution_grids (species_id); CREATE INDEX ix_ord_kickxellales_distribution_grids_country_id ON ord_kickxellales_distribution_grids (country_id); CREATE TABLE ord_kickxellales_microclimate_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER, publication_id INTEGER, substrate_temperature_c REAL, substrate_moisture_pct REAL, canopy_closure_pct REAL, photosynthetic_par_umol_m2_s REAL, days_post_rainfall INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_kickxellales_microclimate_studies_species_id ON ord_kickxellales_microclimate_studies (species_id); CREATE INDEX ix_ord_kickxellales_microclimate_studies_publication_id ON ord_kickxellales_microclimate_studies (publication_id); CREATE TABLE ord_kickxellales_dna_barcoding_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, its_sequenced INTEGER NOT NULL DEFAULT 0, lsu_sequenced INTEGER NOT NULL DEFAULT 0, rpb2_sequenced INTEGER NOT NULL DEFAULT 0, ef1a_sequenced INTEGER NOT NULL DEFAULT 0, genome_assembled INTEGER NOT NULL DEFAULT 0, priority_for_sequencing_score INTEGER CHECK (priority_for_sequencing_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_kickxellales_dna_barcoding_status_species_id ON ord_kickxellales_dna_barcoding_status (species_id); CREATE TABLE ord_kickxellales_spore_print_data ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, specimen_id INTEGER, print_color_label TEXT, print_color_chip_id INTEGER, spore_density_per_mm2 REAL, collection_substrate TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (print_color_chip_id) REFERENCES mor_color_chips (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_kickxellales_spore_print_data_species_id ON ord_kickxellales_spore_print_data (species_id); CREATE INDEX ix_ord_kickxellales_spore_print_data_specimen_id ON ord_kickxellales_spore_print_data (specimen_id); CREATE TABLE ord_kickxellales_mating_systems ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, system_type TEXT, mating_loci_count INTEGER, publication_id INTEGER, notes_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_kickxellales_mating_systems_species_id ON ord_kickxellales_mating_systems (species_id); CREATE INDEX ix_ord_kickxellales_mating_systems_publication_id ON ord_kickxellales_mating_systems (publication_id); CREATE TABLE ord_kickxellales_nutrient_uptake_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, nitrogen_source TEXT, carbon_source TEXT, growth_response TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_kickxellales_nutrient_uptake_studies_species_id ON ord_kickxellales_nutrient_uptake_studies (species_id); CREATE INDEX ix_ord_kickxellales_nutrient_uptake_studies_strain_id ON ord_kickxellales_nutrient_uptake_studies (strain_id); CREATE TABLE ord_kickxellales_range_maps ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, polygon_file_uri TEXT NOT NULL, source_methodology TEXT, area_km2 REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_kickxellales_range_maps_species_id ON ord_kickxellales_range_maps (species_id); CREATE INDEX ix_ord_kickxellales_range_maps_publication_id ON ord_kickxellales_range_maps (publication_id); CREATE TABLE ord_kickxellales_abundance_estimates ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, estimate_kind TEXT, value_min REAL, value_max REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_kickxellales_abundance_estimates_species_id ON ord_kickxellales_abundance_estimates (species_id); CREATE INDEX ix_ord_kickxellales_abundance_estimates_country_id ON ord_kickxellales_abundance_estimates (country_id); CREATE TABLE ord_kickxellales_toxin_profiles ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, presence TEXT, typical_concentration_mg_per_kg REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_kickxellales_toxin_profiles_species_id ON ord_kickxellales_toxin_profiles (species_id); CREATE INDEX ix_ord_kickxellales_toxin_profiles_compound_id ON ord_kickxellales_toxin_profiles (compound_id); CREATE TABLE ord_kickxellales_enzyme_activity_assays ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, enzyme_id INTEGER NOT NULL, strain_id INTEGER, activity_u_per_mg REAL, temperature_c REAL, ph REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (enzyme_id) REFERENCES bio_enzymes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_kickxellales_enzyme_activity_assays_species_id ON ord_kickxellales_enzyme_activity_assays (species_id); CREATE INDEX ix_ord_kickxellales_enzyme_activity_assays_enzyme_id ON ord_kickxellales_enzyme_activity_assays (enzyme_id); CREATE TABLE ord_kickxellales_biocontrol_evaluations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, target_pest_text TEXT NOT NULL, efficacy_pct REAL, trial_setting TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_kickxellales_biocontrol_evaluations_species_id ON ord_kickxellales_biocontrol_evaluations (species_id); CREATE INDEX ix_ord_kickxellales_biocontrol_evaluations_publication_id ON ord_kickxellales_biocontrol_evaluations (publication_id); CREATE TABLE ord_kickxellales_regional_checklists ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, checklist_publication_id INTEGER, status TEXT, checklist_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (checklist_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_kickxellales_regional_checklists_species_id ON ord_kickxellales_regional_checklists (species_id); CREATE INDEX ix_ord_kickxellales_regional_checklists_country_id ON ord_kickxellales_regional_checklists (country_id); CREATE TABLE ord_mortierellales_morphology ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, hymenium_color_at_maturity TEXT, context_color_at_maturity TEXT, characteristic_microstructure TEXT, diagnostic_features_text TEXT, notes_kohler_reaction TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mortierellales_morphology_specimen_id ON ord_mortierellales_morphology (specimen_id); CREATE INDEX ix_ord_mortierellales_morphology_species_id ON ord_mortierellales_morphology (species_id); CREATE TABLE ord_mortierellales_ecology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, dominant_habitat_id INTEGER, dominant_substrate_id INTEGER, dominant_biome_id INTEGER, trophic_strategy TEXT, typical_fruiting_period TEXT, known_distribution_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_habitat_id) REFERENCES eco_habitat_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_substrate_id) REFERENCES eco_substrate_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_biome_id) REFERENCES geo_biomes (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mortierellales_ecology_species_id ON ord_mortierellales_ecology (species_id); CREATE INDEX ix_ord_mortierellales_ecology_dominant_habitat_id ON ord_mortierellales_ecology (dominant_habitat_id); CREATE TABLE ord_mortierellales_phenology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, season_name TEXT, region_country_id INTEGER, first_doy INTEGER, peak_doy INTEGER, last_doy INTEGER, years_observed INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mortierellales_phenology_species_id ON ord_mortierellales_phenology (species_id); CREATE INDEX ix_ord_mortierellales_phenology_region_country_id ON ord_mortierellales_phenology (region_country_id); CREATE TABLE ord_mortierellales_host_associations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, association_type TEXT, specificity TEXT, evidence_publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (evidence_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mortierellales_host_associations_species_id ON ord_mortierellales_host_associations (species_id); CREATE INDEX ix_ord_mortierellales_host_associations_host_id ON ord_mortierellales_host_associations (host_id); CREATE TABLE ord_mortierellales_substrate_preferences ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, substrate_id INTEGER NOT NULL, preference_score REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (substrate_id) REFERENCES eco_substrate_types (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mortierellales_substrate_preferences_species_id ON ord_mortierellales_substrate_preferences (species_id); CREATE INDEX ix_ord_mortierellales_substrate_preferences_substrate_id ON ord_mortierellales_substrate_preferences (substrate_id); CREATE TABLE ord_mortierellales_geographic_distribution ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, occurrence_status TEXT, first_record_year INTEGER, record_count INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mortierellales_geographic_distribution_species_id ON ord_mortierellales_geographic_distribution (species_id); CREATE INDEX ix_ord_mortierellales_geographic_distribution_country_id ON ord_mortierellales_geographic_distribution (country_id); CREATE TABLE ord_mortierellales_phylogeny ( id INTEGER PRIMARY KEY AUTOINCREMENT, tree_id INTEGER NOT NULL, focal_genus_id INTEGER, publication_id INTEGER, notes_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (tree_id) REFERENCES phy_trees (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mortierellales_phylogeny_tree_id ON ord_mortierellales_phylogeny (tree_id); CREATE INDEX ix_ord_mortierellales_phylogeny_focal_genus_id ON ord_mortierellales_phylogeny (focal_genus_id); CREATE TABLE ord_mortierellales_genomics ( id INTEGER PRIMARY KEY AUTOINCREMENT, assembly_id INTEGER NOT NULL, species_id INTEGER, avg_genome_size_mb REAL, avg_gene_count INTEGER, avg_busco_complete_pct REAL, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (assembly_id) REFERENCES gen_assemblies (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mortierellales_genomics_assembly_id ON ord_mortierellales_genomics (assembly_id); CREATE INDEX ix_ord_mortierellales_genomics_species_id ON ord_mortierellales_genomics (species_id); CREATE TABLE ord_mortierellales_biochemistry ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, typicality TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mortierellales_biochemistry_species_id ON ord_mortierellales_biochemistry (species_id); CREATE INDEX ix_ord_mortierellales_biochemistry_compound_id ON ord_mortierellales_biochemistry (compound_id); CREATE TABLE ord_mortierellales_cultivation_notes ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, typical_growth_rate_mm_per_day REAL, preferred_media_type_id INTEGER, optimal_temperature_c REAL, difficulty_score INTEGER CHECK (difficulty_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (preferred_media_type_id) REFERENCES cul_media_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mortierellales_cultivation_notes_species_id ON ord_mortierellales_cultivation_notes (species_id); CREATE INDEX ix_ord_mortierellales_cultivation_notes_strain_id ON ord_mortierellales_cultivation_notes (strain_id); CREATE TABLE ord_mortierellales_pathogenicity ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, disease_id INTEGER, severity_score INTEGER CHECK (severity_score BETWEEN 1 AND 5), publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (disease_id) REFERENCES pat_diseases (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mortierellales_pathogenicity_species_id ON ord_mortierellales_pathogenicity (species_id); CREATE INDEX ix_ord_mortierellales_pathogenicity_host_id ON ord_mortierellales_pathogenicity (host_id); CREATE TABLE ord_mortierellales_edibility ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, edibility_class TEXT, preparation_notes TEXT, regional_tradition_country_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (regional_tradition_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mortierellales_edibility_species_id ON ord_mortierellales_edibility (species_id); CREATE INDEX ix_ord_mortierellales_edibility_1 ON ord_mortierellales_edibility (regional_tradition_country_id); CREATE TABLE ord_mortierellales_medicinal_uses ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, traditional_use_text TEXT, modern_evidence_level TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mortierellales_medicinal_uses_species_id ON ord_mortierellales_medicinal_uses (species_id); CREATE INDEX ix_ord_mortierellales_medicinal_uses_publication_id ON ord_mortierellales_medicinal_uses (publication_id); CREATE TABLE ord_mortierellales_taxonomic_revisions ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER NOT NULL, affected_family_id INTEGER, affected_genus_id INTEGER, revision_summary TEXT, revision_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_family_id) REFERENCES tax_families (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mortierellales_taxonomic_revisions_publication_id ON ord_mortierellales_taxonomic_revisions (publication_id); CREATE INDEX ix_ord_mortierellales_taxonomic_revisions_affected_family_id ON ord_mortierellales_taxonomic_revisions (affected_family_id); CREATE TABLE ord_mortierellales_conservation_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, national_redlist_category TEXT, habitat_pressure_text TEXT, last_assessment_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mortierellales_conservation_status_species_id ON ord_mortierellales_conservation_status (species_id); CREATE INDEX ix_ord_mortierellales_conservation_status_country_id ON ord_mortierellales_conservation_status (country_id); CREATE TABLE ord_mortierellales_diagnostic_keys ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER, key_title TEXT NOT NULL, region_country_id INTEGER, n_taxa_covered INTEGER, key_format TEXT, includes_microscopy INTEGER NOT NULL DEFAULT 0, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mortierellales_diagnostic_keys_publication_id ON ord_mortierellales_diagnostic_keys (publication_id); CREATE INDEX ix_ord_mortierellales_diagnostic_keys_region_country_id ON ord_mortierellales_diagnostic_keys (region_country_id); CREATE TABLE ord_mortierellales_type_species_register ( id INTEGER PRIMARY KEY AUTOINCREMENT, focal_genus_id INTEGER NOT NULL, type_species_id INTEGER, designation_publication_id INTEGER, designation_year INTEGER, designated_by_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (designation_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mortierellales_type_species_register_focal_genus_id ON ord_mortierellales_type_species_register (focal_genus_id); CREATE INDEX ix_ord_mortierellales_type_species_register_type_species_id ON ord_mortierellales_type_species_register (type_species_id); CREATE TABLE ord_mortierellales_distribution_grids ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, grid_cell_code TEXT NOT NULL, centroid_lat REAL, centroid_lon REAL, record_count INTEGER, first_record_year INTEGER, most_recent_record_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mortierellales_distribution_grids_species_id ON ord_mortierellales_distribution_grids (species_id); CREATE INDEX ix_ord_mortierellales_distribution_grids_country_id ON ord_mortierellales_distribution_grids (country_id); CREATE TABLE ord_mortierellales_microclimate_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER, publication_id INTEGER, substrate_temperature_c REAL, substrate_moisture_pct REAL, canopy_closure_pct REAL, photosynthetic_par_umol_m2_s REAL, days_post_rainfall INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mortierellales_microclimate_studies_species_id ON ord_mortierellales_microclimate_studies (species_id); CREATE INDEX ix_ord_mortierellales_microclimate_studies_publication_id ON ord_mortierellales_microclimate_studies (publication_id); CREATE TABLE ord_mortierellales_dna_barcoding_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, its_sequenced INTEGER NOT NULL DEFAULT 0, lsu_sequenced INTEGER NOT NULL DEFAULT 0, rpb2_sequenced INTEGER NOT NULL DEFAULT 0, ef1a_sequenced INTEGER NOT NULL DEFAULT 0, genome_assembled INTEGER NOT NULL DEFAULT 0, priority_for_sequencing_score INTEGER CHECK (priority_for_sequencing_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mortierellales_dna_barcoding_status_species_id ON ord_mortierellales_dna_barcoding_status (species_id); CREATE TABLE ord_mortierellales_spore_print_data ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, specimen_id INTEGER, print_color_label TEXT, print_color_chip_id INTEGER, spore_density_per_mm2 REAL, collection_substrate TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (print_color_chip_id) REFERENCES mor_color_chips (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mortierellales_spore_print_data_species_id ON ord_mortierellales_spore_print_data (species_id); CREATE INDEX ix_ord_mortierellales_spore_print_data_specimen_id ON ord_mortierellales_spore_print_data (specimen_id); CREATE TABLE ord_mortierellales_mating_systems ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, system_type TEXT, mating_loci_count INTEGER, publication_id INTEGER, notes_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mortierellales_mating_systems_species_id ON ord_mortierellales_mating_systems (species_id); CREATE INDEX ix_ord_mortierellales_mating_systems_publication_id ON ord_mortierellales_mating_systems (publication_id); CREATE TABLE ord_mortierellales_nutrient_uptake_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, nitrogen_source TEXT, carbon_source TEXT, growth_response TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mortierellales_nutrient_uptake_studies_species_id ON ord_mortierellales_nutrient_uptake_studies (species_id); CREATE INDEX ix_ord_mortierellales_nutrient_uptake_studies_strain_id ON ord_mortierellales_nutrient_uptake_studies (strain_id); CREATE TABLE ord_mortierellales_range_maps ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, polygon_file_uri TEXT NOT NULL, source_methodology TEXT, area_km2 REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mortierellales_range_maps_species_id ON ord_mortierellales_range_maps (species_id); CREATE INDEX ix_ord_mortierellales_range_maps_publication_id ON ord_mortierellales_range_maps (publication_id); CREATE TABLE ord_mortierellales_abundance_estimates ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, estimate_kind TEXT, value_min REAL, value_max REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mortierellales_abundance_estimates_species_id ON ord_mortierellales_abundance_estimates (species_id); CREATE INDEX ix_ord_mortierellales_abundance_estimates_country_id ON ord_mortierellales_abundance_estimates (country_id); CREATE TABLE ord_mortierellales_toxin_profiles ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, presence TEXT, typical_concentration_mg_per_kg REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mortierellales_toxin_profiles_species_id ON ord_mortierellales_toxin_profiles (species_id); CREATE INDEX ix_ord_mortierellales_toxin_profiles_compound_id ON ord_mortierellales_toxin_profiles (compound_id); CREATE TABLE ord_mortierellales_enzyme_activity_assays ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, enzyme_id INTEGER NOT NULL, strain_id INTEGER, activity_u_per_mg REAL, temperature_c REAL, ph REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (enzyme_id) REFERENCES bio_enzymes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mortierellales_enzyme_activity_assays_species_id ON ord_mortierellales_enzyme_activity_assays (species_id); CREATE INDEX ix_ord_mortierellales_enzyme_activity_assays_enzyme_id ON ord_mortierellales_enzyme_activity_assays (enzyme_id); CREATE TABLE ord_mortierellales_biocontrol_evaluations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, target_pest_text TEXT NOT NULL, efficacy_pct REAL, trial_setting TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mortierellales_biocontrol_evaluations_species_id ON ord_mortierellales_biocontrol_evaluations (species_id); CREATE INDEX ix_ord_mortierellales_biocontrol_evaluations_publication_id ON ord_mortierellales_biocontrol_evaluations (publication_id); CREATE TABLE ord_mortierellales_regional_checklists ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, checklist_publication_id INTEGER, status TEXT, checklist_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (checklist_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_mortierellales_regional_checklists_species_id ON ord_mortierellales_regional_checklists (species_id); CREATE INDEX ix_ord_mortierellales_regional_checklists_country_id ON ord_mortierellales_regional_checklists (country_id); CREATE TABLE ord_glomerales_morphology ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, hymenium_color_at_maturity TEXT, context_color_at_maturity TEXT, characteristic_microstructure TEXT, diagnostic_features_text TEXT, notes_kohler_reaction TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_glomerales_morphology_specimen_id ON ord_glomerales_morphology (specimen_id); CREATE INDEX ix_ord_glomerales_morphology_species_id ON ord_glomerales_morphology (species_id); CREATE TABLE ord_glomerales_ecology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, dominant_habitat_id INTEGER, dominant_substrate_id INTEGER, dominant_biome_id INTEGER, trophic_strategy TEXT, typical_fruiting_period TEXT, known_distribution_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_habitat_id) REFERENCES eco_habitat_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_substrate_id) REFERENCES eco_substrate_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_biome_id) REFERENCES geo_biomes (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_glomerales_ecology_species_id ON ord_glomerales_ecology (species_id); CREATE INDEX ix_ord_glomerales_ecology_dominant_habitat_id ON ord_glomerales_ecology (dominant_habitat_id); CREATE TABLE ord_glomerales_phenology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, season_name TEXT, region_country_id INTEGER, first_doy INTEGER, peak_doy INTEGER, last_doy INTEGER, years_observed INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_glomerales_phenology_species_id ON ord_glomerales_phenology (species_id); CREATE INDEX ix_ord_glomerales_phenology_region_country_id ON ord_glomerales_phenology (region_country_id); CREATE TABLE ord_glomerales_host_associations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, association_type TEXT, specificity TEXT, evidence_publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (evidence_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_glomerales_host_associations_species_id ON ord_glomerales_host_associations (species_id); CREATE INDEX ix_ord_glomerales_host_associations_host_id ON ord_glomerales_host_associations (host_id); CREATE TABLE ord_glomerales_substrate_preferences ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, substrate_id INTEGER NOT NULL, preference_score REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (substrate_id) REFERENCES eco_substrate_types (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_glomerales_substrate_preferences_species_id ON ord_glomerales_substrate_preferences (species_id); CREATE INDEX ix_ord_glomerales_substrate_preferences_substrate_id ON ord_glomerales_substrate_preferences (substrate_id); CREATE TABLE ord_glomerales_geographic_distribution ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, occurrence_status TEXT, first_record_year INTEGER, record_count INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_glomerales_geographic_distribution_species_id ON ord_glomerales_geographic_distribution (species_id); CREATE INDEX ix_ord_glomerales_geographic_distribution_country_id ON ord_glomerales_geographic_distribution (country_id); CREATE TABLE ord_glomerales_phylogeny ( id INTEGER PRIMARY KEY AUTOINCREMENT, tree_id INTEGER NOT NULL, focal_genus_id INTEGER, publication_id INTEGER, notes_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (tree_id) REFERENCES phy_trees (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_glomerales_phylogeny_tree_id ON ord_glomerales_phylogeny (tree_id); CREATE INDEX ix_ord_glomerales_phylogeny_focal_genus_id ON ord_glomerales_phylogeny (focal_genus_id); CREATE TABLE ord_glomerales_genomics ( id INTEGER PRIMARY KEY AUTOINCREMENT, assembly_id INTEGER NOT NULL, species_id INTEGER, avg_genome_size_mb REAL, avg_gene_count INTEGER, avg_busco_complete_pct REAL, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (assembly_id) REFERENCES gen_assemblies (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_glomerales_genomics_assembly_id ON ord_glomerales_genomics (assembly_id); CREATE INDEX ix_ord_glomerales_genomics_species_id ON ord_glomerales_genomics (species_id); CREATE TABLE ord_glomerales_biochemistry ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, typicality TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_glomerales_biochemistry_species_id ON ord_glomerales_biochemistry (species_id); CREATE INDEX ix_ord_glomerales_biochemistry_compound_id ON ord_glomerales_biochemistry (compound_id); CREATE TABLE ord_glomerales_cultivation_notes ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, typical_growth_rate_mm_per_day REAL, preferred_media_type_id INTEGER, optimal_temperature_c REAL, difficulty_score INTEGER CHECK (difficulty_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (preferred_media_type_id) REFERENCES cul_media_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_glomerales_cultivation_notes_species_id ON ord_glomerales_cultivation_notes (species_id); CREATE INDEX ix_ord_glomerales_cultivation_notes_strain_id ON ord_glomerales_cultivation_notes (strain_id); CREATE TABLE ord_glomerales_pathogenicity ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, disease_id INTEGER, severity_score INTEGER CHECK (severity_score BETWEEN 1 AND 5), publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (disease_id) REFERENCES pat_diseases (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_glomerales_pathogenicity_species_id ON ord_glomerales_pathogenicity (species_id); CREATE INDEX ix_ord_glomerales_pathogenicity_host_id ON ord_glomerales_pathogenicity (host_id); CREATE TABLE ord_glomerales_edibility ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, edibility_class TEXT, preparation_notes TEXT, regional_tradition_country_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (regional_tradition_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_glomerales_edibility_species_id ON ord_glomerales_edibility (species_id); CREATE INDEX ix_ord_glomerales_edibility_regional_tradition_country_id ON ord_glomerales_edibility (regional_tradition_country_id); CREATE TABLE ord_glomerales_medicinal_uses ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, traditional_use_text TEXT, modern_evidence_level TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_glomerales_medicinal_uses_species_id ON ord_glomerales_medicinal_uses (species_id); CREATE INDEX ix_ord_glomerales_medicinal_uses_publication_id ON ord_glomerales_medicinal_uses (publication_id); CREATE TABLE ord_glomerales_taxonomic_revisions ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER NOT NULL, affected_family_id INTEGER, affected_genus_id INTEGER, revision_summary TEXT, revision_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_family_id) REFERENCES tax_families (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_glomerales_taxonomic_revisions_publication_id ON ord_glomerales_taxonomic_revisions (publication_id); CREATE INDEX ix_ord_glomerales_taxonomic_revisions_affected_family_id ON ord_glomerales_taxonomic_revisions (affected_family_id); CREATE TABLE ord_glomerales_conservation_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, national_redlist_category TEXT, habitat_pressure_text TEXT, last_assessment_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_glomerales_conservation_status_species_id ON ord_glomerales_conservation_status (species_id); CREATE INDEX ix_ord_glomerales_conservation_status_country_id ON ord_glomerales_conservation_status (country_id); CREATE TABLE ord_glomerales_diagnostic_keys ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER, key_title TEXT NOT NULL, region_country_id INTEGER, n_taxa_covered INTEGER, key_format TEXT, includes_microscopy INTEGER NOT NULL DEFAULT 0, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_glomerales_diagnostic_keys_publication_id ON ord_glomerales_diagnostic_keys (publication_id); CREATE INDEX ix_ord_glomerales_diagnostic_keys_region_country_id ON ord_glomerales_diagnostic_keys (region_country_id); CREATE TABLE ord_glomerales_type_species_register ( id INTEGER PRIMARY KEY AUTOINCREMENT, focal_genus_id INTEGER NOT NULL, type_species_id INTEGER, designation_publication_id INTEGER, designation_year INTEGER, designated_by_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (designation_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_glomerales_type_species_register_focal_genus_id ON ord_glomerales_type_species_register (focal_genus_id); CREATE INDEX ix_ord_glomerales_type_species_register_type_species_id ON ord_glomerales_type_species_register (type_species_id); CREATE TABLE ord_glomerales_distribution_grids ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, grid_cell_code TEXT NOT NULL, centroid_lat REAL, centroid_lon REAL, record_count INTEGER, first_record_year INTEGER, most_recent_record_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_glomerales_distribution_grids_species_id ON ord_glomerales_distribution_grids (species_id); CREATE INDEX ix_ord_glomerales_distribution_grids_country_id ON ord_glomerales_distribution_grids (country_id); CREATE TABLE ord_glomerales_microclimate_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER, publication_id INTEGER, substrate_temperature_c REAL, substrate_moisture_pct REAL, canopy_closure_pct REAL, photosynthetic_par_umol_m2_s REAL, days_post_rainfall INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_glomerales_microclimate_studies_species_id ON ord_glomerales_microclimate_studies (species_id); CREATE INDEX ix_ord_glomerales_microclimate_studies_publication_id ON ord_glomerales_microclimate_studies (publication_id); CREATE TABLE ord_glomerales_dna_barcoding_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, its_sequenced INTEGER NOT NULL DEFAULT 0, lsu_sequenced INTEGER NOT NULL DEFAULT 0, rpb2_sequenced INTEGER NOT NULL DEFAULT 0, ef1a_sequenced INTEGER NOT NULL DEFAULT 0, genome_assembled INTEGER NOT NULL DEFAULT 0, priority_for_sequencing_score INTEGER CHECK (priority_for_sequencing_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_glomerales_dna_barcoding_status_species_id ON ord_glomerales_dna_barcoding_status (species_id); CREATE TABLE ord_glomerales_spore_print_data ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, specimen_id INTEGER, print_color_label TEXT, print_color_chip_id INTEGER, spore_density_per_mm2 REAL, collection_substrate TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (print_color_chip_id) REFERENCES mor_color_chips (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_glomerales_spore_print_data_species_id ON ord_glomerales_spore_print_data (species_id); CREATE INDEX ix_ord_glomerales_spore_print_data_specimen_id ON ord_glomerales_spore_print_data (specimen_id); CREATE TABLE ord_glomerales_mating_systems ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, system_type TEXT, mating_loci_count INTEGER, publication_id INTEGER, notes_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_glomerales_mating_systems_species_id ON ord_glomerales_mating_systems (species_id); CREATE INDEX ix_ord_glomerales_mating_systems_publication_id ON ord_glomerales_mating_systems (publication_id); CREATE TABLE ord_glomerales_nutrient_uptake_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, nitrogen_source TEXT, carbon_source TEXT, growth_response TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_glomerales_nutrient_uptake_studies_species_id ON ord_glomerales_nutrient_uptake_studies (species_id); CREATE INDEX ix_ord_glomerales_nutrient_uptake_studies_strain_id ON ord_glomerales_nutrient_uptake_studies (strain_id); CREATE TABLE ord_glomerales_range_maps ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, polygon_file_uri TEXT NOT NULL, source_methodology TEXT, area_km2 REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_glomerales_range_maps_species_id ON ord_glomerales_range_maps (species_id); CREATE INDEX ix_ord_glomerales_range_maps_publication_id ON ord_glomerales_range_maps (publication_id); CREATE TABLE ord_glomerales_abundance_estimates ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, estimate_kind TEXT, value_min REAL, value_max REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_glomerales_abundance_estimates_species_id ON ord_glomerales_abundance_estimates (species_id); CREATE INDEX ix_ord_glomerales_abundance_estimates_country_id ON ord_glomerales_abundance_estimates (country_id); CREATE TABLE ord_glomerales_toxin_profiles ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, presence TEXT, typical_concentration_mg_per_kg REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_glomerales_toxin_profiles_species_id ON ord_glomerales_toxin_profiles (species_id); CREATE INDEX ix_ord_glomerales_toxin_profiles_compound_id ON ord_glomerales_toxin_profiles (compound_id); CREATE TABLE ord_glomerales_enzyme_activity_assays ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, enzyme_id INTEGER NOT NULL, strain_id INTEGER, activity_u_per_mg REAL, temperature_c REAL, ph REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (enzyme_id) REFERENCES bio_enzymes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_glomerales_enzyme_activity_assays_species_id ON ord_glomerales_enzyme_activity_assays (species_id); CREATE INDEX ix_ord_glomerales_enzyme_activity_assays_enzyme_id ON ord_glomerales_enzyme_activity_assays (enzyme_id); CREATE TABLE ord_glomerales_biocontrol_evaluations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, target_pest_text TEXT NOT NULL, efficacy_pct REAL, trial_setting TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_glomerales_biocontrol_evaluations_species_id ON ord_glomerales_biocontrol_evaluations (species_id); CREATE INDEX ix_ord_glomerales_biocontrol_evaluations_publication_id ON ord_glomerales_biocontrol_evaluations (publication_id); CREATE TABLE ord_glomerales_regional_checklists ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, checklist_publication_id INTEGER, status TEXT, checklist_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (checklist_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_glomerales_regional_checklists_species_id ON ord_glomerales_regional_checklists (species_id); CREATE INDEX ix_ord_glomerales_regional_checklists_country_id ON ord_glomerales_regional_checklists (country_id); CREATE TABLE ord_diversisporales_morphology ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, hymenium_color_at_maturity TEXT, context_color_at_maturity TEXT, characteristic_microstructure TEXT, diagnostic_features_text TEXT, notes_kohler_reaction TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_diversisporales_morphology_specimen_id ON ord_diversisporales_morphology (specimen_id); CREATE INDEX ix_ord_diversisporales_morphology_species_id ON ord_diversisporales_morphology (species_id); CREATE TABLE ord_diversisporales_ecology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, dominant_habitat_id INTEGER, dominant_substrate_id INTEGER, dominant_biome_id INTEGER, trophic_strategy TEXT, typical_fruiting_period TEXT, known_distribution_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_habitat_id) REFERENCES eco_habitat_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_substrate_id) REFERENCES eco_substrate_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_biome_id) REFERENCES geo_biomes (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_diversisporales_ecology_species_id ON ord_diversisporales_ecology (species_id); CREATE INDEX ix_ord_diversisporales_ecology_dominant_habitat_id ON ord_diversisporales_ecology (dominant_habitat_id); CREATE TABLE ord_diversisporales_phenology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, season_name TEXT, region_country_id INTEGER, first_doy INTEGER, peak_doy INTEGER, last_doy INTEGER, years_observed INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_diversisporales_phenology_species_id ON ord_diversisporales_phenology (species_id); CREATE INDEX ix_ord_diversisporales_phenology_region_country_id ON ord_diversisporales_phenology (region_country_id); CREATE TABLE ord_diversisporales_host_associations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, association_type TEXT, specificity TEXT, evidence_publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (evidence_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_diversisporales_host_associations_species_id ON ord_diversisporales_host_associations (species_id); CREATE INDEX ix_ord_diversisporales_host_associations_host_id ON ord_diversisporales_host_associations (host_id); CREATE TABLE ord_diversisporales_substrate_preferences ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, substrate_id INTEGER NOT NULL, preference_score REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (substrate_id) REFERENCES eco_substrate_types (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_diversisporales_substrate_preferences_species_id ON ord_diversisporales_substrate_preferences (species_id); CREATE INDEX ix_ord_diversisporales_substrate_preferences_substrate_id ON ord_diversisporales_substrate_preferences (substrate_id); CREATE TABLE ord_diversisporales_geographic_distribution ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, occurrence_status TEXT, first_record_year INTEGER, record_count INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_diversisporales_geographic_distribution_species_id ON ord_diversisporales_geographic_distribution (species_id); CREATE INDEX ix_ord_diversisporales_geographic_distribution_country_id ON ord_diversisporales_geographic_distribution (country_id); CREATE TABLE ord_diversisporales_phylogeny ( id INTEGER PRIMARY KEY AUTOINCREMENT, tree_id INTEGER NOT NULL, focal_genus_id INTEGER, publication_id INTEGER, notes_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (tree_id) REFERENCES phy_trees (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_diversisporales_phylogeny_tree_id ON ord_diversisporales_phylogeny (tree_id); CREATE INDEX ix_ord_diversisporales_phylogeny_focal_genus_id ON ord_diversisporales_phylogeny (focal_genus_id); CREATE TABLE ord_diversisporales_genomics ( id INTEGER PRIMARY KEY AUTOINCREMENT, assembly_id INTEGER NOT NULL, species_id INTEGER, avg_genome_size_mb REAL, avg_gene_count INTEGER, avg_busco_complete_pct REAL, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (assembly_id) REFERENCES gen_assemblies (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_diversisporales_genomics_assembly_id ON ord_diversisporales_genomics (assembly_id); CREATE INDEX ix_ord_diversisporales_genomics_species_id ON ord_diversisporales_genomics (species_id); CREATE TABLE ord_diversisporales_biochemistry ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, typicality TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_diversisporales_biochemistry_species_id ON ord_diversisporales_biochemistry (species_id); CREATE INDEX ix_ord_diversisporales_biochemistry_compound_id ON ord_diversisporales_biochemistry (compound_id); CREATE TABLE ord_diversisporales_cultivation_notes ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, typical_growth_rate_mm_per_day REAL, preferred_media_type_id INTEGER, optimal_temperature_c REAL, difficulty_score INTEGER CHECK (difficulty_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (preferred_media_type_id) REFERENCES cul_media_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_diversisporales_cultivation_notes_species_id ON ord_diversisporales_cultivation_notes (species_id); CREATE INDEX ix_ord_diversisporales_cultivation_notes_strain_id ON ord_diversisporales_cultivation_notes (strain_id); CREATE TABLE ord_diversisporales_pathogenicity ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, disease_id INTEGER, severity_score INTEGER CHECK (severity_score BETWEEN 1 AND 5), publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (disease_id) REFERENCES pat_diseases (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_diversisporales_pathogenicity_species_id ON ord_diversisporales_pathogenicity (species_id); CREATE INDEX ix_ord_diversisporales_pathogenicity_host_id ON ord_diversisporales_pathogenicity (host_id); CREATE TABLE ord_diversisporales_edibility ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, edibility_class TEXT, preparation_notes TEXT, regional_tradition_country_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (regional_tradition_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_diversisporales_edibility_species_id ON ord_diversisporales_edibility (species_id); CREATE INDEX ix_ord_diversisporales_edibility_1 ON ord_diversisporales_edibility (regional_tradition_country_id); CREATE TABLE ord_diversisporales_medicinal_uses ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, traditional_use_text TEXT, modern_evidence_level TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_diversisporales_medicinal_uses_species_id ON ord_diversisporales_medicinal_uses (species_id); CREATE INDEX ix_ord_diversisporales_medicinal_uses_publication_id ON ord_diversisporales_medicinal_uses (publication_id); CREATE TABLE ord_diversisporales_taxonomic_revisions ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER NOT NULL, affected_family_id INTEGER, affected_genus_id INTEGER, revision_summary TEXT, revision_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_family_id) REFERENCES tax_families (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_diversisporales_taxonomic_revisions_publication_id ON ord_diversisporales_taxonomic_revisions (publication_id); CREATE INDEX ix_ord_diversisporales_taxonomic_revisions_1 ON ord_diversisporales_taxonomic_revisions (affected_family_id); CREATE TABLE ord_diversisporales_conservation_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, national_redlist_category TEXT, habitat_pressure_text TEXT, last_assessment_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_diversisporales_conservation_status_species_id ON ord_diversisporales_conservation_status (species_id); CREATE INDEX ix_ord_diversisporales_conservation_status_country_id ON ord_diversisporales_conservation_status (country_id); CREATE TABLE ord_diversisporales_diagnostic_keys ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER, key_title TEXT NOT NULL, region_country_id INTEGER, n_taxa_covered INTEGER, key_format TEXT, includes_microscopy INTEGER NOT NULL DEFAULT 0, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_diversisporales_diagnostic_keys_publication_id ON ord_diversisporales_diagnostic_keys (publication_id); CREATE INDEX ix_ord_diversisporales_diagnostic_keys_region_country_id ON ord_diversisporales_diagnostic_keys (region_country_id); CREATE TABLE ord_diversisporales_type_species_register ( id INTEGER PRIMARY KEY AUTOINCREMENT, focal_genus_id INTEGER NOT NULL, type_species_id INTEGER, designation_publication_id INTEGER, designation_year INTEGER, designated_by_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (designation_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_diversisporales_type_species_register_focal_genus_id ON ord_diversisporales_type_species_register (focal_genus_id); CREATE INDEX ix_ord_diversisporales_type_species_register_type_species_id ON ord_diversisporales_type_species_register (type_species_id); CREATE TABLE ord_diversisporales_distribution_grids ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, grid_cell_code TEXT NOT NULL, centroid_lat REAL, centroid_lon REAL, record_count INTEGER, first_record_year INTEGER, most_recent_record_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_diversisporales_distribution_grids_species_id ON ord_diversisporales_distribution_grids (species_id); CREATE INDEX ix_ord_diversisporales_distribution_grids_country_id ON ord_diversisporales_distribution_grids (country_id); CREATE TABLE ord_diversisporales_microclimate_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER, publication_id INTEGER, substrate_temperature_c REAL, substrate_moisture_pct REAL, canopy_closure_pct REAL, photosynthetic_par_umol_m2_s REAL, days_post_rainfall INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_diversisporales_microclimate_studies_species_id ON ord_diversisporales_microclimate_studies (species_id); CREATE INDEX ix_ord_diversisporales_microclimate_studies_publication_id ON ord_diversisporales_microclimate_studies (publication_id); CREATE TABLE ord_diversisporales_dna_barcoding_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, its_sequenced INTEGER NOT NULL DEFAULT 0, lsu_sequenced INTEGER NOT NULL DEFAULT 0, rpb2_sequenced INTEGER NOT NULL DEFAULT 0, ef1a_sequenced INTEGER NOT NULL DEFAULT 0, genome_assembled INTEGER NOT NULL DEFAULT 0, priority_for_sequencing_score INTEGER CHECK (priority_for_sequencing_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_diversisporales_dna_barcoding_status_species_id ON ord_diversisporales_dna_barcoding_status (species_id); CREATE TABLE ord_diversisporales_spore_print_data ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, specimen_id INTEGER, print_color_label TEXT, print_color_chip_id INTEGER, spore_density_per_mm2 REAL, collection_substrate TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (print_color_chip_id) REFERENCES mor_color_chips (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_diversisporales_spore_print_data_species_id ON ord_diversisporales_spore_print_data (species_id); CREATE INDEX ix_ord_diversisporales_spore_print_data_specimen_id ON ord_diversisporales_spore_print_data (specimen_id); CREATE TABLE ord_diversisporales_mating_systems ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, system_type TEXT, mating_loci_count INTEGER, publication_id INTEGER, notes_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_diversisporales_mating_systems_species_id ON ord_diversisporales_mating_systems (species_id); CREATE INDEX ix_ord_diversisporales_mating_systems_publication_id ON ord_diversisporales_mating_systems (publication_id); CREATE TABLE ord_diversisporales_nutrient_uptake_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, nitrogen_source TEXT, carbon_source TEXT, growth_response TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_diversisporales_nutrient_uptake_studies_species_id ON ord_diversisporales_nutrient_uptake_studies (species_id); CREATE INDEX ix_ord_diversisporales_nutrient_uptake_studies_strain_id ON ord_diversisporales_nutrient_uptake_studies (strain_id); CREATE TABLE ord_diversisporales_range_maps ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, polygon_file_uri TEXT NOT NULL, source_methodology TEXT, area_km2 REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_diversisporales_range_maps_species_id ON ord_diversisporales_range_maps (species_id); CREATE INDEX ix_ord_diversisporales_range_maps_publication_id ON ord_diversisporales_range_maps (publication_id); CREATE TABLE ord_diversisporales_abundance_estimates ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, estimate_kind TEXT, value_min REAL, value_max REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_diversisporales_abundance_estimates_species_id ON ord_diversisporales_abundance_estimates (species_id); CREATE INDEX ix_ord_diversisporales_abundance_estimates_country_id ON ord_diversisporales_abundance_estimates (country_id); CREATE TABLE ord_diversisporales_toxin_profiles ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, presence TEXT, typical_concentration_mg_per_kg REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_diversisporales_toxin_profiles_species_id ON ord_diversisporales_toxin_profiles (species_id); CREATE INDEX ix_ord_diversisporales_toxin_profiles_compound_id ON ord_diversisporales_toxin_profiles (compound_id); CREATE TABLE ord_diversisporales_enzyme_activity_assays ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, enzyme_id INTEGER NOT NULL, strain_id INTEGER, activity_u_per_mg REAL, temperature_c REAL, ph REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (enzyme_id) REFERENCES bio_enzymes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_diversisporales_enzyme_activity_assays_species_id ON ord_diversisporales_enzyme_activity_assays (species_id); CREATE INDEX ix_ord_diversisporales_enzyme_activity_assays_enzyme_id ON ord_diversisporales_enzyme_activity_assays (enzyme_id); CREATE TABLE ord_diversisporales_biocontrol_evaluations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, target_pest_text TEXT NOT NULL, efficacy_pct REAL, trial_setting TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_diversisporales_biocontrol_evaluations_species_id ON ord_diversisporales_biocontrol_evaluations (species_id); CREATE INDEX ix_ord_diversisporales_biocontrol_evaluations_publication_id ON ord_diversisporales_biocontrol_evaluations (publication_id); CREATE TABLE ord_diversisporales_regional_checklists ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, checklist_publication_id INTEGER, status TEXT, checklist_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (checklist_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_diversisporales_regional_checklists_species_id ON ord_diversisporales_regional_checklists (species_id); CREATE INDEX ix_ord_diversisporales_regional_checklists_country_id ON ord_diversisporales_regional_checklists (country_id); CREATE TABLE ord_blastocladiales_morphology ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, hymenium_color_at_maturity TEXT, context_color_at_maturity TEXT, characteristic_microstructure TEXT, diagnostic_features_text TEXT, notes_kohler_reaction TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_blastocladiales_morphology_specimen_id ON ord_blastocladiales_morphology (specimen_id); CREATE INDEX ix_ord_blastocladiales_morphology_species_id ON ord_blastocladiales_morphology (species_id); CREATE TABLE ord_blastocladiales_ecology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, dominant_habitat_id INTEGER, dominant_substrate_id INTEGER, dominant_biome_id INTEGER, trophic_strategy TEXT, typical_fruiting_period TEXT, known_distribution_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_habitat_id) REFERENCES eco_habitat_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_substrate_id) REFERENCES eco_substrate_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_biome_id) REFERENCES geo_biomes (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_blastocladiales_ecology_species_id ON ord_blastocladiales_ecology (species_id); CREATE INDEX ix_ord_blastocladiales_ecology_dominant_habitat_id ON ord_blastocladiales_ecology (dominant_habitat_id); CREATE TABLE ord_blastocladiales_phenology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, season_name TEXT, region_country_id INTEGER, first_doy INTEGER, peak_doy INTEGER, last_doy INTEGER, years_observed INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_blastocladiales_phenology_species_id ON ord_blastocladiales_phenology (species_id); CREATE INDEX ix_ord_blastocladiales_phenology_region_country_id ON ord_blastocladiales_phenology (region_country_id); CREATE TABLE ord_blastocladiales_host_associations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, association_type TEXT, specificity TEXT, evidence_publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (evidence_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_blastocladiales_host_associations_species_id ON ord_blastocladiales_host_associations (species_id); CREATE INDEX ix_ord_blastocladiales_host_associations_host_id ON ord_blastocladiales_host_associations (host_id); CREATE TABLE ord_blastocladiales_substrate_preferences ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, substrate_id INTEGER NOT NULL, preference_score REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (substrate_id) REFERENCES eco_substrate_types (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_blastocladiales_substrate_preferences_species_id ON ord_blastocladiales_substrate_preferences (species_id); CREATE INDEX ix_ord_blastocladiales_substrate_preferences_substrate_id ON ord_blastocladiales_substrate_preferences (substrate_id); CREATE TABLE ord_blastocladiales_geographic_distribution ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, occurrence_status TEXT, first_record_year INTEGER, record_count INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_blastocladiales_geographic_distribution_species_id ON ord_blastocladiales_geographic_distribution (species_id); CREATE INDEX ix_ord_blastocladiales_geographic_distribution_country_id ON ord_blastocladiales_geographic_distribution (country_id); CREATE TABLE ord_blastocladiales_phylogeny ( id INTEGER PRIMARY KEY AUTOINCREMENT, tree_id INTEGER NOT NULL, focal_genus_id INTEGER, publication_id INTEGER, notes_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (tree_id) REFERENCES phy_trees (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_blastocladiales_phylogeny_tree_id ON ord_blastocladiales_phylogeny (tree_id); CREATE INDEX ix_ord_blastocladiales_phylogeny_focal_genus_id ON ord_blastocladiales_phylogeny (focal_genus_id); CREATE TABLE ord_blastocladiales_genomics ( id INTEGER PRIMARY KEY AUTOINCREMENT, assembly_id INTEGER NOT NULL, species_id INTEGER, avg_genome_size_mb REAL, avg_gene_count INTEGER, avg_busco_complete_pct REAL, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (assembly_id) REFERENCES gen_assemblies (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_blastocladiales_genomics_assembly_id ON ord_blastocladiales_genomics (assembly_id); CREATE INDEX ix_ord_blastocladiales_genomics_species_id ON ord_blastocladiales_genomics (species_id); CREATE TABLE ord_blastocladiales_biochemistry ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, typicality TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_blastocladiales_biochemistry_species_id ON ord_blastocladiales_biochemistry (species_id); CREATE INDEX ix_ord_blastocladiales_biochemistry_compound_id ON ord_blastocladiales_biochemistry (compound_id); CREATE TABLE ord_blastocladiales_cultivation_notes ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, typical_growth_rate_mm_per_day REAL, preferred_media_type_id INTEGER, optimal_temperature_c REAL, difficulty_score INTEGER CHECK (difficulty_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (preferred_media_type_id) REFERENCES cul_media_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_blastocladiales_cultivation_notes_species_id ON ord_blastocladiales_cultivation_notes (species_id); CREATE INDEX ix_ord_blastocladiales_cultivation_notes_strain_id ON ord_blastocladiales_cultivation_notes (strain_id); CREATE TABLE ord_blastocladiales_pathogenicity ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, disease_id INTEGER, severity_score INTEGER CHECK (severity_score BETWEEN 1 AND 5), publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (disease_id) REFERENCES pat_diseases (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_blastocladiales_pathogenicity_species_id ON ord_blastocladiales_pathogenicity (species_id); CREATE INDEX ix_ord_blastocladiales_pathogenicity_host_id ON ord_blastocladiales_pathogenicity (host_id); CREATE TABLE ord_blastocladiales_edibility ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, edibility_class TEXT, preparation_notes TEXT, regional_tradition_country_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (regional_tradition_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_blastocladiales_edibility_species_id ON ord_blastocladiales_edibility (species_id); CREATE INDEX ix_ord_blastocladiales_edibility_1 ON ord_blastocladiales_edibility (regional_tradition_country_id); CREATE TABLE ord_blastocladiales_medicinal_uses ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, traditional_use_text TEXT, modern_evidence_level TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_blastocladiales_medicinal_uses_species_id ON ord_blastocladiales_medicinal_uses (species_id); CREATE INDEX ix_ord_blastocladiales_medicinal_uses_publication_id ON ord_blastocladiales_medicinal_uses (publication_id); CREATE TABLE ord_blastocladiales_taxonomic_revisions ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER NOT NULL, affected_family_id INTEGER, affected_genus_id INTEGER, revision_summary TEXT, revision_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_family_id) REFERENCES tax_families (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_blastocladiales_taxonomic_revisions_publication_id ON ord_blastocladiales_taxonomic_revisions (publication_id); CREATE INDEX ix_ord_blastocladiales_taxonomic_revisions_1 ON ord_blastocladiales_taxonomic_revisions (affected_family_id); CREATE TABLE ord_blastocladiales_conservation_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, national_redlist_category TEXT, habitat_pressure_text TEXT, last_assessment_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_blastocladiales_conservation_status_species_id ON ord_blastocladiales_conservation_status (species_id); CREATE INDEX ix_ord_blastocladiales_conservation_status_country_id ON ord_blastocladiales_conservation_status (country_id); CREATE TABLE ord_blastocladiales_diagnostic_keys ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER, key_title TEXT NOT NULL, region_country_id INTEGER, n_taxa_covered INTEGER, key_format TEXT, includes_microscopy INTEGER NOT NULL DEFAULT 0, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_blastocladiales_diagnostic_keys_publication_id ON ord_blastocladiales_diagnostic_keys (publication_id); CREATE INDEX ix_ord_blastocladiales_diagnostic_keys_region_country_id ON ord_blastocladiales_diagnostic_keys (region_country_id); CREATE TABLE ord_blastocladiales_type_species_register ( id INTEGER PRIMARY KEY AUTOINCREMENT, focal_genus_id INTEGER NOT NULL, type_species_id INTEGER, designation_publication_id INTEGER, designation_year INTEGER, designated_by_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (designation_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_blastocladiales_type_species_register_focal_genus_id ON ord_blastocladiales_type_species_register (focal_genus_id); CREATE INDEX ix_ord_blastocladiales_type_species_register_type_species_id ON ord_blastocladiales_type_species_register (type_species_id); CREATE TABLE ord_blastocladiales_distribution_grids ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, grid_cell_code TEXT NOT NULL, centroid_lat REAL, centroid_lon REAL, record_count INTEGER, first_record_year INTEGER, most_recent_record_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_blastocladiales_distribution_grids_species_id ON ord_blastocladiales_distribution_grids (species_id); CREATE INDEX ix_ord_blastocladiales_distribution_grids_country_id ON ord_blastocladiales_distribution_grids (country_id); CREATE TABLE ord_blastocladiales_microclimate_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER, publication_id INTEGER, substrate_temperature_c REAL, substrate_moisture_pct REAL, canopy_closure_pct REAL, photosynthetic_par_umol_m2_s REAL, days_post_rainfall INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_blastocladiales_microclimate_studies_species_id ON ord_blastocladiales_microclimate_studies (species_id); CREATE INDEX ix_ord_blastocladiales_microclimate_studies_publication_id ON ord_blastocladiales_microclimate_studies (publication_id); CREATE TABLE ord_blastocladiales_dna_barcoding_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, its_sequenced INTEGER NOT NULL DEFAULT 0, lsu_sequenced INTEGER NOT NULL DEFAULT 0, rpb2_sequenced INTEGER NOT NULL DEFAULT 0, ef1a_sequenced INTEGER NOT NULL DEFAULT 0, genome_assembled INTEGER NOT NULL DEFAULT 0, priority_for_sequencing_score INTEGER CHECK (priority_for_sequencing_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_blastocladiales_dna_barcoding_status_species_id ON ord_blastocladiales_dna_barcoding_status (species_id); CREATE TABLE ord_blastocladiales_spore_print_data ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, specimen_id INTEGER, print_color_label TEXT, print_color_chip_id INTEGER, spore_density_per_mm2 REAL, collection_substrate TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (print_color_chip_id) REFERENCES mor_color_chips (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_blastocladiales_spore_print_data_species_id ON ord_blastocladiales_spore_print_data (species_id); CREATE INDEX ix_ord_blastocladiales_spore_print_data_specimen_id ON ord_blastocladiales_spore_print_data (specimen_id); CREATE TABLE ord_blastocladiales_mating_systems ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, system_type TEXT, mating_loci_count INTEGER, publication_id INTEGER, notes_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_blastocladiales_mating_systems_species_id ON ord_blastocladiales_mating_systems (species_id); CREATE INDEX ix_ord_blastocladiales_mating_systems_publication_id ON ord_blastocladiales_mating_systems (publication_id); CREATE TABLE ord_blastocladiales_nutrient_uptake_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, nitrogen_source TEXT, carbon_source TEXT, growth_response TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_blastocladiales_nutrient_uptake_studies_species_id ON ord_blastocladiales_nutrient_uptake_studies (species_id); CREATE INDEX ix_ord_blastocladiales_nutrient_uptake_studies_strain_id ON ord_blastocladiales_nutrient_uptake_studies (strain_id); CREATE TABLE ord_blastocladiales_range_maps ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, polygon_file_uri TEXT NOT NULL, source_methodology TEXT, area_km2 REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_blastocladiales_range_maps_species_id ON ord_blastocladiales_range_maps (species_id); CREATE INDEX ix_ord_blastocladiales_range_maps_publication_id ON ord_blastocladiales_range_maps (publication_id); CREATE TABLE ord_blastocladiales_abundance_estimates ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, estimate_kind TEXT, value_min REAL, value_max REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_blastocladiales_abundance_estimates_species_id ON ord_blastocladiales_abundance_estimates (species_id); CREATE INDEX ix_ord_blastocladiales_abundance_estimates_country_id ON ord_blastocladiales_abundance_estimates (country_id); CREATE TABLE ord_blastocladiales_toxin_profiles ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, presence TEXT, typical_concentration_mg_per_kg REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_blastocladiales_toxin_profiles_species_id ON ord_blastocladiales_toxin_profiles (species_id); CREATE INDEX ix_ord_blastocladiales_toxin_profiles_compound_id ON ord_blastocladiales_toxin_profiles (compound_id); CREATE TABLE ord_blastocladiales_enzyme_activity_assays ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, enzyme_id INTEGER NOT NULL, strain_id INTEGER, activity_u_per_mg REAL, temperature_c REAL, ph REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (enzyme_id) REFERENCES bio_enzymes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_blastocladiales_enzyme_activity_assays_species_id ON ord_blastocladiales_enzyme_activity_assays (species_id); CREATE INDEX ix_ord_blastocladiales_enzyme_activity_assays_enzyme_id ON ord_blastocladiales_enzyme_activity_assays (enzyme_id); CREATE TABLE ord_blastocladiales_biocontrol_evaluations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, target_pest_text TEXT NOT NULL, efficacy_pct REAL, trial_setting TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_blastocladiales_biocontrol_evaluations_species_id ON ord_blastocladiales_biocontrol_evaluations (species_id); CREATE INDEX ix_ord_blastocladiales_biocontrol_evaluations_publication_id ON ord_blastocladiales_biocontrol_evaluations (publication_id); CREATE TABLE ord_blastocladiales_regional_checklists ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, checklist_publication_id INTEGER, status TEXT, checklist_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (checklist_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_blastocladiales_regional_checklists_species_id ON ord_blastocladiales_regional_checklists (species_id); CREATE INDEX ix_ord_blastocladiales_regional_checklists_country_id ON ord_blastocladiales_regional_checklists (country_id); CREATE TABLE ord_monoblepharidales_morphology ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, hymenium_color_at_maturity TEXT, context_color_at_maturity TEXT, characteristic_microstructure TEXT, diagnostic_features_text TEXT, notes_kohler_reaction TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_monoblepharidales_morphology_specimen_id ON ord_monoblepharidales_morphology (specimen_id); CREATE INDEX ix_ord_monoblepharidales_morphology_species_id ON ord_monoblepharidales_morphology (species_id); CREATE TABLE ord_monoblepharidales_ecology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, dominant_habitat_id INTEGER, dominant_substrate_id INTEGER, dominant_biome_id INTEGER, trophic_strategy TEXT, typical_fruiting_period TEXT, known_distribution_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_habitat_id) REFERENCES eco_habitat_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_substrate_id) REFERENCES eco_substrate_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_biome_id) REFERENCES geo_biomes (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_monoblepharidales_ecology_species_id ON ord_monoblepharidales_ecology (species_id); CREATE INDEX ix_ord_monoblepharidales_ecology_dominant_habitat_id ON ord_monoblepharidales_ecology (dominant_habitat_id); CREATE TABLE ord_monoblepharidales_phenology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, season_name TEXT, region_country_id INTEGER, first_doy INTEGER, peak_doy INTEGER, last_doy INTEGER, years_observed INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_monoblepharidales_phenology_species_id ON ord_monoblepharidales_phenology (species_id); CREATE INDEX ix_ord_monoblepharidales_phenology_region_country_id ON ord_monoblepharidales_phenology (region_country_id); CREATE TABLE ord_monoblepharidales_host_associations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, association_type TEXT, specificity TEXT, evidence_publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (evidence_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_monoblepharidales_host_associations_species_id ON ord_monoblepharidales_host_associations (species_id); CREATE INDEX ix_ord_monoblepharidales_host_associations_host_id ON ord_monoblepharidales_host_associations (host_id); CREATE TABLE ord_monoblepharidales_substrate_preferences ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, substrate_id INTEGER NOT NULL, preference_score REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (substrate_id) REFERENCES eco_substrate_types (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_monoblepharidales_substrate_preferences_species_id ON ord_monoblepharidales_substrate_preferences (species_id); CREATE INDEX ix_ord_monoblepharidales_substrate_preferences_substrate_id ON ord_monoblepharidales_substrate_preferences (substrate_id); CREATE TABLE ord_monoblepharidales_geographic_distribution ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, occurrence_status TEXT, first_record_year INTEGER, record_count INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_monoblepharidales_geographic_distribution_species_id ON ord_monoblepharidales_geographic_distribution (species_id); CREATE INDEX ix_ord_monoblepharidales_geographic_distribution_country_id ON ord_monoblepharidales_geographic_distribution (country_id); CREATE TABLE ord_monoblepharidales_phylogeny ( id INTEGER PRIMARY KEY AUTOINCREMENT, tree_id INTEGER NOT NULL, focal_genus_id INTEGER, publication_id INTEGER, notes_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (tree_id) REFERENCES phy_trees (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_monoblepharidales_phylogeny_tree_id ON ord_monoblepharidales_phylogeny (tree_id); CREATE INDEX ix_ord_monoblepharidales_phylogeny_focal_genus_id ON ord_monoblepharidales_phylogeny (focal_genus_id); CREATE TABLE ord_monoblepharidales_genomics ( id INTEGER PRIMARY KEY AUTOINCREMENT, assembly_id INTEGER NOT NULL, species_id INTEGER, avg_genome_size_mb REAL, avg_gene_count INTEGER, avg_busco_complete_pct REAL, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (assembly_id) REFERENCES gen_assemblies (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_monoblepharidales_genomics_assembly_id ON ord_monoblepharidales_genomics (assembly_id); CREATE INDEX ix_ord_monoblepharidales_genomics_species_id ON ord_monoblepharidales_genomics (species_id); CREATE TABLE ord_monoblepharidales_biochemistry ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, typicality TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_monoblepharidales_biochemistry_species_id ON ord_monoblepharidales_biochemistry (species_id); CREATE INDEX ix_ord_monoblepharidales_biochemistry_compound_id ON ord_monoblepharidales_biochemistry (compound_id); CREATE TABLE ord_monoblepharidales_cultivation_notes ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, typical_growth_rate_mm_per_day REAL, preferred_media_type_id INTEGER, optimal_temperature_c REAL, difficulty_score INTEGER CHECK (difficulty_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (preferred_media_type_id) REFERENCES cul_media_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_monoblepharidales_cultivation_notes_species_id ON ord_monoblepharidales_cultivation_notes (species_id); CREATE INDEX ix_ord_monoblepharidales_cultivation_notes_strain_id ON ord_monoblepharidales_cultivation_notes (strain_id); CREATE TABLE ord_monoblepharidales_pathogenicity ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, disease_id INTEGER, severity_score INTEGER CHECK (severity_score BETWEEN 1 AND 5), publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (disease_id) REFERENCES pat_diseases (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_monoblepharidales_pathogenicity_species_id ON ord_monoblepharidales_pathogenicity (species_id); CREATE INDEX ix_ord_monoblepharidales_pathogenicity_host_id ON ord_monoblepharidales_pathogenicity (host_id); CREATE TABLE ord_monoblepharidales_edibility ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, edibility_class TEXT, preparation_notes TEXT, regional_tradition_country_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (regional_tradition_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_monoblepharidales_edibility_species_id ON ord_monoblepharidales_edibility (species_id); CREATE INDEX ix_ord_monoblepharidales_edibility_1 ON ord_monoblepharidales_edibility (regional_tradition_country_id); CREATE TABLE ord_monoblepharidales_medicinal_uses ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, traditional_use_text TEXT, modern_evidence_level TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_monoblepharidales_medicinal_uses_species_id ON ord_monoblepharidales_medicinal_uses (species_id); CREATE INDEX ix_ord_monoblepharidales_medicinal_uses_publication_id ON ord_monoblepharidales_medicinal_uses (publication_id); CREATE TABLE ord_monoblepharidales_taxonomic_revisions ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER NOT NULL, affected_family_id INTEGER, affected_genus_id INTEGER, revision_summary TEXT, revision_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_family_id) REFERENCES tax_families (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_monoblepharidales_taxonomic_revisions_publication_id ON ord_monoblepharidales_taxonomic_revisions (publication_id); CREATE INDEX ix_ord_monoblepharidales_taxonomic_revisions_1 ON ord_monoblepharidales_taxonomic_revisions (affected_family_id); CREATE TABLE ord_monoblepharidales_conservation_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, national_redlist_category TEXT, habitat_pressure_text TEXT, last_assessment_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_monoblepharidales_conservation_status_species_id ON ord_monoblepharidales_conservation_status (species_id); CREATE INDEX ix_ord_monoblepharidales_conservation_status_country_id ON ord_monoblepharidales_conservation_status (country_id); CREATE TABLE ord_monoblepharidales_diagnostic_keys ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER, key_title TEXT NOT NULL, region_country_id INTEGER, n_taxa_covered INTEGER, key_format TEXT, includes_microscopy INTEGER NOT NULL DEFAULT 0, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_monoblepharidales_diagnostic_keys_publication_id ON ord_monoblepharidales_diagnostic_keys (publication_id); CREATE INDEX ix_ord_monoblepharidales_diagnostic_keys_region_country_id ON ord_monoblepharidales_diagnostic_keys (region_country_id); CREATE TABLE ord_monoblepharidales_type_species_register ( id INTEGER PRIMARY KEY AUTOINCREMENT, focal_genus_id INTEGER NOT NULL, type_species_id INTEGER, designation_publication_id INTEGER, designation_year INTEGER, designated_by_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (designation_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_monoblepharidales_type_species_register_0 ON ord_monoblepharidales_type_species_register (focal_genus_id); CREATE INDEX ix_ord_monoblepharidales_type_species_register_1 ON ord_monoblepharidales_type_species_register (type_species_id); CREATE TABLE ord_monoblepharidales_distribution_grids ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, grid_cell_code TEXT NOT NULL, centroid_lat REAL, centroid_lon REAL, record_count INTEGER, first_record_year INTEGER, most_recent_record_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_monoblepharidales_distribution_grids_species_id ON ord_monoblepharidales_distribution_grids (species_id); CREATE INDEX ix_ord_monoblepharidales_distribution_grids_country_id ON ord_monoblepharidales_distribution_grids (country_id); CREATE TABLE ord_monoblepharidales_microclimate_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER, publication_id INTEGER, substrate_temperature_c REAL, substrate_moisture_pct REAL, canopy_closure_pct REAL, photosynthetic_par_umol_m2_s REAL, days_post_rainfall INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_monoblepharidales_microclimate_studies_species_id ON ord_monoblepharidales_microclimate_studies (species_id); CREATE INDEX ix_ord_monoblepharidales_microclimate_studies_publication_id ON ord_monoblepharidales_microclimate_studies (publication_id); CREATE TABLE ord_monoblepharidales_dna_barcoding_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, its_sequenced INTEGER NOT NULL DEFAULT 0, lsu_sequenced INTEGER NOT NULL DEFAULT 0, rpb2_sequenced INTEGER NOT NULL DEFAULT 0, ef1a_sequenced INTEGER NOT NULL DEFAULT 0, genome_assembled INTEGER NOT NULL DEFAULT 0, priority_for_sequencing_score INTEGER CHECK (priority_for_sequencing_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_monoblepharidales_dna_barcoding_status_species_id ON ord_monoblepharidales_dna_barcoding_status (species_id); CREATE TABLE ord_monoblepharidales_spore_print_data ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, specimen_id INTEGER, print_color_label TEXT, print_color_chip_id INTEGER, spore_density_per_mm2 REAL, collection_substrate TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (print_color_chip_id) REFERENCES mor_color_chips (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_monoblepharidales_spore_print_data_species_id ON ord_monoblepharidales_spore_print_data (species_id); CREATE INDEX ix_ord_monoblepharidales_spore_print_data_specimen_id ON ord_monoblepharidales_spore_print_data (specimen_id); CREATE TABLE ord_monoblepharidales_mating_systems ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, system_type TEXT, mating_loci_count INTEGER, publication_id INTEGER, notes_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_monoblepharidales_mating_systems_species_id ON ord_monoblepharidales_mating_systems (species_id); CREATE INDEX ix_ord_monoblepharidales_mating_systems_publication_id ON ord_monoblepharidales_mating_systems (publication_id); CREATE TABLE ord_monoblepharidales_nutrient_uptake_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, nitrogen_source TEXT, carbon_source TEXT, growth_response TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_monoblepharidales_nutrient_uptake_studies_species_id ON ord_monoblepharidales_nutrient_uptake_studies (species_id); CREATE INDEX ix_ord_monoblepharidales_nutrient_uptake_studies_strain_id ON ord_monoblepharidales_nutrient_uptake_studies (strain_id); CREATE TABLE ord_monoblepharidales_range_maps ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, polygon_file_uri TEXT NOT NULL, source_methodology TEXT, area_km2 REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_monoblepharidales_range_maps_species_id ON ord_monoblepharidales_range_maps (species_id); CREATE INDEX ix_ord_monoblepharidales_range_maps_publication_id ON ord_monoblepharidales_range_maps (publication_id); CREATE TABLE ord_monoblepharidales_abundance_estimates ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, estimate_kind TEXT, value_min REAL, value_max REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_monoblepharidales_abundance_estimates_species_id ON ord_monoblepharidales_abundance_estimates (species_id); CREATE INDEX ix_ord_monoblepharidales_abundance_estimates_country_id ON ord_monoblepharidales_abundance_estimates (country_id); CREATE TABLE ord_monoblepharidales_toxin_profiles ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, presence TEXT, typical_concentration_mg_per_kg REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_monoblepharidales_toxin_profiles_species_id ON ord_monoblepharidales_toxin_profiles (species_id); CREATE INDEX ix_ord_monoblepharidales_toxin_profiles_compound_id ON ord_monoblepharidales_toxin_profiles (compound_id); CREATE TABLE ord_monoblepharidales_enzyme_activity_assays ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, enzyme_id INTEGER NOT NULL, strain_id INTEGER, activity_u_per_mg REAL, temperature_c REAL, ph REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (enzyme_id) REFERENCES bio_enzymes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_monoblepharidales_enzyme_activity_assays_species_id ON ord_monoblepharidales_enzyme_activity_assays (species_id); CREATE INDEX ix_ord_monoblepharidales_enzyme_activity_assays_enzyme_id ON ord_monoblepharidales_enzyme_activity_assays (enzyme_id); CREATE TABLE ord_monoblepharidales_biocontrol_evaluations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, target_pest_text TEXT NOT NULL, efficacy_pct REAL, trial_setting TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_monoblepharidales_biocontrol_evaluations_species_id ON ord_monoblepharidales_biocontrol_evaluations (species_id); CREATE INDEX ix_ord_monoblepharidales_biocontrol_evaluations_1 ON ord_monoblepharidales_biocontrol_evaluations (publication_id); CREATE TABLE ord_monoblepharidales_regional_checklists ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, checklist_publication_id INTEGER, status TEXT, checklist_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (checklist_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_monoblepharidales_regional_checklists_species_id ON ord_monoblepharidales_regional_checklists (species_id); CREATE INDEX ix_ord_monoblepharidales_regional_checklists_country_id ON ord_monoblepharidales_regional_checklists (country_id); CREATE TABLE ord_rhizophydiales_morphology ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, hymenium_color_at_maturity TEXT, context_color_at_maturity TEXT, characteristic_microstructure TEXT, diagnostic_features_text TEXT, notes_kohler_reaction TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_rhizophydiales_morphology_specimen_id ON ord_rhizophydiales_morphology (specimen_id); CREATE INDEX ix_ord_rhizophydiales_morphology_species_id ON ord_rhizophydiales_morphology (species_id); CREATE TABLE ord_rhizophydiales_ecology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, dominant_habitat_id INTEGER, dominant_substrate_id INTEGER, dominant_biome_id INTEGER, trophic_strategy TEXT, typical_fruiting_period TEXT, known_distribution_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_habitat_id) REFERENCES eco_habitat_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_substrate_id) REFERENCES eco_substrate_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_biome_id) REFERENCES geo_biomes (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_rhizophydiales_ecology_species_id ON ord_rhizophydiales_ecology (species_id); CREATE INDEX ix_ord_rhizophydiales_ecology_dominant_habitat_id ON ord_rhizophydiales_ecology (dominant_habitat_id); CREATE TABLE ord_rhizophydiales_phenology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, season_name TEXT, region_country_id INTEGER, first_doy INTEGER, peak_doy INTEGER, last_doy INTEGER, years_observed INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_rhizophydiales_phenology_species_id ON ord_rhizophydiales_phenology (species_id); CREATE INDEX ix_ord_rhizophydiales_phenology_region_country_id ON ord_rhizophydiales_phenology (region_country_id); CREATE TABLE ord_rhizophydiales_host_associations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, association_type TEXT, specificity TEXT, evidence_publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (evidence_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_rhizophydiales_host_associations_species_id ON ord_rhizophydiales_host_associations (species_id); CREATE INDEX ix_ord_rhizophydiales_host_associations_host_id ON ord_rhizophydiales_host_associations (host_id); CREATE TABLE ord_rhizophydiales_substrate_preferences ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, substrate_id INTEGER NOT NULL, preference_score REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (substrate_id) REFERENCES eco_substrate_types (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_rhizophydiales_substrate_preferences_species_id ON ord_rhizophydiales_substrate_preferences (species_id); CREATE INDEX ix_ord_rhizophydiales_substrate_preferences_substrate_id ON ord_rhizophydiales_substrate_preferences (substrate_id); CREATE TABLE ord_rhizophydiales_geographic_distribution ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, occurrence_status TEXT, first_record_year INTEGER, record_count INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_rhizophydiales_geographic_distribution_species_id ON ord_rhizophydiales_geographic_distribution (species_id); CREATE INDEX ix_ord_rhizophydiales_geographic_distribution_country_id ON ord_rhizophydiales_geographic_distribution (country_id); CREATE TABLE ord_rhizophydiales_phylogeny ( id INTEGER PRIMARY KEY AUTOINCREMENT, tree_id INTEGER NOT NULL, focal_genus_id INTEGER, publication_id INTEGER, notes_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (tree_id) REFERENCES phy_trees (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_rhizophydiales_phylogeny_tree_id ON ord_rhizophydiales_phylogeny (tree_id); CREATE INDEX ix_ord_rhizophydiales_phylogeny_focal_genus_id ON ord_rhizophydiales_phylogeny (focal_genus_id); CREATE TABLE ord_rhizophydiales_genomics ( id INTEGER PRIMARY KEY AUTOINCREMENT, assembly_id INTEGER NOT NULL, species_id INTEGER, avg_genome_size_mb REAL, avg_gene_count INTEGER, avg_busco_complete_pct REAL, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (assembly_id) REFERENCES gen_assemblies (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_rhizophydiales_genomics_assembly_id ON ord_rhizophydiales_genomics (assembly_id); CREATE INDEX ix_ord_rhizophydiales_genomics_species_id ON ord_rhizophydiales_genomics (species_id); CREATE TABLE ord_rhizophydiales_biochemistry ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, typicality TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_rhizophydiales_biochemistry_species_id ON ord_rhizophydiales_biochemistry (species_id); CREATE INDEX ix_ord_rhizophydiales_biochemistry_compound_id ON ord_rhizophydiales_biochemistry (compound_id); CREATE TABLE ord_rhizophydiales_cultivation_notes ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, typical_growth_rate_mm_per_day REAL, preferred_media_type_id INTEGER, optimal_temperature_c REAL, difficulty_score INTEGER CHECK (difficulty_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (preferred_media_type_id) REFERENCES cul_media_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_rhizophydiales_cultivation_notes_species_id ON ord_rhizophydiales_cultivation_notes (species_id); CREATE INDEX ix_ord_rhizophydiales_cultivation_notes_strain_id ON ord_rhizophydiales_cultivation_notes (strain_id); CREATE TABLE ord_rhizophydiales_pathogenicity ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, disease_id INTEGER, severity_score INTEGER CHECK (severity_score BETWEEN 1 AND 5), publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (disease_id) REFERENCES pat_diseases (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_rhizophydiales_pathogenicity_species_id ON ord_rhizophydiales_pathogenicity (species_id); CREATE INDEX ix_ord_rhizophydiales_pathogenicity_host_id ON ord_rhizophydiales_pathogenicity (host_id); CREATE TABLE ord_rhizophydiales_edibility ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, edibility_class TEXT, preparation_notes TEXT, regional_tradition_country_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (regional_tradition_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_rhizophydiales_edibility_species_id ON ord_rhizophydiales_edibility (species_id); CREATE INDEX ix_ord_rhizophydiales_edibility_1 ON ord_rhizophydiales_edibility (regional_tradition_country_id); CREATE TABLE ord_rhizophydiales_medicinal_uses ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, traditional_use_text TEXT, modern_evidence_level TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_rhizophydiales_medicinal_uses_species_id ON ord_rhizophydiales_medicinal_uses (species_id); CREATE INDEX ix_ord_rhizophydiales_medicinal_uses_publication_id ON ord_rhizophydiales_medicinal_uses (publication_id); CREATE TABLE ord_rhizophydiales_taxonomic_revisions ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER NOT NULL, affected_family_id INTEGER, affected_genus_id INTEGER, revision_summary TEXT, revision_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_family_id) REFERENCES tax_families (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_rhizophydiales_taxonomic_revisions_publication_id ON ord_rhizophydiales_taxonomic_revisions (publication_id); CREATE INDEX ix_ord_rhizophydiales_taxonomic_revisions_affected_family_id ON ord_rhizophydiales_taxonomic_revisions (affected_family_id); CREATE TABLE ord_rhizophydiales_conservation_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, national_redlist_category TEXT, habitat_pressure_text TEXT, last_assessment_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_rhizophydiales_conservation_status_species_id ON ord_rhizophydiales_conservation_status (species_id); CREATE INDEX ix_ord_rhizophydiales_conservation_status_country_id ON ord_rhizophydiales_conservation_status (country_id); CREATE TABLE ord_rhizophydiales_diagnostic_keys ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER, key_title TEXT NOT NULL, region_country_id INTEGER, n_taxa_covered INTEGER, key_format TEXT, includes_microscopy INTEGER NOT NULL DEFAULT 0, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_rhizophydiales_diagnostic_keys_publication_id ON ord_rhizophydiales_diagnostic_keys (publication_id); CREATE INDEX ix_ord_rhizophydiales_diagnostic_keys_region_country_id ON ord_rhizophydiales_diagnostic_keys (region_country_id); CREATE TABLE ord_rhizophydiales_type_species_register ( id INTEGER PRIMARY KEY AUTOINCREMENT, focal_genus_id INTEGER NOT NULL, type_species_id INTEGER, designation_publication_id INTEGER, designation_year INTEGER, designated_by_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (designation_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_rhizophydiales_type_species_register_focal_genus_id ON ord_rhizophydiales_type_species_register (focal_genus_id); CREATE INDEX ix_ord_rhizophydiales_type_species_register_type_species_id ON ord_rhizophydiales_type_species_register (type_species_id); CREATE TABLE ord_rhizophydiales_distribution_grids ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, grid_cell_code TEXT NOT NULL, centroid_lat REAL, centroid_lon REAL, record_count INTEGER, first_record_year INTEGER, most_recent_record_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_rhizophydiales_distribution_grids_species_id ON ord_rhizophydiales_distribution_grids (species_id); CREATE INDEX ix_ord_rhizophydiales_distribution_grids_country_id ON ord_rhizophydiales_distribution_grids (country_id); CREATE TABLE ord_rhizophydiales_microclimate_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER, publication_id INTEGER, substrate_temperature_c REAL, substrate_moisture_pct REAL, canopy_closure_pct REAL, photosynthetic_par_umol_m2_s REAL, days_post_rainfall INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_rhizophydiales_microclimate_studies_species_id ON ord_rhizophydiales_microclimate_studies (species_id); CREATE INDEX ix_ord_rhizophydiales_microclimate_studies_publication_id ON ord_rhizophydiales_microclimate_studies (publication_id); CREATE TABLE ord_rhizophydiales_dna_barcoding_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, its_sequenced INTEGER NOT NULL DEFAULT 0, lsu_sequenced INTEGER NOT NULL DEFAULT 0, rpb2_sequenced INTEGER NOT NULL DEFAULT 0, ef1a_sequenced INTEGER NOT NULL DEFAULT 0, genome_assembled INTEGER NOT NULL DEFAULT 0, priority_for_sequencing_score INTEGER CHECK (priority_for_sequencing_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_rhizophydiales_dna_barcoding_status_species_id ON ord_rhizophydiales_dna_barcoding_status (species_id); CREATE TABLE ord_rhizophydiales_spore_print_data ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, specimen_id INTEGER, print_color_label TEXT, print_color_chip_id INTEGER, spore_density_per_mm2 REAL, collection_substrate TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (print_color_chip_id) REFERENCES mor_color_chips (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_rhizophydiales_spore_print_data_species_id ON ord_rhizophydiales_spore_print_data (species_id); CREATE INDEX ix_ord_rhizophydiales_spore_print_data_specimen_id ON ord_rhizophydiales_spore_print_data (specimen_id); CREATE TABLE ord_rhizophydiales_mating_systems ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, system_type TEXT, mating_loci_count INTEGER, publication_id INTEGER, notes_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_rhizophydiales_mating_systems_species_id ON ord_rhizophydiales_mating_systems (species_id); CREATE INDEX ix_ord_rhizophydiales_mating_systems_publication_id ON ord_rhizophydiales_mating_systems (publication_id); CREATE TABLE ord_rhizophydiales_nutrient_uptake_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, nitrogen_source TEXT, carbon_source TEXT, growth_response TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_rhizophydiales_nutrient_uptake_studies_species_id ON ord_rhizophydiales_nutrient_uptake_studies (species_id); CREATE INDEX ix_ord_rhizophydiales_nutrient_uptake_studies_strain_id ON ord_rhizophydiales_nutrient_uptake_studies (strain_id); CREATE TABLE ord_rhizophydiales_range_maps ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, polygon_file_uri TEXT NOT NULL, source_methodology TEXT, area_km2 REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_rhizophydiales_range_maps_species_id ON ord_rhizophydiales_range_maps (species_id); CREATE INDEX ix_ord_rhizophydiales_range_maps_publication_id ON ord_rhizophydiales_range_maps (publication_id); CREATE TABLE ord_rhizophydiales_abundance_estimates ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, estimate_kind TEXT, value_min REAL, value_max REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_rhizophydiales_abundance_estimates_species_id ON ord_rhizophydiales_abundance_estimates (species_id); CREATE INDEX ix_ord_rhizophydiales_abundance_estimates_country_id ON ord_rhizophydiales_abundance_estimates (country_id); CREATE TABLE ord_rhizophydiales_toxin_profiles ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, presence TEXT, typical_concentration_mg_per_kg REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_rhizophydiales_toxin_profiles_species_id ON ord_rhizophydiales_toxin_profiles (species_id); CREATE INDEX ix_ord_rhizophydiales_toxin_profiles_compound_id ON ord_rhizophydiales_toxin_profiles (compound_id); CREATE TABLE ord_rhizophydiales_enzyme_activity_assays ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, enzyme_id INTEGER NOT NULL, strain_id INTEGER, activity_u_per_mg REAL, temperature_c REAL, ph REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (enzyme_id) REFERENCES bio_enzymes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_rhizophydiales_enzyme_activity_assays_species_id ON ord_rhizophydiales_enzyme_activity_assays (species_id); CREATE INDEX ix_ord_rhizophydiales_enzyme_activity_assays_enzyme_id ON ord_rhizophydiales_enzyme_activity_assays (enzyme_id); CREATE TABLE ord_rhizophydiales_biocontrol_evaluations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, target_pest_text TEXT NOT NULL, efficacy_pct REAL, trial_setting TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_rhizophydiales_biocontrol_evaluations_species_id ON ord_rhizophydiales_biocontrol_evaluations (species_id); CREATE INDEX ix_ord_rhizophydiales_biocontrol_evaluations_publication_id ON ord_rhizophydiales_biocontrol_evaluations (publication_id); CREATE TABLE ord_rhizophydiales_regional_checklists ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, checklist_publication_id INTEGER, status TEXT, checklist_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (checklist_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_rhizophydiales_regional_checklists_species_id ON ord_rhizophydiales_regional_checklists (species_id); CREATE INDEX ix_ord_rhizophydiales_regional_checklists_country_id ON ord_rhizophydiales_regional_checklists (country_id); CREATE TABLE ord_spizellomycetales_morphology ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, hymenium_color_at_maturity TEXT, context_color_at_maturity TEXT, characteristic_microstructure TEXT, diagnostic_features_text TEXT, notes_kohler_reaction TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_spizellomycetales_morphology_specimen_id ON ord_spizellomycetales_morphology (specimen_id); CREATE INDEX ix_ord_spizellomycetales_morphology_species_id ON ord_spizellomycetales_morphology (species_id); CREATE TABLE ord_spizellomycetales_ecology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, dominant_habitat_id INTEGER, dominant_substrate_id INTEGER, dominant_biome_id INTEGER, trophic_strategy TEXT, typical_fruiting_period TEXT, known_distribution_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_habitat_id) REFERENCES eco_habitat_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_substrate_id) REFERENCES eco_substrate_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_biome_id) REFERENCES geo_biomes (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_spizellomycetales_ecology_species_id ON ord_spizellomycetales_ecology (species_id); CREATE INDEX ix_ord_spizellomycetales_ecology_dominant_habitat_id ON ord_spizellomycetales_ecology (dominant_habitat_id); CREATE TABLE ord_spizellomycetales_phenology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, season_name TEXT, region_country_id INTEGER, first_doy INTEGER, peak_doy INTEGER, last_doy INTEGER, years_observed INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_spizellomycetales_phenology_species_id ON ord_spizellomycetales_phenology (species_id); CREATE INDEX ix_ord_spizellomycetales_phenology_region_country_id ON ord_spizellomycetales_phenology (region_country_id); CREATE TABLE ord_spizellomycetales_host_associations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, association_type TEXT, specificity TEXT, evidence_publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (evidence_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_spizellomycetales_host_associations_species_id ON ord_spizellomycetales_host_associations (species_id); CREATE INDEX ix_ord_spizellomycetales_host_associations_host_id ON ord_spizellomycetales_host_associations (host_id); CREATE TABLE ord_spizellomycetales_substrate_preferences ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, substrate_id INTEGER NOT NULL, preference_score REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (substrate_id) REFERENCES eco_substrate_types (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_spizellomycetales_substrate_preferences_species_id ON ord_spizellomycetales_substrate_preferences (species_id); CREATE INDEX ix_ord_spizellomycetales_substrate_preferences_substrate_id ON ord_spizellomycetales_substrate_preferences (substrate_id); CREATE TABLE ord_spizellomycetales_geographic_distribution ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, occurrence_status TEXT, first_record_year INTEGER, record_count INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_spizellomycetales_geographic_distribution_species_id ON ord_spizellomycetales_geographic_distribution (species_id); CREATE INDEX ix_ord_spizellomycetales_geographic_distribution_country_id ON ord_spizellomycetales_geographic_distribution (country_id); CREATE TABLE ord_spizellomycetales_phylogeny ( id INTEGER PRIMARY KEY AUTOINCREMENT, tree_id INTEGER NOT NULL, focal_genus_id INTEGER, publication_id INTEGER, notes_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (tree_id) REFERENCES phy_trees (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_spizellomycetales_phylogeny_tree_id ON ord_spizellomycetales_phylogeny (tree_id); CREATE INDEX ix_ord_spizellomycetales_phylogeny_focal_genus_id ON ord_spizellomycetales_phylogeny (focal_genus_id); CREATE TABLE ord_spizellomycetales_genomics ( id INTEGER PRIMARY KEY AUTOINCREMENT, assembly_id INTEGER NOT NULL, species_id INTEGER, avg_genome_size_mb REAL, avg_gene_count INTEGER, avg_busco_complete_pct REAL, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (assembly_id) REFERENCES gen_assemblies (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_spizellomycetales_genomics_assembly_id ON ord_spizellomycetales_genomics (assembly_id); CREATE INDEX ix_ord_spizellomycetales_genomics_species_id ON ord_spizellomycetales_genomics (species_id); CREATE TABLE ord_spizellomycetales_biochemistry ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, typicality TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_spizellomycetales_biochemistry_species_id ON ord_spizellomycetales_biochemistry (species_id); CREATE INDEX ix_ord_spizellomycetales_biochemistry_compound_id ON ord_spizellomycetales_biochemistry (compound_id); CREATE TABLE ord_spizellomycetales_cultivation_notes ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, typical_growth_rate_mm_per_day REAL, preferred_media_type_id INTEGER, optimal_temperature_c REAL, difficulty_score INTEGER CHECK (difficulty_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (preferred_media_type_id) REFERENCES cul_media_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_spizellomycetales_cultivation_notes_species_id ON ord_spizellomycetales_cultivation_notes (species_id); CREATE INDEX ix_ord_spizellomycetales_cultivation_notes_strain_id ON ord_spizellomycetales_cultivation_notes (strain_id); CREATE TABLE ord_spizellomycetales_pathogenicity ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, disease_id INTEGER, severity_score INTEGER CHECK (severity_score BETWEEN 1 AND 5), publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (disease_id) REFERENCES pat_diseases (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_spizellomycetales_pathogenicity_species_id ON ord_spizellomycetales_pathogenicity (species_id); CREATE INDEX ix_ord_spizellomycetales_pathogenicity_host_id ON ord_spizellomycetales_pathogenicity (host_id); CREATE TABLE ord_spizellomycetales_edibility ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, edibility_class TEXT, preparation_notes TEXT, regional_tradition_country_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (regional_tradition_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_spizellomycetales_edibility_species_id ON ord_spizellomycetales_edibility (species_id); CREATE INDEX ix_ord_spizellomycetales_edibility_1 ON ord_spizellomycetales_edibility (regional_tradition_country_id); CREATE TABLE ord_spizellomycetales_medicinal_uses ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, traditional_use_text TEXT, modern_evidence_level TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_spizellomycetales_medicinal_uses_species_id ON ord_spizellomycetales_medicinal_uses (species_id); CREATE INDEX ix_ord_spizellomycetales_medicinal_uses_publication_id ON ord_spizellomycetales_medicinal_uses (publication_id); CREATE TABLE ord_spizellomycetales_taxonomic_revisions ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER NOT NULL, affected_family_id INTEGER, affected_genus_id INTEGER, revision_summary TEXT, revision_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_family_id) REFERENCES tax_families (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_spizellomycetales_taxonomic_revisions_publication_id ON ord_spizellomycetales_taxonomic_revisions (publication_id); CREATE INDEX ix_ord_spizellomycetales_taxonomic_revisions_1 ON ord_spizellomycetales_taxonomic_revisions (affected_family_id); CREATE TABLE ord_spizellomycetales_conservation_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, national_redlist_category TEXT, habitat_pressure_text TEXT, last_assessment_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_spizellomycetales_conservation_status_species_id ON ord_spizellomycetales_conservation_status (species_id); CREATE INDEX ix_ord_spizellomycetales_conservation_status_country_id ON ord_spizellomycetales_conservation_status (country_id); CREATE TABLE ord_spizellomycetales_diagnostic_keys ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER, key_title TEXT NOT NULL, region_country_id INTEGER, n_taxa_covered INTEGER, key_format TEXT, includes_microscopy INTEGER NOT NULL DEFAULT 0, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_spizellomycetales_diagnostic_keys_publication_id ON ord_spizellomycetales_diagnostic_keys (publication_id); CREATE INDEX ix_ord_spizellomycetales_diagnostic_keys_region_country_id ON ord_spizellomycetales_diagnostic_keys (region_country_id); CREATE TABLE ord_spizellomycetales_type_species_register ( id INTEGER PRIMARY KEY AUTOINCREMENT, focal_genus_id INTEGER NOT NULL, type_species_id INTEGER, designation_publication_id INTEGER, designation_year INTEGER, designated_by_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (designation_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_spizellomycetales_type_species_register_0 ON ord_spizellomycetales_type_species_register (focal_genus_id); CREATE INDEX ix_ord_spizellomycetales_type_species_register_1 ON ord_spizellomycetales_type_species_register (type_species_id); CREATE TABLE ord_spizellomycetales_distribution_grids ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, grid_cell_code TEXT NOT NULL, centroid_lat REAL, centroid_lon REAL, record_count INTEGER, first_record_year INTEGER, most_recent_record_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_spizellomycetales_distribution_grids_species_id ON ord_spizellomycetales_distribution_grids (species_id); CREATE INDEX ix_ord_spizellomycetales_distribution_grids_country_id ON ord_spizellomycetales_distribution_grids (country_id); CREATE TABLE ord_spizellomycetales_microclimate_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER, publication_id INTEGER, substrate_temperature_c REAL, substrate_moisture_pct REAL, canopy_closure_pct REAL, photosynthetic_par_umol_m2_s REAL, days_post_rainfall INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_spizellomycetales_microclimate_studies_species_id ON ord_spizellomycetales_microclimate_studies (species_id); CREATE INDEX ix_ord_spizellomycetales_microclimate_studies_publication_id ON ord_spizellomycetales_microclimate_studies (publication_id); CREATE TABLE ord_spizellomycetales_dna_barcoding_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, its_sequenced INTEGER NOT NULL DEFAULT 0, lsu_sequenced INTEGER NOT NULL DEFAULT 0, rpb2_sequenced INTEGER NOT NULL DEFAULT 0, ef1a_sequenced INTEGER NOT NULL DEFAULT 0, genome_assembled INTEGER NOT NULL DEFAULT 0, priority_for_sequencing_score INTEGER CHECK (priority_for_sequencing_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_spizellomycetales_dna_barcoding_status_species_id ON ord_spizellomycetales_dna_barcoding_status (species_id); CREATE TABLE ord_spizellomycetales_spore_print_data ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, specimen_id INTEGER, print_color_label TEXT, print_color_chip_id INTEGER, spore_density_per_mm2 REAL, collection_substrate TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (print_color_chip_id) REFERENCES mor_color_chips (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_spizellomycetales_spore_print_data_species_id ON ord_spizellomycetales_spore_print_data (species_id); CREATE INDEX ix_ord_spizellomycetales_spore_print_data_specimen_id ON ord_spizellomycetales_spore_print_data (specimen_id); CREATE TABLE ord_spizellomycetales_mating_systems ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, system_type TEXT, mating_loci_count INTEGER, publication_id INTEGER, notes_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_spizellomycetales_mating_systems_species_id ON ord_spizellomycetales_mating_systems (species_id); CREATE INDEX ix_ord_spizellomycetales_mating_systems_publication_id ON ord_spizellomycetales_mating_systems (publication_id); CREATE TABLE ord_spizellomycetales_nutrient_uptake_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, nitrogen_source TEXT, carbon_source TEXT, growth_response TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_spizellomycetales_nutrient_uptake_studies_species_id ON ord_spizellomycetales_nutrient_uptake_studies (species_id); CREATE INDEX ix_ord_spizellomycetales_nutrient_uptake_studies_strain_id ON ord_spizellomycetales_nutrient_uptake_studies (strain_id); CREATE TABLE ord_spizellomycetales_range_maps ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, polygon_file_uri TEXT NOT NULL, source_methodology TEXT, area_km2 REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_spizellomycetales_range_maps_species_id ON ord_spizellomycetales_range_maps (species_id); CREATE INDEX ix_ord_spizellomycetales_range_maps_publication_id ON ord_spizellomycetales_range_maps (publication_id); CREATE TABLE ord_spizellomycetales_abundance_estimates ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, estimate_kind TEXT, value_min REAL, value_max REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_spizellomycetales_abundance_estimates_species_id ON ord_spizellomycetales_abundance_estimates (species_id); CREATE INDEX ix_ord_spizellomycetales_abundance_estimates_country_id ON ord_spizellomycetales_abundance_estimates (country_id); CREATE TABLE ord_spizellomycetales_toxin_profiles ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, presence TEXT, typical_concentration_mg_per_kg REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_spizellomycetales_toxin_profiles_species_id ON ord_spizellomycetales_toxin_profiles (species_id); CREATE INDEX ix_ord_spizellomycetales_toxin_profiles_compound_id ON ord_spizellomycetales_toxin_profiles (compound_id); CREATE TABLE ord_spizellomycetales_enzyme_activity_assays ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, enzyme_id INTEGER NOT NULL, strain_id INTEGER, activity_u_per_mg REAL, temperature_c REAL, ph REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (enzyme_id) REFERENCES bio_enzymes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_spizellomycetales_enzyme_activity_assays_species_id ON ord_spizellomycetales_enzyme_activity_assays (species_id); CREATE INDEX ix_ord_spizellomycetales_enzyme_activity_assays_enzyme_id ON ord_spizellomycetales_enzyme_activity_assays (enzyme_id); CREATE TABLE ord_spizellomycetales_biocontrol_evaluations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, target_pest_text TEXT NOT NULL, efficacy_pct REAL, trial_setting TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_spizellomycetales_biocontrol_evaluations_species_id ON ord_spizellomycetales_biocontrol_evaluations (species_id); CREATE INDEX ix_ord_spizellomycetales_biocontrol_evaluations_1 ON ord_spizellomycetales_biocontrol_evaluations (publication_id); CREATE TABLE ord_spizellomycetales_regional_checklists ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, checklist_publication_id INTEGER, status TEXT, checklist_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (checklist_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_spizellomycetales_regional_checklists_species_id ON ord_spizellomycetales_regional_checklists (species_id); CREATE INDEX ix_ord_spizellomycetales_regional_checklists_country_id ON ord_spizellomycetales_regional_checklists (country_id); CREATE TABLE ord_neocallimastigales_morphology ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, hymenium_color_at_maturity TEXT, context_color_at_maturity TEXT, characteristic_microstructure TEXT, diagnostic_features_text TEXT, notes_kohler_reaction TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_neocallimastigales_morphology_specimen_id ON ord_neocallimastigales_morphology (specimen_id); CREATE INDEX ix_ord_neocallimastigales_morphology_species_id ON ord_neocallimastigales_morphology (species_id); CREATE TABLE ord_neocallimastigales_ecology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, dominant_habitat_id INTEGER, dominant_substrate_id INTEGER, dominant_biome_id INTEGER, trophic_strategy TEXT, typical_fruiting_period TEXT, known_distribution_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_habitat_id) REFERENCES eco_habitat_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_substrate_id) REFERENCES eco_substrate_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_biome_id) REFERENCES geo_biomes (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_neocallimastigales_ecology_species_id ON ord_neocallimastigales_ecology (species_id); CREATE INDEX ix_ord_neocallimastigales_ecology_dominant_habitat_id ON ord_neocallimastigales_ecology (dominant_habitat_id); CREATE TABLE ord_neocallimastigales_phenology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, season_name TEXT, region_country_id INTEGER, first_doy INTEGER, peak_doy INTEGER, last_doy INTEGER, years_observed INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_neocallimastigales_phenology_species_id ON ord_neocallimastigales_phenology (species_id); CREATE INDEX ix_ord_neocallimastigales_phenology_region_country_id ON ord_neocallimastigales_phenology (region_country_id); CREATE TABLE ord_neocallimastigales_host_associations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, association_type TEXT, specificity TEXT, evidence_publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (evidence_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_neocallimastigales_host_associations_species_id ON ord_neocallimastigales_host_associations (species_id); CREATE INDEX ix_ord_neocallimastigales_host_associations_host_id ON ord_neocallimastigales_host_associations (host_id); CREATE TABLE ord_neocallimastigales_substrate_preferences ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, substrate_id INTEGER NOT NULL, preference_score REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (substrate_id) REFERENCES eco_substrate_types (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_neocallimastigales_substrate_preferences_species_id ON ord_neocallimastigales_substrate_preferences (species_id); CREATE INDEX ix_ord_neocallimastigales_substrate_preferences_substrate_id ON ord_neocallimastigales_substrate_preferences (substrate_id); CREATE TABLE ord_neocallimastigales_geographic_distribution ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, occurrence_status TEXT, first_record_year INTEGER, record_count INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_neocallimastigales_geographic_distribution_species_id ON ord_neocallimastigales_geographic_distribution (species_id); CREATE INDEX ix_ord_neocallimastigales_geographic_distribution_country_id ON ord_neocallimastigales_geographic_distribution (country_id); CREATE TABLE ord_neocallimastigales_phylogeny ( id INTEGER PRIMARY KEY AUTOINCREMENT, tree_id INTEGER NOT NULL, focal_genus_id INTEGER, publication_id INTEGER, notes_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (tree_id) REFERENCES phy_trees (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_neocallimastigales_phylogeny_tree_id ON ord_neocallimastigales_phylogeny (tree_id); CREATE INDEX ix_ord_neocallimastigales_phylogeny_focal_genus_id ON ord_neocallimastigales_phylogeny (focal_genus_id); CREATE TABLE ord_neocallimastigales_genomics ( id INTEGER PRIMARY KEY AUTOINCREMENT, assembly_id INTEGER NOT NULL, species_id INTEGER, avg_genome_size_mb REAL, avg_gene_count INTEGER, avg_busco_complete_pct REAL, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (assembly_id) REFERENCES gen_assemblies (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_neocallimastigales_genomics_assembly_id ON ord_neocallimastigales_genomics (assembly_id); CREATE INDEX ix_ord_neocallimastigales_genomics_species_id ON ord_neocallimastigales_genomics (species_id); CREATE TABLE ord_neocallimastigales_biochemistry ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, typicality TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_neocallimastigales_biochemistry_species_id ON ord_neocallimastigales_biochemistry (species_id); CREATE INDEX ix_ord_neocallimastigales_biochemistry_compound_id ON ord_neocallimastigales_biochemistry (compound_id); CREATE TABLE ord_neocallimastigales_cultivation_notes ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, typical_growth_rate_mm_per_day REAL, preferred_media_type_id INTEGER, optimal_temperature_c REAL, difficulty_score INTEGER CHECK (difficulty_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (preferred_media_type_id) REFERENCES cul_media_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_neocallimastigales_cultivation_notes_species_id ON ord_neocallimastigales_cultivation_notes (species_id); CREATE INDEX ix_ord_neocallimastigales_cultivation_notes_strain_id ON ord_neocallimastigales_cultivation_notes (strain_id); CREATE TABLE ord_neocallimastigales_pathogenicity ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, disease_id INTEGER, severity_score INTEGER CHECK (severity_score BETWEEN 1 AND 5), publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (disease_id) REFERENCES pat_diseases (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_neocallimastigales_pathogenicity_species_id ON ord_neocallimastigales_pathogenicity (species_id); CREATE INDEX ix_ord_neocallimastigales_pathogenicity_host_id ON ord_neocallimastigales_pathogenicity (host_id); CREATE TABLE ord_neocallimastigales_edibility ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, edibility_class TEXT, preparation_notes TEXT, regional_tradition_country_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (regional_tradition_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_neocallimastigales_edibility_species_id ON ord_neocallimastigales_edibility (species_id); CREATE INDEX ix_ord_neocallimastigales_edibility_1 ON ord_neocallimastigales_edibility (regional_tradition_country_id); CREATE TABLE ord_neocallimastigales_medicinal_uses ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, traditional_use_text TEXT, modern_evidence_level TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_neocallimastigales_medicinal_uses_species_id ON ord_neocallimastigales_medicinal_uses (species_id); CREATE INDEX ix_ord_neocallimastigales_medicinal_uses_publication_id ON ord_neocallimastigales_medicinal_uses (publication_id); CREATE TABLE ord_neocallimastigales_taxonomic_revisions ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER NOT NULL, affected_family_id INTEGER, affected_genus_id INTEGER, revision_summary TEXT, revision_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_family_id) REFERENCES tax_families (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_neocallimastigales_taxonomic_revisions_publication_id ON ord_neocallimastigales_taxonomic_revisions (publication_id); CREATE INDEX ix_ord_neocallimastigales_taxonomic_revisions_1 ON ord_neocallimastigales_taxonomic_revisions (affected_family_id); CREATE TABLE ord_neocallimastigales_conservation_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, national_redlist_category TEXT, habitat_pressure_text TEXT, last_assessment_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_neocallimastigales_conservation_status_species_id ON ord_neocallimastigales_conservation_status (species_id); CREATE INDEX ix_ord_neocallimastigales_conservation_status_country_id ON ord_neocallimastigales_conservation_status (country_id); CREATE TABLE ord_neocallimastigales_diagnostic_keys ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER, key_title TEXT NOT NULL, region_country_id INTEGER, n_taxa_covered INTEGER, key_format TEXT, includes_microscopy INTEGER NOT NULL DEFAULT 0, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_neocallimastigales_diagnostic_keys_publication_id ON ord_neocallimastigales_diagnostic_keys (publication_id); CREATE INDEX ix_ord_neocallimastigales_diagnostic_keys_region_country_id ON ord_neocallimastigales_diagnostic_keys (region_country_id); CREATE TABLE ord_neocallimastigales_type_species_register ( id INTEGER PRIMARY KEY AUTOINCREMENT, focal_genus_id INTEGER NOT NULL, type_species_id INTEGER, designation_publication_id INTEGER, designation_year INTEGER, designated_by_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (designation_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_neocallimastigales_type_species_register_0 ON ord_neocallimastigales_type_species_register (focal_genus_id); CREATE INDEX ix_ord_neocallimastigales_type_species_register_1 ON ord_neocallimastigales_type_species_register (type_species_id); CREATE TABLE ord_neocallimastigales_distribution_grids ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, grid_cell_code TEXT NOT NULL, centroid_lat REAL, centroid_lon REAL, record_count INTEGER, first_record_year INTEGER, most_recent_record_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_neocallimastigales_distribution_grids_species_id ON ord_neocallimastigales_distribution_grids (species_id); CREATE INDEX ix_ord_neocallimastigales_distribution_grids_country_id ON ord_neocallimastigales_distribution_grids (country_id); CREATE TABLE ord_neocallimastigales_microclimate_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER, publication_id INTEGER, substrate_temperature_c REAL, substrate_moisture_pct REAL, canopy_closure_pct REAL, photosynthetic_par_umol_m2_s REAL, days_post_rainfall INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_neocallimastigales_microclimate_studies_species_id ON ord_neocallimastigales_microclimate_studies (species_id); CREATE INDEX ix_ord_neocallimastigales_microclimate_studies_1 ON ord_neocallimastigales_microclimate_studies (publication_id); CREATE TABLE ord_neocallimastigales_dna_barcoding_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, its_sequenced INTEGER NOT NULL DEFAULT 0, lsu_sequenced INTEGER NOT NULL DEFAULT 0, rpb2_sequenced INTEGER NOT NULL DEFAULT 0, ef1a_sequenced INTEGER NOT NULL DEFAULT 0, genome_assembled INTEGER NOT NULL DEFAULT 0, priority_for_sequencing_score INTEGER CHECK (priority_for_sequencing_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_neocallimastigales_dna_barcoding_status_species_id ON ord_neocallimastigales_dna_barcoding_status (species_id); CREATE TABLE ord_neocallimastigales_spore_print_data ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, specimen_id INTEGER, print_color_label TEXT, print_color_chip_id INTEGER, spore_density_per_mm2 REAL, collection_substrate TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (print_color_chip_id) REFERENCES mor_color_chips (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_neocallimastigales_spore_print_data_species_id ON ord_neocallimastigales_spore_print_data (species_id); CREATE INDEX ix_ord_neocallimastigales_spore_print_data_specimen_id ON ord_neocallimastigales_spore_print_data (specimen_id); CREATE TABLE ord_neocallimastigales_mating_systems ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, system_type TEXT, mating_loci_count INTEGER, publication_id INTEGER, notes_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_neocallimastigales_mating_systems_species_id ON ord_neocallimastigales_mating_systems (species_id); CREATE INDEX ix_ord_neocallimastigales_mating_systems_publication_id ON ord_neocallimastigales_mating_systems (publication_id); CREATE TABLE ord_neocallimastigales_nutrient_uptake_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, nitrogen_source TEXT, carbon_source TEXT, growth_response TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_neocallimastigales_nutrient_uptake_studies_species_id ON ord_neocallimastigales_nutrient_uptake_studies (species_id); CREATE INDEX ix_ord_neocallimastigales_nutrient_uptake_studies_strain_id ON ord_neocallimastigales_nutrient_uptake_studies (strain_id); CREATE TABLE ord_neocallimastigales_range_maps ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, polygon_file_uri TEXT NOT NULL, source_methodology TEXT, area_km2 REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_neocallimastigales_range_maps_species_id ON ord_neocallimastigales_range_maps (species_id); CREATE INDEX ix_ord_neocallimastigales_range_maps_publication_id ON ord_neocallimastigales_range_maps (publication_id); CREATE TABLE ord_neocallimastigales_abundance_estimates ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, estimate_kind TEXT, value_min REAL, value_max REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_neocallimastigales_abundance_estimates_species_id ON ord_neocallimastigales_abundance_estimates (species_id); CREATE INDEX ix_ord_neocallimastigales_abundance_estimates_country_id ON ord_neocallimastigales_abundance_estimates (country_id); CREATE TABLE ord_neocallimastigales_toxin_profiles ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, presence TEXT, typical_concentration_mg_per_kg REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_neocallimastigales_toxin_profiles_species_id ON ord_neocallimastigales_toxin_profiles (species_id); CREATE INDEX ix_ord_neocallimastigales_toxin_profiles_compound_id ON ord_neocallimastigales_toxin_profiles (compound_id); CREATE TABLE ord_neocallimastigales_enzyme_activity_assays ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, enzyme_id INTEGER NOT NULL, strain_id INTEGER, activity_u_per_mg REAL, temperature_c REAL, ph REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (enzyme_id) REFERENCES bio_enzymes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_neocallimastigales_enzyme_activity_assays_species_id ON ord_neocallimastigales_enzyme_activity_assays (species_id); CREATE INDEX ix_ord_neocallimastigales_enzyme_activity_assays_enzyme_id ON ord_neocallimastigales_enzyme_activity_assays (enzyme_id); CREATE TABLE ord_neocallimastigales_biocontrol_evaluations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, target_pest_text TEXT NOT NULL, efficacy_pct REAL, trial_setting TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_neocallimastigales_biocontrol_evaluations_species_id ON ord_neocallimastigales_biocontrol_evaluations (species_id); CREATE INDEX ix_ord_neocallimastigales_biocontrol_evaluations_1 ON ord_neocallimastigales_biocontrol_evaluations (publication_id); CREATE TABLE ord_neocallimastigales_regional_checklists ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, checklist_publication_id INTEGER, status TEXT, checklist_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (checklist_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_neocallimastigales_regional_checklists_species_id ON ord_neocallimastigales_regional_checklists (species_id); CREATE INDEX ix_ord_neocallimastigales_regional_checklists_country_id ON ord_neocallimastigales_regional_checklists (country_id); CREATE TABLE ord_microsporidiales_morphology ( id INTEGER PRIMARY KEY AUTOINCREMENT, specimen_id INTEGER NOT NULL, species_id INTEGER, hymenium_color_at_maturity TEXT, context_color_at_maturity TEXT, characteristic_microstructure TEXT, diagnostic_features_text TEXT, notes_kohler_reaction TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_microsporidiales_morphology_specimen_id ON ord_microsporidiales_morphology (specimen_id); CREATE INDEX ix_ord_microsporidiales_morphology_species_id ON ord_microsporidiales_morphology (species_id); CREATE TABLE ord_microsporidiales_ecology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, dominant_habitat_id INTEGER, dominant_substrate_id INTEGER, dominant_biome_id INTEGER, trophic_strategy TEXT, typical_fruiting_period TEXT, known_distribution_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_habitat_id) REFERENCES eco_habitat_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_substrate_id) REFERENCES eco_substrate_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (dominant_biome_id) REFERENCES geo_biomes (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_microsporidiales_ecology_species_id ON ord_microsporidiales_ecology (species_id); CREATE INDEX ix_ord_microsporidiales_ecology_dominant_habitat_id ON ord_microsporidiales_ecology (dominant_habitat_id); CREATE TABLE ord_microsporidiales_phenology ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, season_name TEXT, region_country_id INTEGER, first_doy INTEGER, peak_doy INTEGER, last_doy INTEGER, years_observed INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_microsporidiales_phenology_species_id ON ord_microsporidiales_phenology (species_id); CREATE INDEX ix_ord_microsporidiales_phenology_region_country_id ON ord_microsporidiales_phenology (region_country_id); CREATE TABLE ord_microsporidiales_host_associations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, association_type TEXT, specificity TEXT, evidence_publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (evidence_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_microsporidiales_host_associations_species_id ON ord_microsporidiales_host_associations (species_id); CREATE INDEX ix_ord_microsporidiales_host_associations_host_id ON ord_microsporidiales_host_associations (host_id); CREATE TABLE ord_microsporidiales_substrate_preferences ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, substrate_id INTEGER NOT NULL, preference_score REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (substrate_id) REFERENCES eco_substrate_types (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_microsporidiales_substrate_preferences_species_id ON ord_microsporidiales_substrate_preferences (species_id); CREATE INDEX ix_ord_microsporidiales_substrate_preferences_substrate_id ON ord_microsporidiales_substrate_preferences (substrate_id); CREATE TABLE ord_microsporidiales_geographic_distribution ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, occurrence_status TEXT, first_record_year INTEGER, record_count INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_microsporidiales_geographic_distribution_species_id ON ord_microsporidiales_geographic_distribution (species_id); CREATE INDEX ix_ord_microsporidiales_geographic_distribution_country_id ON ord_microsporidiales_geographic_distribution (country_id); CREATE TABLE ord_microsporidiales_phylogeny ( id INTEGER PRIMARY KEY AUTOINCREMENT, tree_id INTEGER NOT NULL, focal_genus_id INTEGER, publication_id INTEGER, notes_summary TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (tree_id) REFERENCES phy_trees (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_microsporidiales_phylogeny_tree_id ON ord_microsporidiales_phylogeny (tree_id); CREATE INDEX ix_ord_microsporidiales_phylogeny_focal_genus_id ON ord_microsporidiales_phylogeny (focal_genus_id); CREATE TABLE ord_microsporidiales_genomics ( id INTEGER PRIMARY KEY AUTOINCREMENT, assembly_id INTEGER NOT NULL, species_id INTEGER, avg_genome_size_mb REAL, avg_gene_count INTEGER, avg_busco_complete_pct REAL, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (assembly_id) REFERENCES gen_assemblies (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_microsporidiales_genomics_assembly_id ON ord_microsporidiales_genomics (assembly_id); CREATE INDEX ix_ord_microsporidiales_genomics_species_id ON ord_microsporidiales_genomics (species_id); CREATE TABLE ord_microsporidiales_biochemistry ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, typicality TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_microsporidiales_biochemistry_species_id ON ord_microsporidiales_biochemistry (species_id); CREATE INDEX ix_ord_microsporidiales_biochemistry_compound_id ON ord_microsporidiales_biochemistry (compound_id); CREATE TABLE ord_microsporidiales_cultivation_notes ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, typical_growth_rate_mm_per_day REAL, preferred_media_type_id INTEGER, optimal_temperature_c REAL, difficulty_score INTEGER CHECK (difficulty_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (preferred_media_type_id) REFERENCES cul_media_types (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_microsporidiales_cultivation_notes_species_id ON ord_microsporidiales_cultivation_notes (species_id); CREATE INDEX ix_ord_microsporidiales_cultivation_notes_strain_id ON ord_microsporidiales_cultivation_notes (strain_id); CREATE TABLE ord_microsporidiales_pathogenicity ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, host_id INTEGER NOT NULL, disease_id INTEGER, severity_score INTEGER CHECK (severity_score BETWEEN 1 AND 5), publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (host_id) REFERENCES pat_host_organisms (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (disease_id) REFERENCES pat_diseases (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_microsporidiales_pathogenicity_species_id ON ord_microsporidiales_pathogenicity (species_id); CREATE INDEX ix_ord_microsporidiales_pathogenicity_host_id ON ord_microsporidiales_pathogenicity (host_id); CREATE TABLE ord_microsporidiales_edibility ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, edibility_class TEXT, preparation_notes TEXT, regional_tradition_country_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (regional_tradition_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_microsporidiales_edibility_species_id ON ord_microsporidiales_edibility (species_id); CREATE INDEX ix_ord_microsporidiales_edibility_1 ON ord_microsporidiales_edibility (regional_tradition_country_id); CREATE TABLE ord_microsporidiales_medicinal_uses ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, traditional_use_text TEXT, modern_evidence_level TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_microsporidiales_medicinal_uses_species_id ON ord_microsporidiales_medicinal_uses (species_id); CREATE INDEX ix_ord_microsporidiales_medicinal_uses_publication_id ON ord_microsporidiales_medicinal_uses (publication_id); CREATE TABLE ord_microsporidiales_taxonomic_revisions ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER NOT NULL, affected_family_id INTEGER, affected_genus_id INTEGER, revision_summary TEXT, revision_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_family_id) REFERENCES tax_families (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (affected_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_microsporidiales_taxonomic_revisions_publication_id ON ord_microsporidiales_taxonomic_revisions (publication_id); CREATE INDEX ix_ord_microsporidiales_taxonomic_revisions_1 ON ord_microsporidiales_taxonomic_revisions (affected_family_id); CREATE TABLE ord_microsporidiales_conservation_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, national_redlist_category TEXT, habitat_pressure_text TEXT, last_assessment_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_microsporidiales_conservation_status_species_id ON ord_microsporidiales_conservation_status (species_id); CREATE INDEX ix_ord_microsporidiales_conservation_status_country_id ON ord_microsporidiales_conservation_status (country_id); CREATE TABLE ord_microsporidiales_diagnostic_keys ( id INTEGER PRIMARY KEY AUTOINCREMENT, publication_id INTEGER, key_title TEXT NOT NULL, region_country_id INTEGER, n_taxa_covered INTEGER, key_format TEXT, includes_microscopy INTEGER NOT NULL DEFAULT 0, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (region_country_id) REFERENCES geo_countries (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_microsporidiales_diagnostic_keys_publication_id ON ord_microsporidiales_diagnostic_keys (publication_id); CREATE INDEX ix_ord_microsporidiales_diagnostic_keys_region_country_id ON ord_microsporidiales_diagnostic_keys (region_country_id); CREATE TABLE ord_microsporidiales_type_species_register ( id INTEGER PRIMARY KEY AUTOINCREMENT, focal_genus_id INTEGER NOT NULL, type_species_id INTEGER, designation_publication_id INTEGER, designation_year INTEGER, designated_by_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (focal_genus_id) REFERENCES tax_genera (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (type_species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (designation_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_microsporidiales_type_species_register_focal_genus_id ON ord_microsporidiales_type_species_register (focal_genus_id); CREATE INDEX ix_ord_microsporidiales_type_species_register_1 ON ord_microsporidiales_type_species_register (type_species_id); CREATE TABLE ord_microsporidiales_distribution_grids ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, grid_cell_code TEXT NOT NULL, centroid_lat REAL, centroid_lon REAL, record_count INTEGER, first_record_year INTEGER, most_recent_record_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_microsporidiales_distribution_grids_species_id ON ord_microsporidiales_distribution_grids (species_id); CREATE INDEX ix_ord_microsporidiales_distribution_grids_country_id ON ord_microsporidiales_distribution_grids (country_id); CREATE TABLE ord_microsporidiales_microclimate_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER, publication_id INTEGER, substrate_temperature_c REAL, substrate_moisture_pct REAL, canopy_closure_pct REAL, photosynthetic_par_umol_m2_s REAL, days_post_rainfall INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_microsporidiales_microclimate_studies_species_id ON ord_microsporidiales_microclimate_studies (species_id); CREATE INDEX ix_ord_microsporidiales_microclimate_studies_publication_id ON ord_microsporidiales_microclimate_studies (publication_id); CREATE TABLE ord_microsporidiales_dna_barcoding_status ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, its_sequenced INTEGER NOT NULL DEFAULT 0, lsu_sequenced INTEGER NOT NULL DEFAULT 0, rpb2_sequenced INTEGER NOT NULL DEFAULT 0, ef1a_sequenced INTEGER NOT NULL DEFAULT 0, genome_assembled INTEGER NOT NULL DEFAULT 0, priority_for_sequencing_score INTEGER CHECK (priority_for_sequencing_score BETWEEN 1 AND 5), notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_microsporidiales_dna_barcoding_status_species_id ON ord_microsporidiales_dna_barcoding_status (species_id); CREATE TABLE ord_microsporidiales_spore_print_data ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, specimen_id INTEGER, print_color_label TEXT, print_color_chip_id INTEGER, spore_density_per_mm2 REAL, collection_substrate TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (specimen_id) REFERENCES spc_specimens (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (print_color_chip_id) REFERENCES mor_color_chips (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_microsporidiales_spore_print_data_species_id ON ord_microsporidiales_spore_print_data (species_id); CREATE INDEX ix_ord_microsporidiales_spore_print_data_specimen_id ON ord_microsporidiales_spore_print_data (specimen_id); CREATE TABLE ord_microsporidiales_mating_systems ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, system_type TEXT, mating_loci_count INTEGER, publication_id INTEGER, notes_text TEXT, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_microsporidiales_mating_systems_species_id ON ord_microsporidiales_mating_systems (species_id); CREATE INDEX ix_ord_microsporidiales_mating_systems_publication_id ON ord_microsporidiales_mating_systems (publication_id); CREATE TABLE ord_microsporidiales_nutrient_uptake_studies ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, strain_id INTEGER, nitrogen_source TEXT, carbon_source TEXT, growth_response TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_microsporidiales_nutrient_uptake_studies_species_id ON ord_microsporidiales_nutrient_uptake_studies (species_id); CREATE INDEX ix_ord_microsporidiales_nutrient_uptake_studies_strain_id ON ord_microsporidiales_nutrient_uptake_studies (strain_id); CREATE TABLE ord_microsporidiales_range_maps ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, polygon_file_uri TEXT NOT NULL, source_methodology TEXT, area_km2 REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_microsporidiales_range_maps_species_id ON ord_microsporidiales_range_maps (species_id); CREATE INDEX ix_ord_microsporidiales_range_maps_publication_id ON ord_microsporidiales_range_maps (publication_id); CREATE TABLE ord_microsporidiales_abundance_estimates ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER, estimate_kind TEXT, value_min REAL, value_max REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_microsporidiales_abundance_estimates_species_id ON ord_microsporidiales_abundance_estimates (species_id); CREATE INDEX ix_ord_microsporidiales_abundance_estimates_country_id ON ord_microsporidiales_abundance_estimates (country_id); CREATE TABLE ord_microsporidiales_toxin_profiles ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, compound_id INTEGER NOT NULL, presence TEXT, typical_concentration_mg_per_kg REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (compound_id) REFERENCES bio_compounds (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_microsporidiales_toxin_profiles_species_id ON ord_microsporidiales_toxin_profiles (species_id); CREATE INDEX ix_ord_microsporidiales_toxin_profiles_compound_id ON ord_microsporidiales_toxin_profiles (compound_id); CREATE TABLE ord_microsporidiales_enzyme_activity_assays ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, enzyme_id INTEGER NOT NULL, strain_id INTEGER, activity_u_per_mg REAL, temperature_c REAL, ph REAL, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (enzyme_id) REFERENCES bio_enzymes (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (strain_id) REFERENCES cul_strains (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_microsporidiales_enzyme_activity_assays_species_id ON ord_microsporidiales_enzyme_activity_assays (species_id); CREATE INDEX ix_ord_microsporidiales_enzyme_activity_assays_enzyme_id ON ord_microsporidiales_enzyme_activity_assays (enzyme_id); CREATE TABLE ord_microsporidiales_biocontrol_evaluations ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, target_pest_text TEXT NOT NULL, efficacy_pct REAL, trial_setting TEXT, publication_id INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_microsporidiales_biocontrol_evaluations_species_id ON ord_microsporidiales_biocontrol_evaluations (species_id); CREATE INDEX ix_ord_microsporidiales_biocontrol_evaluations_1 ON ord_microsporidiales_biocontrol_evaluations (publication_id); CREATE TABLE ord_microsporidiales_regional_checklists ( id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER NOT NULL, country_id INTEGER NOT NULL, checklist_publication_id INTEGER, status TEXT, checklist_year INTEGER, notes TEXT, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, created_by_user_id INTEGER, updated_by_user_id INTEGER, is_deleted INTEGER NOT NULL DEFAULT 0, row_version INTEGER NOT NULL DEFAULT 1, FOREIGN KEY (species_id) REFERENCES tax_species (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (country_id) REFERENCES geo_countries (id) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (checklist_publication_id) REFERENCES lit_publications (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (created_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (updated_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_ord_microsporidiales_regional_checklists_species_id ON ord_microsporidiales_regional_checklists (species_id); CREATE INDEX ix_ord_microsporidiales_regional_checklists_country_id ON ord_microsporidiales_regional_checklists (country_id); CREATE TABLE tax_species_audit ( audit_id INTEGER PRIMARY KEY AUTOINCREMENT, source_id INTEGER NOT NULL, operation TEXT NOT NULL CHECK (operation IN ('I','U','D')), changed_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, changed_by_user_id INTEGER, old_row TEXT, new_row TEXT, change_reason TEXT, FOREIGN KEY (changed_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_tax_species_audit_source_id ON tax_species_audit (source_id); CREATE INDEX ix_tax_species_audit_changed_at ON tax_species_audit (changed_at); CREATE INDEX ix_tax_species_audit_operation ON tax_species_audit (operation); CREATE TABLE tax_genera_audit ( audit_id INTEGER PRIMARY KEY AUTOINCREMENT, source_id INTEGER NOT NULL, operation TEXT NOT NULL CHECK (operation IN ('I','U','D')), changed_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, changed_by_user_id INTEGER, old_row TEXT, new_row TEXT, change_reason TEXT, FOREIGN KEY (changed_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_tax_genera_audit_source_id ON tax_genera_audit (source_id); CREATE INDEX ix_tax_genera_audit_changed_at ON tax_genera_audit (changed_at); CREATE INDEX ix_tax_genera_audit_operation ON tax_genera_audit (operation); CREATE TABLE tax_families_audit ( audit_id INTEGER PRIMARY KEY AUTOINCREMENT, source_id INTEGER NOT NULL, operation TEXT NOT NULL CHECK (operation IN ('I','U','D')), changed_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, changed_by_user_id INTEGER, old_row TEXT, new_row TEXT, change_reason TEXT, FOREIGN KEY (changed_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_tax_families_audit_source_id ON tax_families_audit (source_id); CREATE INDEX ix_tax_families_audit_changed_at ON tax_families_audit (changed_at); CREATE INDEX ix_tax_families_audit_operation ON tax_families_audit (operation); CREATE TABLE tax_orders_audit ( audit_id INTEGER PRIMARY KEY AUTOINCREMENT, source_id INTEGER NOT NULL, operation TEXT NOT NULL CHECK (operation IN ('I','U','D')), changed_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, changed_by_user_id INTEGER, old_row TEXT, new_row TEXT, change_reason TEXT, FOREIGN KEY (changed_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_tax_orders_audit_source_id ON tax_orders_audit (source_id); CREATE INDEX ix_tax_orders_audit_changed_at ON tax_orders_audit (changed_at); CREATE INDEX ix_tax_orders_audit_operation ON tax_orders_audit (operation); CREATE TABLE tax_classes_audit ( audit_id INTEGER PRIMARY KEY AUTOINCREMENT, source_id INTEGER NOT NULL, operation TEXT NOT NULL CHECK (operation IN ('I','U','D')), changed_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, changed_by_user_id INTEGER, old_row TEXT, new_row TEXT, change_reason TEXT, FOREIGN KEY (changed_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_tax_classes_audit_source_id ON tax_classes_audit (source_id); CREATE INDEX ix_tax_classes_audit_changed_at ON tax_classes_audit (changed_at); CREATE INDEX ix_tax_classes_audit_operation ON tax_classes_audit (operation); CREATE TABLE tax_phyla_audit ( audit_id INTEGER PRIMARY KEY AUTOINCREMENT, source_id INTEGER NOT NULL, operation TEXT NOT NULL CHECK (operation IN ('I','U','D')), changed_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, changed_by_user_id INTEGER, old_row TEXT, new_row TEXT, change_reason TEXT, FOREIGN KEY (changed_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_tax_phyla_audit_source_id ON tax_phyla_audit (source_id); CREATE INDEX ix_tax_phyla_audit_changed_at ON tax_phyla_audit (changed_at); CREATE INDEX ix_tax_phyla_audit_operation ON tax_phyla_audit (operation); CREATE TABLE tax_subspecies_audit ( audit_id INTEGER PRIMARY KEY AUTOINCREMENT, source_id INTEGER NOT NULL, operation TEXT NOT NULL CHECK (operation IN ('I','U','D')), changed_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, changed_by_user_id INTEGER, old_row TEXT, new_row TEXT, change_reason TEXT, FOREIGN KEY (changed_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_tax_subspecies_audit_source_id ON tax_subspecies_audit (source_id); CREATE INDEX ix_tax_subspecies_audit_changed_at ON tax_subspecies_audit (changed_at); CREATE INDEX ix_tax_subspecies_audit_operation ON tax_subspecies_audit (operation); CREATE TABLE tax_varieties_audit ( audit_id INTEGER PRIMARY KEY AUTOINCREMENT, source_id INTEGER NOT NULL, operation TEXT NOT NULL CHECK (operation IN ('I','U','D')), changed_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, changed_by_user_id INTEGER, old_row TEXT, new_row TEXT, change_reason TEXT, FOREIGN KEY (changed_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_tax_varieties_audit_source_id ON tax_varieties_audit (source_id); CREATE INDEX ix_tax_varieties_audit_changed_at ON tax_varieties_audit (changed_at); CREATE INDEX ix_tax_varieties_audit_operation ON tax_varieties_audit (operation); CREATE TABLE tax_forms_audit ( audit_id INTEGER PRIMARY KEY AUTOINCREMENT, source_id INTEGER NOT NULL, operation TEXT NOT NULL CHECK (operation IN ('I','U','D')), changed_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, changed_by_user_id INTEGER, old_row TEXT, new_row TEXT, change_reason TEXT, FOREIGN KEY (changed_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_tax_forms_audit_source_id ON tax_forms_audit (source_id); CREATE INDEX ix_tax_forms_audit_changed_at ON tax_forms_audit (changed_at); CREATE INDEX ix_tax_forms_audit_operation ON tax_forms_audit (operation); CREATE TABLE spc_specimens_audit ( audit_id INTEGER PRIMARY KEY AUTOINCREMENT, source_id INTEGER NOT NULL, operation TEXT NOT NULL CHECK (operation IN ('I','U','D')), changed_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, changed_by_user_id INTEGER, old_row TEXT, new_row TEXT, change_reason TEXT, FOREIGN KEY (changed_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_spc_specimens_audit_source_id ON spc_specimens_audit (source_id); CREATE INDEX ix_spc_specimens_audit_changed_at ON spc_specimens_audit (changed_at); CREATE INDEX ix_spc_specimens_audit_operation ON spc_specimens_audit (operation); CREATE TABLE spc_collection_events_audit ( audit_id INTEGER PRIMARY KEY AUTOINCREMENT, source_id INTEGER NOT NULL, operation TEXT NOT NULL CHECK (operation IN ('I','U','D')), changed_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, changed_by_user_id INTEGER, old_row TEXT, new_row TEXT, change_reason TEXT, FOREIGN KEY (changed_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_spc_collection_events_audit_source_id ON spc_collection_events_audit (source_id); CREATE INDEX ix_spc_collection_events_audit_changed_at ON spc_collection_events_audit (changed_at); CREATE INDEX ix_spc_collection_events_audit_operation ON spc_collection_events_audit (operation); CREATE TABLE spc_loans_audit ( audit_id INTEGER PRIMARY KEY AUTOINCREMENT, source_id INTEGER NOT NULL, operation TEXT NOT NULL CHECK (operation IN ('I','U','D')), changed_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, changed_by_user_id INTEGER, old_row TEXT, new_row TEXT, change_reason TEXT, FOREIGN KEY (changed_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_spc_loans_audit_source_id ON spc_loans_audit (source_id); CREATE INDEX ix_spc_loans_audit_changed_at ON spc_loans_audit (changed_at); CREATE INDEX ix_spc_loans_audit_operation ON spc_loans_audit (operation); CREATE TABLE gen_sequences_audit ( audit_id INTEGER PRIMARY KEY AUTOINCREMENT, source_id INTEGER NOT NULL, operation TEXT NOT NULL CHECK (operation IN ('I','U','D')), changed_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, changed_by_user_id INTEGER, old_row TEXT, new_row TEXT, change_reason TEXT, FOREIGN KEY (changed_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_gen_sequences_audit_source_id ON gen_sequences_audit (source_id); CREATE INDEX ix_gen_sequences_audit_changed_at ON gen_sequences_audit (changed_at); CREATE INDEX ix_gen_sequences_audit_operation ON gen_sequences_audit (operation); CREATE TABLE gen_assemblies_audit ( audit_id INTEGER PRIMARY KEY AUTOINCREMENT, source_id INTEGER NOT NULL, operation TEXT NOT NULL CHECK (operation IN ('I','U','D')), changed_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, changed_by_user_id INTEGER, old_row TEXT, new_row TEXT, change_reason TEXT, FOREIGN KEY (changed_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_gen_assemblies_audit_source_id ON gen_assemblies_audit (source_id); CREATE INDEX ix_gen_assemblies_audit_changed_at ON gen_assemblies_audit (changed_at); CREATE INDEX ix_gen_assemblies_audit_operation ON gen_assemblies_audit (operation); CREATE TABLE gen_dna_extracts_audit ( audit_id INTEGER PRIMARY KEY AUTOINCREMENT, source_id INTEGER NOT NULL, operation TEXT NOT NULL CHECK (operation IN ('I','U','D')), changed_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, changed_by_user_id INTEGER, old_row TEXT, new_row TEXT, change_reason TEXT, FOREIGN KEY (changed_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_gen_dna_extracts_audit_source_id ON gen_dna_extracts_audit (source_id); CREATE INDEX ix_gen_dna_extracts_audit_changed_at ON gen_dna_extracts_audit (changed_at); CREATE INDEX ix_gen_dna_extracts_audit_operation ON gen_dna_extracts_audit (operation); CREATE TABLE phy_trees_audit ( audit_id INTEGER PRIMARY KEY AUTOINCREMENT, source_id INTEGER NOT NULL, operation TEXT NOT NULL CHECK (operation IN ('I','U','D')), changed_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, changed_by_user_id INTEGER, old_row TEXT, new_row TEXT, change_reason TEXT, FOREIGN KEY (changed_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_phy_trees_audit_source_id ON phy_trees_audit (source_id); CREATE INDEX ix_phy_trees_audit_changed_at ON phy_trees_audit (changed_at); CREATE INDEX ix_phy_trees_audit_operation ON phy_trees_audit (operation); CREATE TABLE bio_compounds_audit ( audit_id INTEGER PRIMARY KEY AUTOINCREMENT, source_id INTEGER NOT NULL, operation TEXT NOT NULL CHECK (operation IN ('I','U','D')), changed_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, changed_by_user_id INTEGER, old_row TEXT, new_row TEXT, change_reason TEXT, FOREIGN KEY (changed_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_bio_compounds_audit_source_id ON bio_compounds_audit (source_id); CREATE INDEX ix_bio_compounds_audit_changed_at ON bio_compounds_audit (changed_at); CREATE INDEX ix_bio_compounds_audit_operation ON bio_compounds_audit (operation); CREATE TABLE bio_species_compound_occurrences_audit ( audit_id INTEGER PRIMARY KEY AUTOINCREMENT, source_id INTEGER NOT NULL, operation TEXT NOT NULL CHECK (operation IN ('I','U','D')), changed_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, changed_by_user_id INTEGER, old_row TEXT, new_row TEXT, change_reason TEXT, FOREIGN KEY (changed_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_bio_species_compound_occurrences_audit_source_id ON bio_species_compound_occurrences_audit (source_id); CREATE INDEX ix_bio_species_compound_occurrences_audit_changed_at ON bio_species_compound_occurrences_audit (changed_at); CREATE INDEX ix_bio_species_compound_occurrences_audit_operation ON bio_species_compound_occurrences_audit (operation); CREATE TABLE cul_strains_audit ( audit_id INTEGER PRIMARY KEY AUTOINCREMENT, source_id INTEGER NOT NULL, operation TEXT NOT NULL CHECK (operation IN ('I','U','D')), changed_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, changed_by_user_id INTEGER, old_row TEXT, new_row TEXT, change_reason TEXT, FOREIGN KEY (changed_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_cul_strains_audit_source_id ON cul_strains_audit (source_id); CREATE INDEX ix_cul_strains_audit_changed_at ON cul_strains_audit (changed_at); CREATE INDEX ix_cul_strains_audit_operation ON cul_strains_audit (operation); CREATE TABLE pat_disease_associations_audit ( audit_id INTEGER PRIMARY KEY AUTOINCREMENT, source_id INTEGER NOT NULL, operation TEXT NOT NULL CHECK (operation IN ('I','U','D')), changed_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, changed_by_user_id INTEGER, old_row TEXT, new_row TEXT, change_reason TEXT, FOREIGN KEY (changed_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_pat_disease_associations_audit_source_id ON pat_disease_associations_audit (source_id); CREATE INDEX ix_pat_disease_associations_audit_changed_at ON pat_disease_associations_audit (changed_at); CREATE INDEX ix_pat_disease_associations_audit_operation ON pat_disease_associations_audit (operation); CREATE TABLE pat_clinical_isolates_audit ( audit_id INTEGER PRIMARY KEY AUTOINCREMENT, source_id INTEGER NOT NULL, operation TEXT NOT NULL CHECK (operation IN ('I','U','D')), changed_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, changed_by_user_id INTEGER, old_row TEXT, new_row TEXT, change_reason TEXT, FOREIGN KEY (changed_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_pat_clinical_isolates_audit_source_id ON pat_clinical_isolates_audit (source_id); CREATE INDEX ix_pat_clinical_isolates_audit_changed_at ON pat_clinical_isolates_audit (changed_at); CREATE INDEX ix_pat_clinical_isolates_audit_operation ON pat_clinical_isolates_audit (operation); CREATE TABLE eco_phenology_observations_audit ( audit_id INTEGER PRIMARY KEY AUTOINCREMENT, source_id INTEGER NOT NULL, operation TEXT NOT NULL CHECK (operation IN ('I','U','D')), changed_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, changed_by_user_id INTEGER, old_row TEXT, new_row TEXT, change_reason TEXT, FOREIGN KEY (changed_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_eco_phenology_observations_audit_source_id ON eco_phenology_observations_audit (source_id); CREATE INDEX ix_eco_phenology_observations_audit_changed_at ON eco_phenology_observations_audit (changed_at); CREATE INDEX ix_eco_phenology_observations_audit_operation ON eco_phenology_observations_audit (operation); CREATE TABLE eco_iucn_assessments_audit ( audit_id INTEGER PRIMARY KEY AUTOINCREMENT, source_id INTEGER NOT NULL, operation TEXT NOT NULL CHECK (operation IN ('I','U','D')), changed_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, changed_by_user_id INTEGER, old_row TEXT, new_row TEXT, change_reason TEXT, FOREIGN KEY (changed_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_eco_iucn_assessments_audit_source_id ON eco_iucn_assessments_audit (source_id); CREATE INDEX ix_eco_iucn_assessments_audit_changed_at ON eco_iucn_assessments_audit (changed_at); CREATE INDEX ix_eco_iucn_assessments_audit_operation ON eco_iucn_assessments_audit (operation); CREATE TABLE lic_lichens_audit ( audit_id INTEGER PRIMARY KEY AUTOINCREMENT, source_id INTEGER NOT NULL, operation TEXT NOT NULL CHECK (operation IN ('I','U','D')), changed_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, changed_by_user_id INTEGER, old_row TEXT, new_row TEXT, change_reason TEXT, FOREIGN KEY (changed_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_lic_lichens_audit_source_id ON lic_lichens_audit (source_id); CREATE INDEX ix_lic_lichens_audit_changed_at ON lic_lichens_audit (changed_at); CREATE INDEX ix_lic_lichens_audit_operation ON lic_lichens_audit (operation); CREATE TABLE img_images_audit ( audit_id INTEGER PRIMARY KEY AUTOINCREMENT, source_id INTEGER NOT NULL, operation TEXT NOT NULL CHECK (operation IN ('I','U','D')), changed_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, changed_by_user_id INTEGER, old_row TEXT, new_row TEXT, change_reason TEXT, FOREIGN KEY (changed_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_img_images_audit_source_id ON img_images_audit (source_id); CREATE INDEX ix_img_images_audit_changed_at ON img_images_audit (changed_at); CREATE INDEX ix_img_images_audit_operation ON img_images_audit (operation); CREATE TABLE field_expeditions_audit ( audit_id INTEGER PRIMARY KEY AUTOINCREMENT, source_id INTEGER NOT NULL, operation TEXT NOT NULL CHECK (operation IN ('I','U','D')), changed_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, changed_by_user_id INTEGER, old_row TEXT, new_row TEXT, change_reason TEXT, FOREIGN KEY (changed_by_user_id) REFERENCES sys_users (id) ON DELETE SET NULL ON UPDATE CASCADE ); CREATE INDEX ix_field_expeditions_audit_source_id ON field_expeditions_audit (source_id); CREATE INDEX ix_field_expeditions_audit_changed_at ON field_expeditions_audit (changed_at); CREATE INDEX ix_field_expeditions_audit_operation ON field_expeditions_audit (operation);