scob database system

80
SCOB Database : 1. ORDBMS = Object-Relational DataBase Management System 2. Uses SQL = Structured Query Language 3. Connection with Access (with ODBC) (ODBC = Open DataBase Connectivity)

Upload: others

Post on 20-May-2022

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: SCOB DATABASE SYSTEM

SCOB Database :

1. ORDBMS = Object-Relational DataBaseManagement System2. Uses SQL = Structured Query Language3. Connection with Access (with ODBC)(ODBC = Open DataBase Connectivity)

Page 2: SCOB DATABASE SYSTEM

JDBC & ODBC

• JDBC (Java DataBase Connectivity) (Interface for the Java programming language): provides methods for querying and updating data in a database.

• JDBC is oriented towards relational databases. • ODBC (Open DataBase Connectivity)• JDBC-to-ODBC bridge : enables connections to

any ODBC-accessible data source

Page 3: SCOB DATABASE SYSTEM

First principles

• Entity-Relationship model

• Several (separate) tables• Information can be linked

• Foreign Key• Primary Key

• Temporal data (startdate; enddate)

Page 4: SCOB DATABASE SYSTEM

Table (example)

Page 5: SCOB DATABASE SYSTEM

• CREATE TABLES (with SQL or with theOracle Scheme Manager)

• ADD OTHER TABLES

• ADD COLUMNS TO EXISTING TABLES

Page 6: SCOB DATABASE SYSTEM

With the Oracle Scheme Manager

Page 7: SCOB DATABASE SYSTEM
Page 8: SCOB DATABASE SYSTEM

With SQL ….• CREATE TABLE CORPORATION (• ID NUMBER NOT NULL,• STARTDATE DATE NOT NULL,• ENDDATE DATE NOT NULL,• PRIMARY KEY (ID)• );

• CREATE TABLE CORPORATION_NAME (• CORPORATION NUMBER NOT NULL,• NAME VARCHAR2(250) NOT NULL,• STARTDATE DATE NOT NULL,• ENDDATE DATE NOT NULL,• SOURCE VARCHAR2(500),• COMMENTS VARCHAR2(250),• PRIMARY KEY (CORPORATION,NAME,STARTDATE)• );

Page 9: SCOB DATABASE SYSTEM

… Result: tables

Page 10: SCOB DATABASE SYSTEM

Access Linked (ODBC)

Page 11: SCOB DATABASE SYSTEM

New table …

Page 12: SCOB DATABASE SYSTEM

STOCK_DIVIDEND Table

Page 13: SCOB DATABASE SYSTEM

INPUT of DATA

Page 14: SCOB DATABASE SYSTEM

INPUT of DATA

• MODULAR SYSTEM (with JAVA & SQL)

• SQL• ACCESS

• Excel + IMPORT DATA with « INSERT .. »

Page 15: SCOB DATABASE SYSTEM

Input (1) : SQL

INSERT INTO corporation_juridisch_statuutselect id,1,'1-jan-1000','31-dec-

3999',null,null from corporationminusselect unique corporation,1,'1-jan-1000','31-

dec-3999',null,null fromcorporation_juridisch_statuut

Page 16: SCOB DATABASE SYSTEM

Input (2): MODULAR SYSTEM (I)

Page 17: SCOB DATABASE SYSTEM

Input (2) : Modular System II

Page 18: SCOB DATABASE SYSTEM

JAVA PROGRAMMING

Page 19: SCOB DATABASE SYSTEM

COMPILE the programs INTO JAVA CLASS FILES

Page 20: SCOB DATABASE SYSTEM

Input (3) : Access

Page 21: SCOB DATABASE SYSTEM

Input (4): Import data

• Transform your data from Excel to Access with “File, Get External Data, Import”

• Develop programs to import these data (see “Example” on the next sheet”)

Page 22: SCOB DATABASE SYSTEM

Example• INSERT INTO SCOBALL_PERSON_FUNCTION ( PERSON, JOB,

CORPORATION, STARTDATE, ENDDATE, SOURCE )• SELECT [bestuurders_SCOB].[Person ID], [SCOBALL_JOB].[ID],

[bestuurders_SCOB].[Corporation], [bestuurders_SCOB]![Balans op]-1 AS Expr1, [bestuurders_SCOB].[Balans op], "RF"+Str([bestuurders_SCOB]![RFvan]) AS Expr2

• FROM bestuurders_SCOB, SCOBALL_JOB• WHERE (((SCOBALL_JOB.NAME)=[bestuurders_SCOB]![Fonction]) AND

((Str([bestuurders_SCOB]![PersonID])+Str([SCOBALL_JOB]![ID])+Str([bestuurders_SCOB]![Corporation])+Str([bestuurders_SCOB]![Balans op]-1)+Str([bestuurders_SCOB]![Balans op])) Not In (select Str([SCOBALL_PERSON_FUNCTION]![PERSON])+Str([SCOBALL_PERSON_FUNCTION]![JOB])+Str([SCOBALL_PERSON_FUNCTION]![CORPORATION])+Str([SCOBALL_PERSON_FUNCTION]![STARTDATE])+Str([SCOBALL_PERSON_FUNCTION]![ENDDATE]) from scoball_person_function)));

Page 23: SCOB DATABASE SYSTEM

PRACTICAL SESSION(modular system 1)

(STOCK EXCHANGE DATA)

Page 24: SCOB DATABASE SYSTEM

Putting data in the database(Start with dd/mm/yyyy)

Page 25: SCOB DATABASE SYSTEM

Security Check (!)

Page 26: SCOB DATABASE SYSTEM

NEW LISTINGSand/or

DELISTINGS

Page 27: SCOB DATABASE SYSTEM
Page 28: SCOB DATABASE SYSTEM
Page 29: SCOB DATABASE SYSTEM

Input of Prices … (& Checking)

Page 30: SCOB DATABASE SYSTEM

Add quantities

Page 31: SCOB DATABASE SYSTEM
Page 32: SCOB DATABASE SYSTEM

… and dividends

Page 33: SCOB DATABASE SYSTEM

… and use the right currency !

Page 34: SCOB DATABASE SYSTEM

Currencies refer to the Exchange Rate Table

Page 35: SCOB DATABASE SYSTEM

PRACTICAL SESSION(modular system 2)

(Company data)

Page 36: SCOB DATABASE SYSTEM

Input (2) : Modular System II

Page 37: SCOB DATABASE SYSTEM
Page 38: SCOB DATABASE SYSTEM
Page 39: SCOB DATABASE SYSTEM

Input: Bookkeeping data

Page 40: SCOB DATABASE SYSTEM

Input: Boards of directors …

Page 41: SCOB DATABASE SYSTEM

Input: Ownership

Page 42: SCOB DATABASE SYSTEM

Corporation_stockholders Table

Page 43: SCOB DATABASE SYSTEM

Mergers …

Page 44: SCOB DATABASE SYSTEM

Cartels …

Page 45: SCOB DATABASE SYSTEM

ORIGINALand/or

TRANSFORMEDDATA

Page 46: SCOB DATABASE SYSTEM

WHY

• There are good reasons to keep theoriginal data « as they are »

• At the same time, it can be highly useful to work with transformed data

• E.g. : (historical) bookkeeping data can betransformed in a modern system; stock data can be « manipulated » ….

Page 47: SCOB DATABASE SYSTEM

Transformation (1) : MakeStockInfo

Page 48: SCOB DATABASE SYSTEM

STOCK INFO

• Transforms all dividends (expressed in different currencies) into dividends havingthe same currency as prices

• Calculates capital gains and total returnswhile taking into account stock splits, reverse splits, inscription rights ….

• Selects one out of many prices, quantitiesetc.

Page 49: SCOB DATABASE SYSTEM

« Stock Info » uses information ofthe Stock Splits table

Page 50: SCOB DATABASE SYSTEM

Stock_Info Table

Page 51: SCOB DATABASE SYSTEM

Transformation (2): Bookkeeping data (Original data)

Page 52: SCOB DATABASE SYSTEM

SQL program …

(…)

insert into output_tempselect 20, -sum(amount)from corporation_resultitems, resultitemswhere type=509and corporation=3144and startdate='30-sep-1904'and item=id;

(…)

Page 53: SCOB DATABASE SYSTEM

OUTPUT

Page 54: SCOB DATABASE SYSTEM

OUTPUT (1): SQL

Page 55: SCOB DATABASE SYSTEM

Output (1) : SQL SELECT distinct id, to_char(min(stock_name.startdate),'yyyy-mm-dd') as

DAY,corporation_name.name

FROM stock, stock_name, stock_quantity, stock_corporation, corporation_name

WHERE id=stock_name.stockand id=stock_quantity.stockand id=stock_corporation.stockand stock_corporation.corporation = corporation_name.corporationand quantity = 1000000and sharetype=2

GROUP BY id, corporation_name.name

ORDER BY to_char(min(stock_name.startdate),'yyyy-mm-dd')

Page 56: SCOB DATABASE SYSTEM

Result of this query• ID DAY NAME • ---------- ---------- --------------------------------------------------------------------------------• 24407 1925-05-14 Crédit Communal • 24407 1925-05-14 Dexia (Gemeentekrediet-Holding) • 13465 1932-04-18 STATEN : BELGIE • 24429 1933-07-04 Crédit Communal • 24429 1933-07-04 Dexia (Gemeentekrediet-Holding) • 22456 1937-05-10 Société Nationale des Chemins de fer Belges (SNCB) • 22457 1937-05-10 Société Nationale des Chemins de fer Belges (SNCB) • 13496 1938-11-17 STATEN : BELGIE • 24445 1943-06-15 Société Nationale des Chemins de fer Belges (SNCB) • 24446 1943-06-15 Société Nationale des Chemins de fer Belges (SNCB) • 23520 1952-06-16 Wereldbank (BIRD)• 22583 1967-02-06 Intercom) • 22583 1967-02-06 Société Intercommunale Belge d'Electricite• 22200 2000-09-11 STATEN : BELGIE • 14 rows selected.

Page 57: SCOB DATABASE SYSTEM

Output (2): Modular System II

Page 58: SCOB DATABASE SYSTEM
Page 59: SCOB DATABASE SYSTEM

Output (3) : Modular System (III): Index calculations

Page 60: SCOB DATABASE SYSTEM
Page 61: SCOB DATABASE SYSTEM

Output (4): Modular System IV

Page 62: SCOB DATABASE SYSTEM
Page 63: SCOB DATABASE SYSTEM
Page 64: SCOB DATABASE SYSTEM
Page 65: SCOB DATABASE SYSTEM
Page 66: SCOB DATABASE SYSTEM

Output (5): Modular System V

Page 67: SCOB DATABASE SYSTEM
Page 68: SCOB DATABASE SYSTEM
Page 69: SCOB DATABASE SYSTEM
Page 70: SCOB DATABASE SYSTEM

Output (6) : Matlab, Eviews ….:EXTRACT all the DATA you need

• variable datum char(10);• execute :datum :='31/12/2010';• spool 2010aan• select sc.category, st.corporation,ty.type, sc.stock, no.sector• from stock_category sc, stock_corporation st, category ca, stock_type ty, notation no, stock ss• where sc.stock = st.stock• and sc.stock = ty.stock• and sc.stock = no.stock• and ss.id = st.stock• and st.startdate <=to_date(:datum, 'DD/MM/YYYY') and st.enddate > to_date(:datum, 'DD/MM/YYYY')• and sc.startdate <=to_date(:datum, 'DD/MM/YYYY') and sc.enddate > to_date(:datum, 'DD/MM/YYYY')• and ty.startdate <=to_date(:datum, 'DD/MM/YYYY') and ty.enddate > to_date(:datum, 'DD/MM/YYYY')• and no.startdate <=to_date(:datum, 'DD/MM/YYYY') and no.enddate > to_date(:datum, 'DD/MM/YYYY')• and ty.type < 140• and ca.id = sc.category• and ss.sharetype = 1• and ss.stockexchange = 1• and no.sector > 1• group by sc.stock, sc.category, st.corporation, ty.type, no.sector;• spool OFF;

Page 71: SCOB DATABASE SYSTEM

(..) and use MATLAB …

Page 72: SCOB DATABASE SYSTEM

Eviews …. (or another program)

Page 73: SCOB DATABASE SYSTEM

DATA …

and how to survive them

Page 74: SCOB DATABASE SYSTEM

• Original data: problems of interpretation• Original data: mistakes

• Other information needed: companyname, industry affiliation ….

• There is a lot of information in the original quotation lists

• Document the data !

Page 75: SCOB DATABASE SYSTEM
Page 76: SCOB DATABASE SYSTEM
Page 77: SCOB DATABASE SYSTEM

Document your data …

Page 78: SCOB DATABASE SYSTEM

BACK UPS

Page 79: SCOB DATABASE SYSTEM

SSH (Secure Shell)

Page 80: SCOB DATABASE SYSTEM

Thank you !