Shadowhelix:Datenbank/Umsetzung SQL: Unterschied zwischen den Versionen

Aus Shadowhelix
Zur Navigation springen Zur Suche springen
(Die Seite wurde neu angelegt: „Skript für Tabellenerstellung: <pre> CREATE TABLE sources( id_source INTEGER(0) NOT NULL ,description TEXT NOT NULL ,language_code TEXT NOT NULL ,type…“)
 
Keine Bearbeitungszusammenfassung
Zeile 1: Zeile 1:
__TOC__
==Datenbankstruktur==
Skript für Tabellenerstellung:
Skript für Tabellenerstellung:


Zeile 124: Zeile 126:
);
);
</pre>
</pre>
==Beispielimplementierung - SQLite==
===Anleitung - Erstellung der Datenbank===
:''Voraussetzung: SQLite ist installiert.''
* Obenstehendes Skript in die Datei <tt>create_tables.sql</tt> kopieren.
* Datenbank-Dateien herunterladen.
* Import-Skript schreiben, z.B. <tt>import.sql</tt>. Inhalt:
<pre>
.separator "\t"
.import entwurf_sources.txt sources
.import entwurf_contributors.txt contributors
..
</pre>
* Alle Dateien in ein Verzeichnis zusammenführen.
* Neue Datenbank anlegen ggf. systemabhängig aber normalerweise durch Aufruf des SQLite-Kommandos mit Datenbankname, z.B.
:<tt>> sqlite shx.db</tt>
* In SQlite die Tabellen durch Ausführen von <tt>create_tables.sql</tt> erstellen.
:<tt>sqlite> .read create_tables.sql</tt>
* In SQlite den Inhalt der Datenbankdateien durch Ausführen von <tt>import.sql</tt> in die Tabellen importieren.
:<tt>sqlite> .read import.sql</tt>

Version vom 26. Februar 2016, 11:06 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_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.
  • Obenstehendes Skript in die Datei create_tables.sql kopieren.
  • Datenbank-Dateien herunterladen.
  • Import-Skript schreiben, z.B. import.sql. Inhalt:
.separator "\t"
.import entwurf_sources.txt sources
.import entwurf_contributors.txt contributors
..
  • 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