Git Product home page Git Product logo

Comments (1)

landongyu avatar landongyu commented on June 12, 2024

Polypheny Tutorial

                                                       

0.Introduction

Polypheny is an open source and powerful database with easy-to-use, scalable, and flexible data storage architecture. A key characteristic and unique feature of Polypheny is its ability to seamlessly map between different data models. A key characteristic and unique feature of Polypheny is its ability to seamlessly map between different data models. This enables all data to be queried using all supported query languages - independent of the data model the query language is used. independent of the data model the query language is based on.This will simplify the work of programmers. This tutorial will help you understand the design, working principles and basic usage of polypheny database. This tutorial is based on Windows operating system and Java language.

1.Download and install polypheny

Polypheny supports several operating systems, including Linux, Windows and Mac OS X. Before we start learning polypheny, we need to install polypheny first. Here we take Windows as an example:

Click on the download link below: https://github.com/polypheny/Polypheny-DB/releases/tag/v0.9.1

We can see that polypheny offers several installation packages for your system, you can download them as needed.

Once downloaded we click on the installer to start the installation. If you need to change the installation folder, please select the installation location, otherwise just click next and then click install.

You can find polypheny on your desktop after installation.

2.Start polypheny

Double click to open polypheny, the first startup will do some initialization, it may be slow, please be patient.

The console page will be opened automatically after successful startup. Default address:(http://localhost:8080/#/views/monitoring)

Polypheny's Query Interface for drivers and connectors will occupy port: 20591. Please make sure this port is available, or go to the configuration file to change the default port.

3.Using the Visual Console

The web UI console makes polypheny much easier to use, it no longer requires a visual database connection tool. All your configuration changes, server status, load monitoring, and basic data additions, deletions, and modifications can be done through this webUI.

3.1Load Monitoring

You can clearly see the load of your business operations on the home page for real-time server monitoring and adjustment.

3.2Creating Namespaces and Tables

Polypheny separates tables for different businesses through namespaces, similar to other relational databases' databases. polypheny is powerful in that its namespaces support relational, document, and graph.

After creating the namespace, you can click into the namespace to build a table. Everything is visualized and you don't even need to write any SQL statements.

3.3Add, delete, update and select data

Click on data, we can see the specific data in the table.

Clicking on query, we can get a window to write sql statement to manipulate the data.

3.4Settings
3.4.1You can go through the ui interface to set the port, very convenient.

3.4.2You can set the relevant thread parameters of polypheny

3.4.3Partition Settings

There are other settings, which are not described here, waiting for your exploration.

4.Integration of polypheny in the project (base on Java & JDBC)

Like other databases, polypheny supports connectivity via a JDBC driver. it provides a standard interface for executing SQL queries, retrieving results, and managing database connections.

4.1Building a Java Project

Here's a maven project using Idea to go to build so that you can better manage dependencies.

Ensure that your local JDK version and the choice of the same, there is no need to pursue a high version of the JDK.

The pom file configuration, you need to introduce polypheny-jdbc-driver dependency.

Create a new application class file, the name here can be arbitrary, there needs to be a main function in it.

4.2Connection Code

The following is the complete code, where jdbcurl is pointing to your local polypheny, if your port number is not changed then this parameter does not need to be changed, username is defaulted to 'pa' and password is defaulted to "".

public static void main( String[] args ) {
    String jdbcUrl = "jdbc:polypheny://localhost:20591";
    String username = "pa";
    String password = "";
    try {
        // Load the JDBC driver class
        try {
            Class.forName( "org.polypheny.jdbc.Driver" );
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
        }
        // Establish a connection to the Polypheny database
        Connection connection = DriverManager.getConnection( jdbcUrl, username, password );

        // Create a statement for executing SQL queries
        Statement statement = connection.createStatement();

        // Execute an SQL query
        String sql = "SELECT * FROM emp";
        ResultSet resultSet = statement.executeQuery( sql );

        // Process the query results
        while (resultSet.next()) {
            // Retrieve data from the result set
            int id = resultSet.getInt( "employeeno" );
            String age = resultSet.getString( "age" );
            String gender = resultSet.getString( "gender" );
            String workingyears = resultSet.getString( "workingyears" );
            String relationshipjoy = resultSet.getString( "relationshipjoy" );
            // ...

            // Do something with the data
            System.out.println( "employeeno: " + id + ", age: " + age + ", gender: "
                    + gender+ ", workingyears: " + workingyears+ ", relationshipjoy: " + relationshipjoy);
        }

        // Close the result set, statement, and connection
        resultSet.close();
        statement.close();
        connection.close();
    } catch ( SQLException e ) {
        e.printStackTrace();
    }
}

The code establishes a JDBC connection and queries the emp table for all the data, then takes out the employeeno, age, etc. fields from it.

Through the console printout we see that the data can be queried normally, so we have successfully connected to the polypheny database. This concludes the tutorial on polypheny.

from polypheny-db.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.