Your SlideShare is downloading. ×
Workshop Matlab BITS Database
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Saving this for later?

Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime - even offline.

Text the download link to your phone

Standard text messaging rates apply

Workshop Matlab BITS Database

931
views

Published on

Matlab Bank of Italy Time Series Database …

Matlab Bank of Italy Time Series Database
Workshop c/o Area Ricerca Banca d'Italia
Villa Huffer
21 Gennaio 2008

Published in: Technology

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
931
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
15
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. WMDB 2008 BITS Time Series Data Base Emmanuele Somma emmanuele.somma@bancaditalia.it Supporto Informatico per l’Area Ricerche Banca d’Italia 21 January 2008 E. Somma (SIA-BdI) WMDB 2008 21/01/2008 1/28
  • 2. Summary 1 tsdb The Time Series Database with Vintage Support Loading Data Getting informations 2 tsdb Administration E. Somma (SIA-BdI) WMDB 2008 21/01/2008 2/28
  • 3. tsdb The Time Series Database with Vintage Support 1 tsdb The Time Series Database with Vintage Support Loading Data Getting informations 2 tsdb Administration E. Somma (SIA-BdI) WMDB 2008 21/01/2008 3/28
  • 4. tsdb Time Series Database Object Single object for all Database operations (tsdb) Very simple command interface Saves data, release date, series name and every metadata you wish Issues (standard) SQL Data Manipulation commands to RDBMS. Issue also Data Definition commands to fully create database instance or grant access to user (db root authorizations required) Fully support free MYSQL database, compatible to other DB (DB2 and Oracle tested). Native access to JDBC drivers (more speed) or ODBC Connectors (more compatibility) E. Somma (SIA-BdI) WMDB 2008 21/01/2008 4/28
  • 5. tsdb Basic Usage >> db = tsdb( database, user, password) >> ts = tsload(db, ’SERIENAME’) >> [...] >> tsstore(db, ts) E. Somma (SIA-BdI) WMDB 2008 21/01/2008 5/28
  • 6. tsdb What is a Release? A RELEASE is a value representing a lapse in time at your wish (i.e. when you downloaded the series). The field containing the release information is named release and is in the columns metadata. Actual TSDB implementation recognize release as MATLAB datenum value. Even the container (tsmat) has a release metadata, it NOT reports the release of the series contained but only the release of the collection instead. The series (column) release is saved into the DB with tstore operation and loaded with tsload whereas collection release is not saved and loaded. Only if isn’t defined a release for a series/column tsstore operation uses collection release as series release. E. Somma (SIA-BdI) WMDB 2008 21/01/2008 6/28
  • 7. tsdb Collection and Series Releases >> E. Somma (SIA-BdI) WMDB 2008 21/01/2008 7/28
  • 8. tsdb Collection and Series Releases >> tstab(ts) E. Somma (SIA-BdI) WMDB 2008 21/01/2008 7/28
  • 9. tsdb Collection and Series Releases >> tstab(ts) tsStart: 1980 1 tsRelease: 25-Jul-2007 Frequency: 12 (monthly) Date T1 T1 T1 T1 17/07/07 18/07/07 19/07/07 20/07/07 1980-M-001 0.6822 0.1509 0.8600 0.4966 1980-M-002 0.3028 0.6979 0.8537 0.8998 1980-M-003 0.5417 0.3784 0.5936 0.8216 E. Somma (SIA-BdI) WMDB 2008 21/01/2008 7/28
  • 10. tsdb Collection and Series Releases >> tstab(ts) tsStart: 1980 1 tsRelease: 25-Jul-2007 COLLECTION RELEASE Frequency: 12 (monthly) Date T1 T1 T1 T1 17/07/07 18/07/07 19/07/07 20/07/07 1980-M-001 0.6822 0.1509 0.8600 0.4966 1980-M-002 0.3028 0.6979 0.8537 0.8998 1980-M-003 0.5417 0.3784 0.5936 0.8216 E. Somma (SIA-BdI) WMDB 2008 21/01/2008 7/28
  • 11. tsdb Collection and Series Releases >> tstab(ts) tsStart: 1980 1 tsRelease: 25-Jul-2007 Frequency: 12 (monthly) Date SERIES RELEASE T1 T1 T1 T1 17/07/07 18/07/07 19/07/07 20/07/07 1980-M-001 0.6822 0.1509 0.8600 0.4966 1980-M-002 0.3028 0.6979 0.8537 0.8998 1980-M-003 0.5417 0.3784 0.5936 0.8216 E. Somma (SIA-BdI) WMDB 2008 21/01/2008 7/28
  • 12. tsdb Using Single and Multiple Parameters Some TSDB operations may be used with a single parameter as well with multiple parameters. Single parameter could be a simple string, numbers or series. Multiple parameters have to be a cell array containing strings, numbers or series. >> ts = tsload(db, ’SERIES’) >> ts = tsload(db, { ’SERIES1’ ’SERIES2’}) >> ts = tsload(db, { ’SERIES1’ ’SERIES2’}, 733283) >> ts = tsload(db, { ’SERIES1’ ’SERIES2’}, {733283 733284}) E. Somma (SIA-BdI) WMDB 2008 21/01/2008 8/28
  • 13. tsdb A complete example Follow instructions to setup free database software on your machine Follow instructions to setup Java connector on your machine Connect as database administrator and create a TSDB instance Connect as BITS user and test installation Play freely Return to work E. Somma (SIA-BdI) WMDB 2008 21/01/2008 9/28
  • 14. tsdb Setup free DBMS (Mysql) Downloads and click on XAMPP.EXE (from file://stux20/pccommon/xampp) Unzip in D:/ Done (Your administrator user is root. No password.) E. Somma (SIA-BdI) WMDB 2008 21/01/2008 10/28
  • 15. tsdb Setup Java Downloads mysql-connector-java-5.0.6-bin.jar (from file://stux20/pccommon/xampp) Save in D:/xampp/mysql/ >> javaaddpath D:/xampp/mysql >> clear java E. Somma (SIA-BdI) WMDB 2008 21/01/2008 11/28
  • 16. tsdb DEMO: Create demo database From Matlab prompt issue the commands: >> dbROOT = tsdb(’J:mysql’,’root’,’’) >> tsdbdemo(dbROOT,’create’) >> close(dbROOT) E. Somma (SIA-BdI) WMDB 2008 21/01/2008 12/28
  • 17. tsdb DEMO: Check database >> db = tsdb(’J:bitsdemo’,’BITS’,’’) BITSDB Database bitsdemo (ver. 1.0) User: BITS On Host: localhost Backup Dir: C:Documents[...]h856605Application DataBITSDB Driver: jdbc:mysql://localhost/bitsdemo >> namelist=tsseries(db) namelist = ’ITRETTOTF’ ’ITIPINTMG’ ’BDESPISDH’ ’BDEU2001A’ ’BDM3C...B’ ’FRHCONMGD’ ’EAGDP...D’ ’ITGDP...D’ OK. Database ’bitsdemo’ is up and running. E. Somma (SIA-BdI) WMDB 2008 21/01/2008 13/28
  • 18. Loading Data 1 tsdb The Time Series Database with Vintage Support Loading Data Getting informations 2 tsdb Administration E. Somma (SIA-BdI) WMDB 2008 21/01/2008 14/28
  • 19. tsdb DEMO: Loading Data >> [ tsM, tsA ] = tsload(db,namelist) tsM = matdata: [258x6 double] start_year: 1986 [...] Size: [258 6] Start: 1986 1 End: 2007 6 Labels: ITRETTOTF ITIPINTMG BDESPISDH BDEU2001A BDM3C...B tsA = matdata: [89x2 double] start_year: 1985 [...] Size: [89 2] Start: 1985 1 End: 2007 1 Labels: EAGDP...D ITGDP...D E. Somma (SIA-BdI) WMDB 2008 21/01/2008 15/28
  • 20. tsdb DEMO: Loading Data/2 >> tstab(tsM) tsStart: 1986 1 tsRelease: 19-Jul-2007 Frequency: 12 (monthly) Date ITRETTOTF ITIPINTMG BDESPISDH BDEU2001A 12/07/07 12/07/07 12/07/07 12/07/07 1986-M-001 39.1000 78.8519 82.3500 22398.1600 1986-M-002 35.7600 79.5136 95.3100 21864.3700 1986-M-003 42.5700 79.4736 101.4700 22359.8200 1986-M-004 41.1700 79.2002 96.9700 25555.3900 [...] 2007-M-004 106.6000 95.8000 91.1000 78810.0000 2007-M-005 NaN 96.6000 91.3000 79077.0000 2007-M-006 NaN NaN NaN NaN E. Somma (SIA-BdI) WMDB 2008 21/01/2008 16/28
  • 21. tsdb DEMO: Loading Data/2 >> tstab(tsM) tsStart: 1986 1 tsRelease: 19-Jul-2007 Frequency: 12 (monthly) Date ITRETTOTF ITIPINTMG BDESPISDH BDEU2001A 12/07/07 12/07/07 12/07/07 12/07/07 1986-M-001 39.1000 78.8519 82.3500 22398.1600 1986-M-002 35.7600 79.5136 95.3100 21864.3700 1986-M-003 42.5700 79.4736 101.4700 22359.8200 1986-M-004 41.1700 79.2002 96.9700 25555.3900 [...] 2007-M-004 106.6000 95.8000 91.1000 78810.0000 2007-M-005 NaN 96.6000 91.3000 79077.0000 2007-M-006 NaN NaN NaN NaN E. Somma (SIA-BdI) WMDB 2008 21/01/2008 16/28
  • 22. tsdb DEMO: Loading Releases >> r = tsreleases(db,’BDESPISDH’); >> ts = tsload(db,’BDESPISDH’,r) ts = matdata: [258x25 double] [...] Size: [258 25] Start: 1986 1 End: 2007 6 Labels: BDESPISDH BDESPISDH ... E. Somma (SIA-BdI) WMDB 2008 21/01/2008 17/28
  • 23. tsdb DEMO: Loading Data/2 >> tstab(ts) tsStart: 1986 1 tsRelease: 06-Sep-2007 Frequency: 12 (monthly) Date BDESPISDH BDESPISDH BDESPISDH 28/02/07 08/03/07 09/03/07 1986-M-001 82.3500 82.3500 82.3500 1986-M-002 95.3100 95.3100 95.3100 1986-M-003 101.4700 101.4700 101.4700 [...] 2006-M-012 89.3000 89.3000 91.6000 2007-M-001 NaN NaN 91.2000 2007-M-002 NaN NaN NaN 2007-M-003 NaN NaN NaN E. Somma (SIA-BdI) WMDB 2008 21/01/2008 18/28
  • 24. Getting informations 1 tsdb The Time Series Database with Vintage Support Loading Data Getting informations 2 tsdb Administration E. Somma (SIA-BdI) WMDB 2008 21/01/2008 19/28
  • 25. tsinfo res = tsinfo(db,series,[operation, [arg, ... ] ] ...) op result = res{#idx} E. Somma (SIA-BdI) WMDB 2008 21/01/2008 20/28
  • 26. tsinfo res = tsinfo(db,series,[operation, [arg, ... ] ] ...) op result = res{#idx} == NSERIES - Number of series in DB == >> res = tsinfo(db, nan, ’nseries’) >> nseries = res{2} E. Somma (SIA-BdI) WMDB 2008 21/01/2008 20/28
  • 27. tsinfo res = tsinfo(db,series,[operation, [arg, ... ] ] ...) op result = res{#idx} == SERIES - Names of the series in DB == >> series = tsinfo(db,nan, ’series’) E. Somma (SIA-BdI) WMDB 2008 21/01/2008 20/28
  • 28. tsinfo res = tsinfo(db,series,[operation, [arg, ... ] ] ...) op result = res{#idx} == NRELEASES - Number of releases in series == >> res = tsinfo(db, {series}, ’nreleases’) >> nrels = res{1,1} >> nerls_serie1 = nrels{1} E. Somma (SIA-BdI) WMDB 2008 21/01/2008 20/28
  • 29. tsinfo res = tsinfo(db,series,[operation, [arg, ... ] ] ...) op result = res{#idx} == RELEASES - Set of release dates for a given series == >> rels = tsinfo(db, {series}, ’releases’) >> rels_serie1 = rels{1} E. Somma (SIA-BdI) WMDB 2008 21/01/2008 20/28
  • 30. tsinfo res = tsinfo(db,series,[operation, [arg, ... ] ] ...) op result = res{#idx} == ORDERBYFREQ - returns series ordered by frequency == >> [ordered, freqs] = tsinfo(db, {series}, ’orderbyfreq’) E. Somma (SIA-BdI) WMDB 2008 21/01/2008 20/28
  • 31. Connection status >> ping(db) DatabaseProductName: ’MySQL’ DatabaseProductVersion: ’5.0.41-community-nt’ JDBCDriverName: ’MySQL-AB JDBC Driver’ JDBCDriverVersion: [1x103 char] MaxDatabaseConnections: 0 CurrentUserName: ’BITS@localhost’ DatabaseURL: ’jdbc:mysql://localhost/bitsdemo’ AutoCommitTransactions: ’True’ E. Somma (SIA-BdI) WMDB 2008 21/01/2008 21/28
  • 32. Connection status >>isconnection(db) ans = 1 E. Somma (SIA-BdI) WMDB 2008 21/01/2008 21/28
  • 33. tsdb Administration 1 tsdb The Time Series Database with Vintage Support Loading Data Getting informations 2 tsdb Administration E. Somma (SIA-BdI) WMDB 2008 21/01/2008 22/28
  • 34. tsadmin(dbROOT,’setup’,...) Create USER if doesn’t exists. Requests password interactively or use empty password if DBNAME begins with ’*’ Create database bits<DBNAME> Setup TSDB structure in ’bits<DBNAME>’ Example: >> tsadmin(dbROOT,’setup’, ’BITS’,’test’) >> tsadmin(dbROOT,’setup’,’*BITS’,’test’) E. Somma (SIA-BdI) WMDB 2008 21/01/2008 23/28
  • 35. tsadmin(dbROOT,’drop’,DBNAME) Prerequisite: Administrator account/password (root/’’) Operations: Expunge db instance Needs interactive confirmation Unless variable ’force’ is defined in work area Example: >> dbROOT = tsdb(’J:mysql’,’root’,’’); >> tsadmin(db,’drop’,’bitstest’); E. Somma (SIA-BdI) WMDB 2008 21/01/2008 24/28
  • 36. tsadmin(db,’trunc’) Prerequisite: User account/password (BITS/’’) Operations: Clean all db tables contents Needs interactive confirmation Unless variable ’force’ is defined in work area Example: >> db = tsdb(’J:bitsdemo’,’BITS’); >> tsadmin(db,’trunc’); E. Somma (SIA-BdI) WMDB 2008 21/01/2008 25/28
  • 37. Backup/Restore operations Backup/restore operations save/load data in BACKUPDIR Save full time-series database, you can use fullbackup. >> tsadmin(db,’fullbackup’,LABEL); It save a text file named where <date> is today date in ’dd-Mmm-yyyy’ format. Save all releases of a single series, use tsbackup. >> tsadmin(db,’tsbackup’,LABEL); It save a matlab .mat file named <SERIENAME> <date> <LABEL>.mat where <date> is today date in ’dd-Mmm-yyyy’ format. Operations: Clean all db tables contents Needs interactive confirmation Unless variable ’force’ is defined in work area Example: >> db = tsdb(’J:bitsdemo’,’BITS’); >> tsadmin(db,’trunc’); E. Somma (SIA-BdI) WMDB 2008 21/01/2008 26/28
  • 38. tsadmin(db,’rm’, { series }) Prerequisite: User account/password (BITS/’’) Operations: Deletes time-series and (part of) his history from db Example: >> db = tsdb(’J:bitsdemo’,’BITS’); >> tsadmin(db,’rm’, ’BDESPISDH’); >> tsadmin(db,’rm’, ’BDESPISDH’, {datenum(’28/02/2007’)}); E. Somma (SIA-BdI) WMDB 2008 21/01/2008 27/28
  • 39. tsadmin(db,’cp/mv, { series }, db2) Prerequisite: User account/password (BITS/’’) on db1 and db2 Operations: Copies or Moves a time-series and (part of) his history from one db to another Example: >> db = tsdb(’J:bitsdemo’,’BITS’); >> db2 = tsdb(’J:bitsdemo2’,’BITS’); >> tsadmin(db,’cp’, ’BDESPISDH’, db2); >> tsadmin(db,’mv’, ’BDESPISDH’, db2); E. Somma (SIA-BdI) WMDB 2008 21/01/2008 28/28
  • 40. Grazie dell’attenzione E. Somma (SIA-BdI) WMDB 2008 21/01/2008 29/28