Datenbanksysteme 3 Sommer 2003Datenübernahme - 1Worzyk
FH Anhalt
Data Warehouse
Daten übernehmen und vorbereiten
Datenbanksysteme 3 Sommer 2003Datenübernahme - 2Worzyk
FH Anhalt
Datenstrukturim Data Warehouse
• Star - Schema
• Snowflake - Schema
• Starflake - Schema
Datenbanksysteme 3 Sommer 2003Datenübernahme - 3Worzyk
FH Anhalt
Star Schema
Verkaufs-transaktionen
Zeit
Produkte
LieferantenKunde
Ort
FaktenDimensionsdaten
Datenbanksysteme 3 Sommer 2003Datenübernahme - 4Worzyk
FH Anhalt
Snowflake Schema
Verkaufs-transaktionen
Zeit
ProdukteOrt
FaktenSnowflake Dimensionsdaten
Woche
MonatSSV Oster-
verkauf
Region
Art
Farbe
Datenbanksysteme 3 Sommer 2003Datenübernahme - 5Worzyk
FH Anhalt
Starflake Schema
Verkaufs-transaktionen
Zeit
ProdukteOrt
Fakten Snowflake Dimensionsdaten
Woche
MonatSSV Oster-
verkauf
Region
Art
Farbe
Dimensionsdaten
Kunde
OrtZeit
Produkte
Lieferanten
Datenbanksysteme 3 Sommer 2003Datenübernahme - 6Worzyk
FH Anhalt
Oracle Data Mining Architektur
Datenbankz.B.Oracle 8.0.5
Data Warehouse
OracleWarehouse Builder8i 8.1.6 Repository
Net8
OWBClient
DarwinClient
OracleIntelligent WebHouseDarwin
OCI
ODBC
Sun SolarisHP UX
Datenbanksysteme 3 Sommer 2003Datenübernahme - 7Worzyk
FH Anhalt
Beispieldatenbank Quelle
Rechnung
Bestellung Kopf
Bestellung Artikel
Lieferung
Verkäufer
Segment
Zahlungsart
Kalender
R-1
R-2
R-3
R-5
R-6
R-7
Datenbanksysteme 3 Sommer 2003Datenübernahme - 8Worzyk
FH Anhalt
BeispieldatenbankOWB
Datenbanksysteme 3 Sommer 2003Datenübernahme - 9Worzyk
FH Anhalt
Beispieldatenbank Quelle
Datenbanksysteme 3 Sommer 2003Datenübernahme - 10Worzyk
FH Anhalt
Beispieldatenbank Quelle
Datenbanksysteme 3 Sommer 2003Datenübernahme - 11Worzyk
FH Anhalt
Beispieldatenbank Quelle
Datenbanksysteme 3 Sommer 2003Datenübernahme - 12Worzyk
FH Anhalt
Beispieldatenbank Quelle
Datenbanksysteme 3 Sommer 2003Datenübernahme - 13Worzyk
FH Anhalt
Beispieldatenbank Quelle
Datenbanksysteme 3 Sommer 2003Datenübernahme - 14Worzyk
FH Anhalt
Beispieldatenbank Ziel (Warehouse Schema)
Datenbanksysteme 3 Sommer 2003Datenübernahme - 15Worzyk
FH Anhalt
Beispieldatenbank OWBZiel (Faktentabelle)
Datenbanksysteme 3 Sommer 2003Datenübernahme - 16Worzyk
FH Anhalt
Beispieldatenbank OWBZiel (Dimensionen)
Levels und Hierarchien
Beispiel: ZeitH1: YearL->QuarterL->MonthL->WeekL->DayL
H2: YearL->WeekL->DayL
Datenbanksysteme 3 Sommer 2003Datenübernahme - 17Worzyk
FH Anhalt
Beispieldatenbank OWBZiel (Warehouse Schema)
Datenbanksysteme 3 Sommer 2003Datenübernahme - 18Worzyk
FH Anhalt
Beispieldatenbank Ziel (Warehouse Schema)
Datenbanksysteme 3 Sommer 2003Datenübernahme - 19Worzyk
FH Anhalt
Tabellen
ta_probant
probant
aufgaben_nr
ergebnis_1
ergebnis_2
ergebnis_3
ergebnis_4
richtig
datum
ip_adresse
ta_aufgabenaufgaben_nraugfaben_textloesung_1loesung_2loesung_3loesung_4kommentar_1kommentar_2kommentar_3kommentar_4richtige_loesung
ta_mathetest_historiedatumtext
ta_seite1datumip_adresse
Datenbanksysteme 3 Sommer 2003Datenübernahme - 20Worzyk
FH Anhalt
Beispieldatenbank Quelle -> Ziel
channel
product
Datenbanksysteme 3 Sommer 2003Datenübernahme - 21Worzyk
FH Anhalt
BeispielMathetest
• Wie sehen die zeitlichen Verläufe aus• Wie lange braucht der einzelnen Probant
pro Frage• Welche Einträge sind plausibel• Welche Daten der Eltern sind plausibel? • Wie korrelieren die Antworten auf die
Testfragen?
Datenbanksysteme 3 Sommer 2003Datenübernahme - 22Worzyk
FH Anhalt
Rohdaten30.6.196017.4.19571 5 Apr 15 2000 1:28PM
deeeeeeeee5 17 Apr 15 2000 1:29PM
24.03.195126.01.19481 7 Apr 15 2000 1:29PM
00.00.0000.00.0040 10 Apr 17 2000 4:07PM
15.11.195023.01.194814 1 Apr 18 2000 2:41PM
1409530805481 1 Jul 13 2000 4:34PM
29.7´5429.9´523 54 Sep 27 2000 8:20AM
01.01.0001.01.009 54 Sep 27 2000 2:05PM
20.05.195623.03.19531. 54 Oct 26 2000 9:54PM
1.1.19601.1.19601 2 Oct 30 2000 12:29PM
ab0 3 Jan 10 2001 1:46PM
ab0 54 Jan 11 2001 6:57PM
Datenbanksysteme 3 Sommer 2003Datenübernahme - 23Worzyk
FH Anhalt
Import der FaktendatenSybase -> Oracle
1. select – insert
2. dump - restore
Datenbanksysteme 3 Sommer 2003Datenübernahme - 24Worzyk
FH Anhalt
Sybase
Datenbanksysteme 3 Sommer 2003Datenübernahme - 25Worzyk
FH Anhalt
Datenbanksysteme 3 Sommer 2003Datenübernahme - 26Worzyk
FH Anhalt
Datenbanksysteme 3 Sommer 2003Datenübernahme - 27Worzyk
FH Anhalt
Datenbanksysteme 3 Sommer 2003Datenübernahme - 28Worzyk
FH Anhalt
Faktentabelledrop table ta_zeitreihe;
create table ta_zeitreihe(
schluessel number(6) not null,
probant char(24) not null,
aufgaben_nr number(3) not null,
ergebnis_1 number(1) null,
ergebnis_2 number(2) null,
ergebnis_3 number(1) null,
ergebnis_4 number(4) null,
richtig char(1) not null,
datum date null,
ip_adresse char(15) null,
jahrestag char(7) null
);
Datenbanksysteme 3 Sommer 2003Datenübernahme - 29Worzyk
FH Anhalt
select - insertFaktentabelle
select
"insert into ta_zeitreihe values (sq_zeitreihe.nextval,"+"'"
+probant+"',"+convert(char(2),aufgaben_nr)+","
+convert(char(1),isnull(ergebnis_1,0))+","
+convert(char(1),isnull(ergebnis_2,0))+","
+convert(char(1),isnull(ergebnis_3,0))+","
+convert(char(1),isnull(ergebnis_4,0))+",'"+richtig
+"',to_date('"+convert(char(12),datum,104)+convert(char(8),datum,108)
+"','dd.mm.yyyy hh24:mi:ss')"
+",'"+ip_adresse+"');"
from ta_probant
Datenbanksysteme 3 Sommer 2003Datenübernahme - 30Worzyk
FH Anhalt
SQL*LoaderÜbersicht
SQL*Loader
InputDatenfiles
LogFile
LoaderControlFile
BadFile
DiscardFileDaten
bank
Datenbanksysteme 3 Sommer 2003Datenübernahme - 31Worzyk
FH Anhalt
Funktionen von SQL*Loader
• Mehrere Eingabedateien gleichzeitig
• SQL-Funktionen für die Eingabefelder
• Laden mehrerer Tabellen in einem Lauf
• Zusammenfassen mehrerer Zeilen zu einem logischen Datensatz
• Generierung von Schlüsseln
• Eingabe von Platte, Band, named pipes
Datenbanksysteme 3 Sommer 2003Datenübernahme - 32Worzyk
FH Anhalt
Control file
• Enthält– Pfade für Eingabe, Log, fehlerhafte
Datensätze, verworfene Datensätze– Struktur der Eingabedaten– Feldprüfungen– Zieltabellen– Vorschriften zur Fehlerbehandlung
• wird beim Aufruf übergeben
Datenbanksysteme 3 Sommer 2003Datenübernahme - 33Worzyk
FH Anhalt
Control fileBeispiel
LOAD DATA
INFILE 'example.dat'
INTO TABLE emp
(empno POSITION(01:04) INTEGER EXTERNAL,
ename POSITION(06:15) CHAR,
job POSITION(17:25) CHAR,
mgr POSITION(27:30) INTEGER EXTERNAL,
sal POSITION(32:39) DECIMAL EXTERNAL,
comm POSITION(41:48) DECIMAL EXTERNAL,
...
Datenbanksysteme 3 Sommer 2003Datenübernahme - 34Worzyk
FH Anhalt
Control fileBeispiel
LOAD DATA
INFILE *
INTO TABLE DEPT
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
(DEPTNO, DNAME, LOC)
BEGINDATA
12,RESEARCH,"SARATOGA"
10,"ACCOUNTING",CLEVELAND
11,"ART",SALEM
21,"SALES",PHILA.
22,"SALES",ROCHESTER
42,"INT'L","SAN FRAN"
Datenbanksysteme 3 Sommer 2003Datenübernahme - 35Worzyk
FH Anhalt
Control fileBeispiel
load data
infile 'example.dat' "fix 11"
badfile 'example.bad'
discardfile 'example.dsc'
discardmax 999
truncate
into table example
(rown position(1-5), cmnt position(6-10))
Datenbanksysteme 3 Sommer 2003Datenübernahme - 36Worzyk
FH Anhalt
Filtern der Datensätze
Datenbank
Eingabe
SQL*Loader Feldprüfung
SQL*Loader Auswahl
DBMS
BadFile
DiscardFile
Datenbanksysteme 3 Sommer 2003Datenübernahme - 37Worzyk
FH Anhalt
Syntax control file
-- comment
OPTIONS (options)
DATACONTINUE_LOAD
LOAD
infile_clause
READBUFFERS n
INSERTAPPENDREPLACE
Concatenation_clause
BEGINDATAPRESERVE BLANKS
into_table_clause
Datenbanksysteme 3 Sommer 2003Datenübernahme - 38Worzyk
FH Anhalt
Syntax control file
*
INFILE
infile_clause::=
input_filename
BADFILE bad_file_name
DISCARDFILE discard_file_name DISCARDS
DISCARDMAX
n
Datenbanksysteme 3 Sommer 2003Datenübernahme - 39Worzyk
FH Anhalt
Syntax control file
COTINUEIF
concatenation_clause::=
n
(
(n)CONCATENATE
THIS
NEXT
)
pos_spec_operator ‘ char_string‘
Datenbanksysteme 3 Sommer 2003Datenübernahme - 40Worzyk
FH Anhalt
Syntax control file
pos_spec_operator::=
)
:
( start
end
-
=
!=
<>
=
Datenbanksysteme 3 Sommer 2003Datenübernahme - 41Worzyk
FH Anhalt
Syntax control file
field_condition
FIELDS
column_name
INTO TABLE tablenameINSERTAPPENDREPLACE
WHEN
AND
delimiter_spec
(
,
column_spec )
into_table_clause::=
Datenbanksysteme 3 Sommer 2003Datenübernahme - 42Worzyk
FH Anhalt
Syntax control file
delimiter_spec::=termination_spec
enclosure_spec
termination_spec enclosure_spec
OPTIONALLY
TERMINATED
by
WHITESPACE
‘ char‘
ENCLOSED
by
‘ char‘
AND ‘ char‘
Datenbanksysteme 3 Sommer 2003Datenübernahme - 43Worzyk
FH Anhalt
Syntax control file
column_spec::=
POSITION pos_spec datatype_spec
( * )
+n
NULLIF field_condition DEFAULTIF field_condition
“ sql_string“
Datenbanksysteme 3 Sommer 2003Datenübernahme - 44Worzyk
FH Anhalt
Syntax control filedatatype_spec::=
INTEGER
FLOAT
( precision
delimiter_spec
(length)
EXTERNAL
DECIMAL
, scale
)
(length)
EXTERNAL
CHAR
(length)
DATE
(length) “ mask“
Datenbanksysteme 3 Sommer 2003Datenübernahme - 45Worzyk
FH Anhalt
Aufruf des SQL*Loader
SQLLDR80 schlüsselwort=wert [, schlüsselwort=wert ]Gültige Schlüsselworte:
USERID - ORACLE userid/password
CONTROL - controlfile
LOG - logfile
BAD - badfile
DATA - datafile
LOAD - Anzahl der einzulesenden logischen Datensätze
ERRORS - Anzahl der erlaubten Fehler
Datenbanksysteme 3 Sommer 2003Datenübernahme - 46Worzyk
FH Anhalt
Mathetest
Datenbanksysteme 3 Sommer 2003Datenübernahme - 47Worzyk
FH Anhalt
Mathetest Auswertung pro Stunde
select to_char(datum,'hh24'), count(*)from ta_zeitreihegroup by to_char(datum,'hh24')order by to_char(datum,'hh24');
Datenbanksysteme 3 Sommer 2003Datenübernahme - 48Worzyk
FH Anhalt
Mathetest
Datenbanksysteme 3 Sommer 2003Datenübernahme - 49Worzyk
FH Anhalt
Mathetest Auswertung pro Wochentag
select to_char(datum,'day'), count(*),
to_char(datum,'d')
from ta_zeitreihe
group by to_char(datum,'day'),
to_char(datum,'d')
order by to_char(datum,'d');
Datenbanksysteme 3 Sommer 2003Datenübernahme - 50Worzyk
FH Anhalt
Mathetest
Datenbanksysteme 3 Sommer 2003Datenübernahme - 51Worzyk
FH Anhalt
Mathetest
Datenbanksysteme 3 Sommer 2003Datenübernahme - 52Worzyk
FH Anhalt
Mathetest
• Faktentabelle– Alle Einträge der Originaltabelle und zusätzlich ein
eindeutiger Zähler und Tagesnummer
• Dimensionstabelle– Jeder Tag seit Beginn des Tests mit: fortlaufende
Nummer, Tagesnummer, Monat, Jahr, Datum
• Dimensionstabelle– zu jedem Eintrag in der Faktentabelle: Wochentag,
Stunde, Tagesnummer
Datenbanksysteme 3 Sommer 2003Datenübernahme - 53Worzyk
FH Anhalt
Dimensionstabelle TAG DATUM JAHREST MONAT
---------- -------- ------- ----------
1 13.04.00 2000104 4
2 14.04.00 2000105 4
3 15.04.00 2000106 4
4 16.04.00 2000107 4
5 17.04.00 2000108 4
6 18.04.00 2000109 4
7 19.04.00 2000110 4
8 20.04.00 2000111 4
9 21.04.00 2000112 4
10 22.04.00 2000113 4
11 23.04.00 2000114 4
Datenbanksysteme 3 Sommer 2003Datenübernahme - 54Worzyk
FH Anhalt
Datumsfunktionen von Oracle
ADD_MONTHS
Syntax
ADD_MONTHS(d,n)
Purpose
Returns the date d plus n months. The argument n can be any integer. If d is the last day of the month or if the resulting month has fewer days than the day component of d, then the result is the last day of the resulting month.
Otherwise, the result has the same day component as d.
Datenbanksysteme 3 Sommer 2003Datenübernahme - 55Worzyk
FH Anhalt
Datumsfunktionen von Oracle
LAST_DAY
Syntax
LAST_DAY(d)
Purpose
Returns the date of the last day of the month that contains d. You might use this function to determine how many days are left in the current month.
Datenbanksysteme 3 Sommer 2003Datenübernahme - 56Worzyk
FH Anhalt
Datumsfunktionen von OracleNEXT_DAY
Syntax
NEXT_DAY(d, char)
Purpose
Returns the date of the first weekday named by char that is later than the date d. The argument char must be a day of the week in your session's date language-either the full name or the abbreviation. The minimum number of letters required is the number of letters in the abbreviated version; any characters immediately following the valid abbreviation are ignored. The return value has the same hours, minutes, and seconds
component as the argument d.
Datenbanksysteme 3 Sommer 2003Datenübernahme - 57Worzyk
FH Anhalt
Datumsfunktionen von Oracle
ROUND
Syntax
ROUND(d[,fmt])
Purpose
Returns d rounded to the unit specified by the format model fmt. If you omit fmt, d is rounded to the nearest day. See "ROUND and TRUNC" for the permitted format models to use in fmt.
Datenbanksysteme 3 Sommer 2003Datenübernahme - 58Worzyk
FH Anhalt
Datumsformate in Oracle
YYYY 4-stellige J ahreszahlQ QuartalMM Monat 01-12MONTH MonatsnameMON Abkürzung des MonatsnamensWW WochennrIW Wochennr nach ISOW Woche im MonatDDD Tag im J ahr 1-366DD Tag im Monat 1-31D Tag in der WocheDAY TagesnameDY Abkürzung des TagesnamensJ J ulianischer Tag; Tag 1 ist 1. J anuar 4712 vor Chr.HH Tagesstunde 1-12HH24 Tagesstunde 1-24MI MinuteSS Sekunde
Datenbanksysteme 3 Sommer 2003Datenübernahme - 59Worzyk
FH Anhalt
Datumsfunktionen von Sybase
dateadd - adds an interval to a specified date. It takes three arguments-- the datepart, a number, and a date. The result is a datetime value equal to the date plus the number of date parts.
select newpubdate = dateadd(day, 21, pubdate)
from titles
Datenbanksysteme 3 Sommer 2003Datenübernahme - 60Worzyk
FH Anhalt
Datumsfunktionen von Sybase
datediff - calculates the number of date parts between two specified dates. It takes three arguments. The first is a date part. The second and third are dates, either datetime or smalldatetime values. The result is a signed integer value equal to date2 - date1, in date parts.
select newdate = datediff(day, pubdate, getdate())
from titles
Datenbanksysteme 3 Sommer 2003Datenübernahme - 61Worzyk
FH Anhalt
Datumsfunktionen von Sybase
datename - produces the specified datepart (the first argument) of the specified date (the second argument) as a character string. Takes either a datetime or smalldatetime value as its second argument.
select datename(month getdate()) November
Datenbanksysteme 3 Sommer 2003Datenübernahme - 62Worzyk
FH Anhalt
Datumsfunktionen von Sybase
datepart - produces the specified datepart (the first argument) of the specified date (the second argument) as an integer. Takes either a datetime or smalldatetime value as its second argument.
select datepart(month getdate()) 11
Datenbanksysteme 3 Sommer 2003Datenübernahme - 63Worzyk
FH Anhalt
Datenbanksysteme 3 Sommer 2003Datenübernahme - 64Worzyk
FH Anhalt
Datenkonvertierung Sybase
convert (datatype [(length) | (precision[, scale])], expression[, style])
Converts between a wide variety of datatypes and reformats date/time and money data for display purposes.
Datenbanksysteme 3 Sommer 2003Datenübernahme - 65Worzyk
FH Anhalt
Datenbanksysteme 3 Sommer 2003Datenübernahme - 66Worzyk
FH Anhalt
Dimensionstabelle TAG DATUM JAHREST MONAT
---------- -------- ------- ----------
1 13.04.00 2000104 4
2 14.04.00 2000105 4
3 15.04.00 2000106 4
4 16.04.00 2000107 4
5 17.04.00 2000108 4
6 18.04.00 2000109 4
7 19.04.00 2000110 4
8 20.04.00 2000111 4
9 21.04.00 2000112 4
10 22.04.00 2000113 4
11 23.04.00 2000114 4
Datenbanksysteme 3 Sommer 2003Datenübernahme - 67Worzyk
FH Anhalt
Dimensionstabelledrop table ta_Dim_zeit_1;
create table ta_dim_zeit_1(
tag_nr number(3) not null,
Datum date null,
jahrestag char(7),
monat number(2)
);
select to_number(to_char(max(datum),'J'))
- to_number(to_char(min(datum),'J'))+1
from ta_zeitreihe;
insert into ta_dim_zeit_1 (tag_nr)
select schluessel
from ta_zeitreihe
where schluessel <= 382
Datenbanksysteme 3 Sommer 2003Datenübernahme - 68Worzyk
FH Anhalt
Dimensionstabelle
select to_char(min(datum),'J'), min(datum)
from ta_zeitreihe;
update ta_dim_zeit_1
set datum = to_date(to_char(2451647+tag_nr,'9999999'),'J');
update ta_dim_zeit_1
set jahrestag = to_char(datum,'YYYY')||to_char(datum,'ddd'),
monat = to_char(datum,'MM');
Datenbanksysteme 3 Sommer 2003Datenübernahme - 69Worzyk
FH Anhalt
Auswertung pro Tag
select to_char(d1.datum, 'yy.mm.dd'), count(z.schluessel) "Anzahl"
from ta_dim_zeit_1 d1,
ta_zeitreihe z
where d1.jahrestag = z.jahrestag (+)
group by to_char(d1.datum, 'yy.mm.dd'), d1.jahrestag
order by to_char(d1.datum, 'yy.mm.dd');
Datenbanksysteme 3 Sommer 2003Datenübernahme - 70Worzyk
FH Anhalt
Top Related