Skip to content

julianhyde/chinook-data-hsqldb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status Maven Central

chinook-data-hsqldb

Chinook data set in hsqldb format

This project contains the Chinook data set as an embedded HSQLDB database.

It originated as the Chinook database version 1.4, which itself is an alternative to the Northwind database.

Schema

Chinook's schema consists of 11 tables:

Table Row count
Album 347
Artist 275
Customer 59
Employee 8
Genre 25
Invoice 412
InvoiceLine 2,240
MediaType 5
Playlist 18
PlaylistTrack 8,715
Track 3,503

Its size is about 900 KB uncompressed, 160 KB compressed.

Here is a schema diagram:

Chinook schema diagram

Using the data set

The data set is packaged as a jar file that is published to Maven Central as a Maven artifact. To use the data in your Java application, add the artifact to your project's dependencies:

<dependency>
  <groupId>net.hydromatic</groupId>
  <artifactId>chinook-data-hsqldb</artifactId>
  <version>0.2</version>
</dependency>

Now you can connect using Java code:

import java.sql.Connection;
import java.sql.Statement;
import java.sql.ResultSet;

final String url = "jdbc:hsqldb:res:chinook";
final String sql = "select \"EmployeeId\", \"LastName\" from \"Employee\"";
try (Connection c = DriverManager.getConnection(url, "sa", "");
    Statement s = c.createStatement();
    ResultSet r = s.executeQuery(sql)) {
  while (r.next()) {
    System.out.println(r.getInt(1) + ":" + r.getString(2));
  }
}

You can also connect using a JDBC interface such as sqlline. Make sure that chinook-data-hsqldb.jar is on the class path, and start sqlline:

$ ./sqlline
sqlline version 1.12.0
sqlline> !connect jdbc:hsqldb:res:chinook sa ""
0: jdbc:hsqldb:res:chinook> select count(*) from "chinook"."Track";
+----------------------+
|          C1          |
+----------------------+
| 3503                 |
+----------------------+
1 row selected (0.004 seconds)
0: jdbc:hsqldb:res:chinook> !quit

If you use username and password "CHINOOK" and "CHINOOK", the default schema is "chinook", so you can omit the table prefix, if you wish:

$ ./sqlline
sqlline version 1.12.0
sqlline> !connect jdbc:hsqldb:res:chinook CHINOOK CHINOOK
0: jdbc:hsqldb:res:chinook> select count(*) from "Track";
+----------------------+
|          C1          |
+----------------------+
| 3503                 |
+----------------------+
1 row selected (0.004 seconds)
0: jdbc:hsqldb:res:chinook> !quit

Get chinook-data-hsqldb

From Maven

Get chinook-data-hsqldb from Maven Central:

<dependency>
  <groupId>net.hydromatic</groupId>
  <artifactId>chinook-data-hsqldb</artifactId>
  <version>0.2</version>
</dependency>

Download and build

Java version 8 or higher.

$ git clone git://github.com/julianhyde/chinook-data-hsqldb.git
$ cd chinook-data-hsqldb
$ ./mvnw install

On Windows, the last line is

> mvnw install

See also

Similar data sets:

More information

About

Chinook data set in hsqldb format

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages