test_db loads 300,024 dirty employee rows so your checksums have something to prove
A sample MySQL database with an integrated test suite, used to test your applications and database servers
At a glance
- What is it?
- datacharmer/test_db ships the Employees sample dataset as SQL plus a checksum test suite, aimed at anyone who needs a fixed, non-trivial corpus rather than a schema-only fixture. The data is deliberately inconsistent and two of the three integrity scripts no longer run on MySQL 9.6.
- Who is it for?
- Adopt test_db if you need one fixed corpus whose contents every server must reproduce exactly, and if you can pin a client version, since the required flag differs between MySQL client generations. Skip it if your tests need data shaped like your own domain, or if you are on MySQL 9.6 and depend on test_employees_md5.sql or test_employees_sha.sql, because the functions they call no longer exist there.
- Can I use it commercially?
- Not without permission. GitHub finds no licence file in the repository, and without a licence all rights are reserved by default: you may read the code but not reuse it. Check the README, or ask the authors, before using it.
- Is it still maintained?
- Activity is slowing. The repository last received commits 7 months ago.
- What is it written in?
- Mainly PLpgSQL, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on November 14, 2026, and from our analysis. They are not legal advice.
Star history
- datacharmer/test_db4,454 ★ · +13
| Repository | 2026-09-23 | 2026-11-14 |
|---|---|---|
| datacharmer/test_db | 4.4k | 4.5k |
13 Stars in the last 52 days, measured from the daily GitHub snapshot. Compare with other projects
Editorial analysis
The data was generated, so the inconsistencies were left in on purpose
test_db answers a narrow question that many teams end up solving badly: what fixed corpus do we point a database test at? The answer here is a copy of the Employees dataset created by Fusheng Wang and Carlo Zaniolo at Siemens Corporate Research, converted to XML and then exported into relational form. It holds about 300,000 employee records and 2.8 million salary entries, 167 MB on disk, which the project calls heavy enough to be non-trivial for testing.
What makes it useful is what the authors refused to correct. The generated data contains inconsistencies and subtle problems, and rather than clean them the maintainers left the contents untouched and turned them into data cleaning exercises. A team writing an ETL test gets inconsistencies without anyone having to plant them. A team testing aggregation gets a distribution that was never designed to be pretty.
Engineers validating their own code or their own server are the audience here, not application developers looking for a sample app to click through. The six tables are employees, departments, dept_manager, dept_emp, titles and salaries.
The load path is plain SQL text, not a package you install
Installation is a download and a redirect. There is no package on PyPI, no apt package and no Docker image in the repository listing. Top-level entries include employees.sql, a partitioned variant, objects.sql, eight .dump files for bulk loading, the three integrity scripts, a sql_test.sh driver and a test_versions.sh script. Nothing compiles and nothing registers.
The whole procedure is one command. It is run through a user holding the privileges the README lists:
mysql < employees.sqlA second file exists for people who want the two largest tables partitioned:
mysql < employees_partitioned.sqlA 9.x client needs --commands or SOURCE does nothing
Skipping one flag is how a modern client fails quietly. Starting with MySQL 9.5 the SOURCE command requires --commands on the client, and the project calls this out in an important note because MySQL client 9.x changed the default value of that option to FALSE. Without it, the script's SOURCE statements are ignored and you end up with a schema and no rows.
The version boundary appears twice in slightly different words. The MySQL 9.x section says 9.5 is where --commands becomes required, while the important note during installation says client 9.x or later. The wider of the two is the safe assumption.
mysql --commands < employees.sqlPrivileges needed by the connecting user are a fixed list: SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, REFERENCES, INDEX, ALTER, SHOW DATABASES, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE and CREATE VIEW.
The integrity suite asserts fixed row counts and fixed checksums
Verification is where this project earns its keep. Each script compares what is on the server against a hardcoded expectation and prints a table with expected_records and expected_crc next to found_records and found_crc, then a per-table verdict of OK and ok. The checksums are constants in the SQL, not values computed from whatever you just loaded, so the test actually detects a wrong load rather than agreeing with it.
mysql -t < test_employees_sha2.sqlCounts worth memorising: employees 300024, departments 9, dept_manager 24, dept_emp 331603, titles 443308, salaries 2844047. The employees figure is the one that surprises people, since the dataset is described as about 300,000 records and the test asserts a precise 300024.
A sixth file, test_versions.sh, drives the same idea across server versions, and the weekly CI runs using ProxySQL/dbdeployer cover MySQL 5.6, 5.7, 8.0, 8.4, 9.0, 9.2, 9.5 and 9.6, Percona Server 8.0 and 8.4, MariaDB 10.11, 11.4 and 12.1, and PostgreSQL 16 and 17. Row count assertions catch a truncated bulk load, a changed character set or a restore that silently dropped a partition.
MD5() and SHA() were removed in 9.6, so two of the three test files fail
Starting with MySQL 9.6 the MD5() and SHA() functions have been removed from the server. Consequence: test_employees_md5.sql and test_employees_sha.sql do not work on 9.6 or later, which leaves only test_employees_sha2.sql, built on SHA2(..., 256) and compatible with every supported version. The project states that the SHA-256 checksums are identical across all supported MySQL, Percona, MariaDB and PostgreSQL versions, which is what lets one set of expected values work everywhere.
So on a current server you have one integrity script, not three, and if your pipeline pinned the MD5 file you will need to change it. On 8.0 through 9.5 you still have the choice.
One more wrinkle in the file itself. The tested versions table appears twice under two headings of the same name. The first copy lists PostgreSQL 16 and 17; the second drops the PostgreSQL row entirely and ends at MariaDB, and its closing sentence about SHA-256 checksums omits PostgreSQL where the first includes it. Nothing in the repository reconciles the two. Trust the first.
The PostgreSQL port is a directory of differences, not a translation layer
PostgreSQL 12 and later are supported from files under postgresql/, and the schema and data are stated to be identical to the MySQL version. The differences are enumerated rather than implied, and they are the ones that actually bite when porting a routine.
MySQL's ENUM('M','F') becomes CHAR(1) CHECK (gender IN ('M','F')), so anything in your code that relied on the enum's ordinal ordering has to change. The delimiter // syntax for stored procedures is replaced by PostgreSQL dollar-quoting, which changes how you write and how you invoke the routines. If your application reads gender as an integer index, the check constraint gives you a character instead.
A sakila/ directory also sits in the repository listing. It sits next to the Employees schema rather than inside it, so treat anything found there as a separate sample and confirm which one your load script actually references before trusting a checksum.
Against generating your own fixtures, the difference is fixed constants
The common alternative is to write a generator that produces rows from a schema you already own, run it twice and diff the two runs. That approach catches non-determinism but says nothing about whether the data is right, because both runs come from the same code and will agree on the same mistake.
test_db inverts that. The expectations are literals checked into the repository, the load path is SQL text any server can execute, and the assertions are the MySQL functions themselves, so the test doubles as a check that the server evaluates its own hash functions correctly. That inversion has a price. You cannot parameterise the schema, the row counts are the project's rather than your domain's, and 167 MB of data is a fixed cost on every clean run. If your queries need customers, orders or invoices, this corpus tells you nothing about them.
Editorial conclusion
Adopt test_db if you need one fixed corpus whose contents every server must reproduce exactly, and if you can pin a client version, since the required flag differs between MySQL client generations. Skip it if your tests need data shaped like your own domain, or if you are on MySQL 9.6 and depend on test_employees_md5.sql or test_employees_sha.sql, because the functions they call no longer exist there. Before anything else, load the data and run test_employees_sha2.sql, then confirm the salaries row count reads 2844047 and that expected and found checksums agree on all six tables.
Frequently asked questions
What is test_db?
It is the Employees sample database with an integrated test suite, maintained at github.com/datacharmer/test_db and used to test applications and database servers. It ships about 300,000 employee records and 2.8 million salary entries as SQL files you load through the mysql client.
How do I install test_db into MySQL?
Download the repository, change into it and run mysql < employees.sql through a user holding the listed privileges. On MySQL client 9.x or later you must pass --commands or the SOURCE statements are ignored. There is no package to install.
How do I verify the test_db installation succeeded?
Run one of the integrity tests, for example mysql -t < test_employees_sha2.sql, and check that expected and found values match. The expected counts are 300024 employees, 9 departments, 24 dept_manager rows, 331603 dept_emp rows, 443308 titles and 2844047 salaries.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/datacharmer-test-db)Star history chart for your README
[](https://hysenlabs.com/projects/datacharmer-test-db)Was this useful?