Shadowhelix:Datenbank/Umsetzung SQL: Unterschied zwischen den Versionen

Aus Shadowhelix
Zur Navigation springen Zur Suche springen
Keine Bearbeitungszusammenfassung
(Ergänzung contributors referenced name in Datenbankstruktur)
Zeile 27: Zeile 27:
,year_birth      TEXT
,year_birth      TEXT
,year_death      TEXT
,year_death      TEXT
);
CREATE TABLE contributors_referenced_name(
id_contributor  INTEGER(0) NOT NULL
,referenced_name TEXT NOT NULL
);
);


Zeile 139: Zeile 144:
.separator "\t"
.separator "\t"
.import Entwurf_contributors.txt contributors
.import Entwurf_contributors.txt contributors
.import Entwurf_contributors_referenced_name contributors_referenced_name
.import Entwurf_contributors_weblink.txt contributors_weblink
.import Entwurf_contributors_weblink.txt contributors_weblink
.import Entwurf_sources.txt sources
.import Entwurf_sources.txt sources

Version vom 2. März 2016, 16:57 Uhr

Datenbankstruktur

Skript für Tabellenerstellung:

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

CREATE TABLE sources_catalog(
id_source     INTEGER(0) NOT NULL
,id_drivethru TEXT
,id_amazon    TEXT
,id_rpggeek   TEXT
);

CREATE TABLE contributors(
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
);

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

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

CREATE TABLE contributions(
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 contributions_illustration(
id_contributor INTEGER(0) NOT NULL
,id_illustration INTEGER(0)
);

CREATE TABLE illustrations(
id_illustration INTEGER(0) NOT NULL
,id_constructed TEXT
);

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

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

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

CREATE TABLE corporations_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 products_name(
id_product     INTEGER(0) NOT NULL
,language_code TEXT
,name          TEXT
);

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

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

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

CREATE TABLE shadow_matrix_users(
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 Entwurf_contributors.txt contributors
.import Entwurf_contributors_referenced_name contributors_referenced_name
.import Entwurf_contributors_weblink.txt contributors_weblink
.import Entwurf_sources.txt sources
.import Entwurf_sources_catalog.txt sources_catalog
.import Entwurf_contributions.txt contributions
.import Entwurf_contributions_illustration.txt contributions_illustration
.import Entwurf_illustrations.txt illustrations
.import Entwurf_illustrations_source.txt illustrations_source
.import Entwurf_illustrations_weblink.txt illustrations_weblink
.import Entwurf_corporations_name.txt corporations_name
.import Entwurf_corporations_ownership.txt corporations_ownership
.import Entwurf_products_name.txt products_name
.import Entwurf_products_source.txt products_source
.import Entwurf_products_type.txt products_type
.import Entwurf_types.txt types
.import Entwurf_shadow_matrix_users.txt shadow_matrix_users
.import Entwurf_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