Shadowhelix:Datenbank/Umsetzung SQL: Unterschied zwischen den Versionen

Aus Shadowhelix
Zur Navigation springen Zur Suche springen
(+persons, persons_illustration)
Keine Bearbeitungszusammenfassung
Zeile 4: Zeile 4:


<pre>
<pre>
CREATE TABLE sources(
CREATE TABLE source(
id_source      INTEGER(0) NOT NULL
id_source      INTEGER(0) NOT NULL
,description  TEXT NOT NULL
,description  TEXT NOT NULL
Zeile 11: Zeile 11:
);
);


CREATE TABLE sources_catalog(
CREATE TABLE source_catalog(
id_source    INTEGER(0) NOT NULL
id_source    INTEGER(0) NOT NULL
,catalog      TEXT
,catalog      TEXT
Zeile 17: Zeile 17:
);
);


CREATE TABLE sources_translated(
CREATE TABLE source_translated(
id_source            INTEGER(0) NOT NULL
id_source            INTEGER(0) NOT NULL
,id_source_original  INTEGER(0) NOT NULL
,id_source_original  INTEGER(0) NOT NULL
Zeile 23: Zeile 23:
);
);


CREATE TABLE contributors(
CREATE TABLE contributor(
id_contributor  INTEGER(0) NOT NULL
id_contributor  INTEGER(0) NOT NULL
,surname        TEXT NOT NULL
,surname        TEXT NOT NULL
Zeile 35: Zeile 35:
);
);


CREATE TABLE contributors_catalog(
CREATE TABLE contributor_catalog(
id_contributor          INTEGER(0) NOT NULL
id_contributor          INTEGER(0) NOT NULL
,catalog                TEXT
,catalog                TEXT
Zeile 42: Zeile 42:
);
);


CREATE TABLE contributors_referenced_name(
CREATE TABLE contributor_referenced_name(
id_contributor  INTEGER(0) NOT NULL
id_contributor  INTEGER(0) NOT NULL
,referenced_name TEXT NOT NULL
,referenced_name TEXT NOT NULL
);
);


CREATE TABLE contributors_weblink(
CREATE TABLE contributor_weblink(
id_contributor          INTEGER(0) NOT NULL
id_contributor          INTEGER(0) NOT NULL
,url                    TEXT NOT NULL
,url                    TEXT NOT NULL
Zeile 53: Zeile 53:
);
);


CREATE TABLE contributors_weblink_hosting_service(
CREATE TABLE contributor_weblink_hosting_service(
id_contributor          INTEGER(0) NOT NULL
id_contributor          INTEGER(0) NOT NULL
,hosting_service        TEXT NOT NULL
,hosting_service        TEXT NOT NULL
Zeile 60: Zeile 60:
);
);


CREATE TABLE contributions(
CREATE TABLE contribution(
id_contributor      INTEGER(0) NOT NULL
id_contributor      INTEGER(0) NOT NULL
,id_source          INTEGER(0) NOT NULL
,id_source          INTEGER(0) NOT NULL
Zeile 68: Zeile 68:
);
);


CREATE TABLE contributions_illustration(
CREATE TABLE contribution_illustration(
id_contributor INTEGER(0) NOT NULL
id_contributor INTEGER(0) NOT NULL
,id_illustration INTEGER(0)
,id_illustration INTEGER(0)
);
);


CREATE TABLE illustrations_catalog(
CREATE TABLE illustration_catalog(
id_illustration INTEGER(0) NOT NULL
id_illustration INTEGER(0) NOT NULL
,catalog        TEXT
,catalog        TEXT
Zeile 79: Zeile 79:
);
);


CREATE TABLE illustrations_source(
CREATE TABLE illustration_source(
id_illustration  INTEGER(0) NOT NULL
id_illustration  INTEGER(0) NOT NULL
,id_source      INTEGER(0) NOT NULL
,id_source      INTEGER(0) NOT NULL
Zeile 89: Zeile 89:
);
);


CREATE TABLE illustrations_type(
CREATE TABLE illustration_type(
id_illustration INTEGER(0) NOT NULL
id_illustration INTEGER(0) NOT NULL
,type          TEXT NOT NULL
,type          TEXT NOT NULL
);
);


CREATE TABLE illustrations_weblink(
CREATE TABLE illustration_weblink(
id_illustration INTEGER(0) NOT NULL
id_illustration INTEGER(0) NOT NULL
,web_link      TEXT
,web_link      TEXT
Zeile 100: Zeile 100:
);
);


CREATE TABLE corporations_name(
CREATE TABLE corporation_name(
id_corporation INTEGER(0) NOT NULL
id_corporation INTEGER(0) NOT NULL
,language_code TEXT
,language_code TEXT
Zeile 108: Zeile 108:
);
);


CREATE TABLE corporations_ownership(
CREATE TABLE corporation_ownership(
id_corporation        INTEGER(0) NOT NULL
id_corporation        INTEGER(0) NOT NULL
,id_corporation_owner  INTEGER(0)
,id_corporation_owner  INTEGER(0)
Zeile 120: Zeile 120:
);
);


CREATE TABLE products_name(
CREATE TABLE product_name(
id_product    INTEGER(0) NOT NULL
id_product    INTEGER(0) NOT NULL
,language_code TEXT
,language_code TEXT
Zeile 126: Zeile 126:
);
);


CREATE TABLE products_source(
CREATE TABLE product_source(
id_product      INTEGER(0) NOT NULL
id_product      INTEGER(0) NOT NULL
,id_source      INTEGER(0)
,id_source      INTEGER(0)
Zeile 134: Zeile 134:
);
);


CREATE TABLE products_type(
CREATE TABLE product_type(
id_product  INTEGER(0) NOT NULL
id_product  INTEGER(0) NOT NULL
,id_type    INTEGER(0)
,id_type    INTEGER(0)
);
);


CREATE TABLE types(
CREATE TABLE type(
id_type        INTEGER(0) NOT NULL
id_type        INTEGER(0) NOT NULL
,language_code TEXT
,language_code TEXT
Zeile 145: Zeile 145:
);
);


CREATE TABLE persons(
CREATE TABLE person(
id_person    INTEGER(0) NOT NULL
id_person    INTEGER(0) NOT NULL
,description TEXT NOT NULL
,description TEXT NOT NULL
Zeile 151: Zeile 151:
);
);


CREATE TABLE persons_illustration(
CREATE TABLE person_illustration(
id_person        INTEGER(0) NOT NULL
id_person        INTEGER(0) NOT NULL
,id_illustration INTEGER(0) NOT NULL
,id_illustration INTEGER(0) NOT NULL
);
);


CREATE TABLE shadow_matrix_users(
CREATE TABLE shadow_matrix_user(
id_user    INTEGER(0) NOT NULL
id_user    INTEGER(0) NOT NULL
,id_person INTEGER(0)
,id_person INTEGER(0)
Zeile 182: Zeile 182:
<pre>
<pre>
.separator "\t"
.separator "\t"
.import Entwurf_contributors.txt contributors
.import ShxDB_contributor.txt contributor
.import Entwurf_contributors_contributors_catalog.txt contributors_catalog
.import ShxDB_contributor_contributors_catalog.txt contributor_catalog
.import Entwurf_contributors_referenced_name contributors_referenced_name
.import ShxDB_contributor_referenced_name contributor_referenced_name
.import Entwurf_contributors_weblink.txt contributors_weblink
.import ShxDB_contributor_weblink.txt contributor_weblink
.import Entwurf_contributors_weblink_hosting_service.txt contributors_weblink_hosting_service
.import ShxDB_contributor_weblink_hosting_service.txt contributor_weblink_hosting_service
.import Entwurf_sources.txt sources
.import ShxDB_source.txt source
.import Entwurf_sources_catalog.txt sources_catalog
.import ShxDB_source_catalog.txt source_catalog
.import Entwurf_sources_translated.txt sources_translated
.import ShxDB_source_translated.txt source_translated
.import Entwurf_contributions.txt contributions
.import ShxDB_contribution.txt contribution
.import Entwurf_contributions_illustration.txt contributions_illustration
.import ShxDB_contribution_illustration.txt contribution_illustration
.import Entwurf_illustrations_catalog.txt illustrations_catalog
.import ShxDB_illustration_catalog.txt illustration_catalog
.import Entwurf_illustrations_source.txt illustrations_source
.import ShxDB_illustration_source.txt illustration_source
.import Entwurf_illustrations_type.txt illustrations_type
.import ShxDB_illustration_type.txt illustration_type
.import Entwurf_illustrations_weblink.txt illustrations_weblink
.import ShxDB_illustration_weblink.txt illustration_weblink
.import Entwurf_corporations_name.txt corporations_name
.import ShxDB_corporation_name.txt corporation_name
.import Entwurf_corporations_ownership.txt corporations_ownership
.import ShxDB_corporation_ownership.txt corporation_ownership
.import Entwurf_persons.txt persons
.import ShxDB_person.txt person
.import Entwurf_persons_illustration.txt persons_illustration
.import ShxDB_person_illustration.txt person_illustration
.import Entwurf_products_name.txt products_name
.import ShxDB_product_name.txt product_name
.import Entwurf_products_source.txt products_source
.import ShxDB_product_source.txt product_source
.import Entwurf_products_type.txt products_type
.import ShxDB_product_type.txt product_type
.import Entwurf_types.txt types
.import ShxDB_type.txt type
.import Entwurf_shadow_matrix_users.txt shadow_matrix_users
.import ShxDB_shadow_matrix_user.txt shadow_matrix_user
.import Entwurf_shadow_matrix_shadowtalk_source.txt shadow_matrix_shadowtalk_source
.import ShxDB_shadow_matrix_shadowtalk_source.txt shadow_matrix_shadowtalk_source
</pre>
</pre>



Version vom 8. April 2016, 16:58 Uhr

Datenbankstruktur

Skript für Tabellenerstellung:

CREATE TABLE source(
id_source      INTEGER(0) NOT NULL
,description   TEXT NOT NULL
,language_code TEXT NOT NULL
,type          TEXT
);

CREATE TABLE source_catalog(
id_source     INTEGER(0) NOT NULL
,catalog      TEXT
,key          TEXT
);

CREATE TABLE source_translated(
id_source            INTEGER(0) NOT NULL
,id_source_original  INTEGER(0) NOT NULL
,partial_translation TEXT
);

CREATE TABLE contributor(
id_contributor   INTEGER(0) NOT NULL
,surname         TEXT NOT NULL
,surname_suffix  TEXT
,forename_first  TEXT
,forename_second TEXT
,forename_third  TEXT
,year_birth      TEXT
,year_death      TEXT
,sex             CHAR(1)
);

CREATE TABLE contributor_catalog(
id_contributor          INTEGER(0) NOT NULL
,catalog                TEXT
,key                    TEXT
,archive_copy_timestamp INTEGER(0)
);

CREATE TABLE contributor_referenced_name(
id_contributor   INTEGER(0) NOT NULL
,referenced_name TEXT NOT NULL
);

CREATE TABLE contributor_weblink(
id_contributor          INTEGER(0) NOT NULL
,url                    TEXT NOT NULL
,archive_copy_timestamp INTEGER(0)
);

CREATE TABLE contributor_weblink_hosting_service(
id_contributor          INTEGER(0) NOT NULL
,hosting_service        TEXT NOT NULL
,account_name           TEXT NOT NULL
,archive_copy_timestamp INTEGER(0)
);

CREATE TABLE contribution(
id_contributor       INTEGER(0) NOT NULL
,id_source           INTEGER(0) NOT NULL
,standard_descriptor TEXT NOT NULL
,uncredited          CHAR(1)
,title_contribution  TEXT
);

CREATE TABLE contribution_illustration(
id_contributor INTEGER(0) NOT NULL
,id_illustration INTEGER(0)
);

CREATE TABLE illustration_catalog(
id_illustration INTEGER(0) NOT NULL
,catalog        TEXT
,key            TEXT
);

CREATE TABLE illustration_source(
id_illustration  INTEGER(0) NOT NULL
,id_source       INTEGER(0) NOT NULL
,issue           TEXT
,page_reference  TEXT
,entry_reference TEXT
,position        TEXT
,modification    TEXT
);

CREATE TABLE illustration_type(
id_illustration INTEGER(0) NOT NULL
,type           TEXT NOT NULL
);

CREATE TABLE illustration_weblink(
id_illustration INTEGER(0) NOT NULL
,web_link       TEXT
,direct_link    TEXT
);

CREATE TABLE corporation_name(
id_corporation INTEGER(0) NOT NULL
,language_code TEXT
,short_name    TEXT
,full_name     TEXT
,abbreviation  TEXT
);

CREATE TABLE corporation_ownership(
id_corporation         INTEGER(0) NOT NULL
,id_corporation_owner  INTEGER(0)
,id_organisation_owner INTEGER(0)
,id_person_owner       INTEGER(0)
,fraction              TEXT
,from_year             TEXT
,from_month            TEXT
,to_year               TEXT
,to_month              TEXT
);

CREATE TABLE product_name(
id_product     INTEGER(0) NOT NULL
,language_code TEXT
,name          TEXT
);

CREATE TABLE product_source(
id_product       INTEGER(0) NOT NULL
,id_source       INTEGER(0)
,issue           TEXT
,page_reference  TEXT
,entry_reference TEXT
);

CREATE TABLE product_type(
id_product   INTEGER(0) NOT NULL
,id_type     INTEGER(0)
);

CREATE TABLE type(
id_type        INTEGER(0) NOT NULL
,language_code TEXT
,name          TEXT
);

CREATE TABLE person(
id_person    INTEGER(0) NOT NULL
,description TEXT NOT NULL
,sex         TEXT
);

CREATE TABLE person_illustration(
id_person        INTEGER(0) NOT NULL
,id_illustration INTEGER(0) NOT NULL
);

CREATE TABLE shadow_matrix_user(
id_user    INTEGER(0) NOT NULL
,id_person INTEGER(0)
,name      TEXT
);

CREATE TABLE shadow_matrix_shadowtalk_source(
id_user          INTEGER(0) NOT NULL
,id_source       INTEGER(0) NOT NULL
,issue           TEXT
,page_reference  TEXT
,entry_reference TEXT
);

Beispielimplementierung - SQLite

Anleitung - Erstellung der Datenbank

Voraussetzung: SQLite ist installiert.
  • Datenbank-Dateien herunterladen.
  • Obenstehendes Skript in die Datei create_tables.sql kopieren.
  • Import-Skript in die Datei import.sql schreiben. Inhalt (kürzen, falls nicht alle Daten eingefügt werden müssen):
.separator "\t"
.import ShxDB_contributor.txt contributor
.import ShxDB_contributor_contributors_catalog.txt contributor_catalog
.import ShxDB_contributor_referenced_name contributor_referenced_name
.import ShxDB_contributor_weblink.txt contributor_weblink
.import ShxDB_contributor_weblink_hosting_service.txt contributor_weblink_hosting_service
.import ShxDB_source.txt source
.import ShxDB_source_catalog.txt source_catalog
.import ShxDB_source_translated.txt source_translated
.import ShxDB_contribution.txt contribution
.import ShxDB_contribution_illustration.txt contribution_illustration
.import ShxDB_illustration_catalog.txt illustration_catalog
.import ShxDB_illustration_source.txt illustration_source
.import ShxDB_illustration_type.txt illustration_type
.import ShxDB_illustration_weblink.txt illustration_weblink
.import ShxDB_corporation_name.txt corporation_name
.import ShxDB_corporation_ownership.txt corporation_ownership
.import ShxDB_person.txt person
.import ShxDB_person_illustration.txt person_illustration
.import ShxDB_product_name.txt product_name
.import ShxDB_product_source.txt product_source
.import ShxDB_product_type.txt product_type
.import ShxDB_type.txt type
.import ShxDB_shadow_matrix_user.txt shadow_matrix_user
.import ShxDB_shadow_matrix_shadowtalk_source.txt shadow_matrix_shadowtalk_source
  • Alle Dateien in ein Verzeichnis zusammenführen.
  • Neue Datenbank anlegen ggf. systemabhängig aber normalerweise durch Aufruf des SQLite-Kommandos mit Datenbankname, z.B.
> sqlite shx.db
  • In SQlite die Tabellen durch Ausführen von create_tables.sql erstellen.
sqlite> .read create_tables.sql
  • In SQlite den Inhalt der Datenbankdateien durch Ausführen von import.sql in die Tabellen importieren.
sqlite> .read import.sql