1 / 14

Andmelao “päringumootor”

Andmelao “päringumootor”. Janek Press Daniel Skornjakov. Andmelao “päringumootor”. Java Mysql Connector/J Mysql. Andmelao “päringumootor”. Klass “Warehouse” Klass “Engine”. Klass “Warehouse ”. Ühendus Mysql-ga Andmeladu Andmekuup Hierarhiad Päringud. Klass “Warehouse” meetodid.

karik
Download Presentation

Andmelao “päringumootor”

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Andmelao “päringumootor” Janek Press Daniel Skornjakov

  2. Andmelao “päringumootor” • Java • Mysql Connector/J • Mysql

  3. Andmelao “päringumootor” • Klass “Warehouse” • Klass “Engine”

  4. Klass “Warehouse ” • Ühendus Mysql-ga • Andmeladu • Andmekuup • Hierarhiad • Päringud

  5. Klass “Warehouse” meetodid • Ühendus Mysql-ga • public Warehouse(String host, String db, String user, String pass); • public Connection GetConnection() • public void Close() • public boolean IsConnected()

  6. Klass “Warehouse” meetodid • Andmeladu • CreateWarehouse(String name, String[] dims, String[][] hierarchies, String[] measures) • public boolean DropWarehouse(String name)

  7. Klass “Warehouse” meetodid • Andmekuup • public boolean CreateCube(String name, String[] dims, String[] hierarchies, String[] measures • public boolean CreateCube(String name, String[] dims, int[] hierarchies, String[] measures) • public boolean DropCubes(String name)

  8. Klass “Warehouse” meetodid • Hierarhiad • public boolean ResetHierarchies() • public boolean DeleteHierarchy(String base) • public boolean CreateHierarchy(String base, String[] levels) • public String[] GetHierarchy(String base) • public int GetHierarchyCount(String base)

  9. Klass “Warehouse” meetodid • Päringud • private int ExecSQL(String[] commands) • Näide String[] insert = new String[1]; Insert[0] = “INSERT INTO ..”; ExecSql(Insert);

  10. Klass “Engine” • public String[][] ExecuteQuery(String query);

  11. Näide Engine eng = new Engine(new Warehouse(cnfMySQL[0], cnfMySQL[1], cnfMySQL[2], cnfMySQL[3])); eng.GetWarehouse().ResetHierarchies(); String[] dims = { "aeg","asukoht","toode" }; String[][] hierarchies = { { "paev", "nadal", "kuu", "aasta" },{"maakond","linn"},null}; String[] measures = { "summa","kogus" }; eng.GetWarehouse().CreateWarehouse("myyk", dims, hierarchies, measures); eng.GetWarehouse().InsertData("data.txt"); PrintResults(eng.ExecuteQuery("SELECT aeg:nadal,asukoht:linn, summa FROMmyyk;")); PrintResults(eng.ExecuteQuery("SELECT nadal,linn, summa FROM myyk;"));

  12. Näide: tabelid • Myyk (id_aeg,id_asukoht,id_toode,summa,kogus) • Myyk_aeg (id_aeg,paev,nadal,kuu,aasta) • Myyk_asukoht (id_asukoht,maakond,linn) • Myyk_cube_aeg_asukoht (id_aeg,id_asukoht,summa,aggr_count) • Hierarchies (base,element,level)

  13. Näide: “data.txt” • INSERT INTO myyk (id_aeg,id_asukoht,id_toode,summa,kogus) values('1','1','1','1000','1') • INSERT INTO myyk (id_aeg,id_asukoht,id_toode,summa,kogus) values('1','2','1','1050','1') • INSERT INTO myyk (id_aeg,id_asukoht,id_toode,summa,kogus) values('1','2','2','1500','1') • INSERT INTO myyk (id_aeg,id_asukoht,id_toode,summa,kogus) values('1','1','3','1200','1') • INSERT INTO myyk (id_aeg,id_asukoht,id_toode,summa,kogus) values('1','2','4','2000','1') • INSERT INTO myyk (id_aeg,id_asukoht,id_toode,summa,kogus) values('2','1','4','2100','1') • INSERT INTO myyk (id_aeg,id_asukoht,id_toode,summa,kogus) values('3','2','4','1800','1') • INSERT INTO myyk (id_aeg,id_asukoht,id_toode,summa,kogus) values('2','2','2','1400','1') • INSERT INTO myyk (id_aeg,id_asukoht,id_toode,summa,kogus) values('3','1','2','5000','5') • INSERT INTO myyk_toode values('1','Protsessor AMD') • INSERT INTO myyk_toode values('2','Protsessor Intel') • INSERT INTO myyk_toode values('3','Protsessor Celeron') • INSERT INTO myyk_toode values('4','Emaplaat Asus') • INSERT INTO myyk_aeg (id_aeg,paev,nadal,kuu,aasta) values('1','10','2','30','4') • INSERT INTO myyk_aeg (id_aeg,paev,nadal,kuu,aasta) values('2','5','3','40','4') • INSERT INTO myyk_aeg (id_aeg,paev,nadal,kuu,aasta) values('3','10','2','41','4') • INSERT INTO myyk_asukoht values('1','Tartumaa','Tartu') • INSERT INTO myyk_asukoht values('2','Harjumaa','Tallinn')

  14. Päring Sql’le • SELECT myyk_aeg.nadal AS nadal, myyk_asukoht.linn AS linn, SUM(myyk_cube_aeg_asukoht.summa) AS summa FROM myyk_cube_aeg_asukoht,myyk_aeg,myyk_asukoht WHERE myyk_cube_aeg_asukoht.id_aeg=myyk_aeg.id_aeg AND myyk_cube_aeg_asukoht.id_asukoht=myyk_asukoht.id_asukoht GROUP BY myyk_aeg.nadal, myyk_asukoht.linn

More Related