forked from datacharmer/test_db
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
851dee3
commit 5cd6371
Showing
17 changed files
with
1,017 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
1.0.7 2015-08-30 | ||
- Moved to GitHub | ||
- Fixed bug#393423 Duplicate key in dept_manager | ||
- Fixed bug#393429 Column order in employees.dept_manager is incorrect | ||
- Adapted partitioned structure to MySQL 5.5+ syntax | ||
1.0.6 2009-03-29 | ||
- fixed bug#320513 - employees with same start date are counted twice | ||
1.0.5 2008-08-02 | ||
- removed comment for FK in employees.sql | ||
- added some database objects (views, stored procedures and functions) | ||
1.0.4 2008-07-26 | ||
- fixed bug in test_employees | ||
- added partitioning to employees.sql (saved as employees_partitioned.sql) | ||
1.0.3 2008-07-19 | ||
- adapted for testing on MD5 or SHA1 (two separated test files) | ||
- removed views and table changelog | ||
1.0.2 2008-03-15 | ||
- Added support for PBXT - replaced LOAD DATA with SQL dumps | ||
1.0.1 2008-01-04 | ||
- Adapted code to run on 4.1 | ||
1.0.0 2008-01-03 | ||
- Based on a work by Fusheng Wang and Carlo Zaniolo | ||
- modified by Giuseppe Maxia and Patrick Crews | ||
- Initial release | ||
- no known bugs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,105 @@ | ||
# test_db | ||
a sample database with an integrated test suite, used to test your applications and database servers | ||
A sample database with an integrated test suite, used to test your applications and database servers | ||
|
||
This repository was migrated from [Launchpad](https://launchpad.net/test-db). | ||
|
||
See usage in the [MySQL docs](https://dev.mysql.com/doc/employee/en/index.html) | ||
|
||
|
||
## Where it comes from | ||
|
||
The original data was created by Fusheng Wang and Carlo Zaniolo at | ||
Siemens Corporate Research. The data is in XML format. | ||
http://www.cs.aau.dk/TimeCenter/software.htm | ||
http://www.cs.aau.dk/TimeCenter/Data/employeeTemporalDataSet.zip | ||
|
||
Giuseppe Maxia made the relational schema and Patrick Crews exported | ||
the data in relational format. | ||
|
||
The database contains about 300,000 employee records with 2.8 million | ||
salary entries. The export data is 167 MB, which is not huge, but | ||
heavy enough to be non-trivial for testing. | ||
|
||
The data was generated, and as such there are inconsistencies and subtle | ||
problems. Rather than removing them, we decided to leave the contents | ||
untouched, and use these issues as data cleaning exercises. | ||
|
||
|
||
## Installation: | ||
|
||
1. Download the repository | ||
2. Change directory to the repository | ||
3. run | ||
|
||
mysql < employees.sql | ||
|
||
|
||
If you want to install with two large partitioned tables, run | ||
|
||
mysql < employees_partitioned.sql | ||
|
||
|
||
## Testing the installation | ||
|
||
After installing, you can run one of the following | ||
|
||
mysql -t < test_employees_md5.sql | ||
# OR | ||
mysql -t < test_employees_sha.sql | ||
|
||
For example: | ||
|
||
mysql -t < test_employees_md5.sql | ||
+----------------------+ | ||
| INFO | | ||
+----------------------+ | ||
| TESTING INSTALLATION | | ||
+----------------------+ | ||
+--------------+------------------+----------------------------------+ | ||
| table_name | expected_records | expected_crc | | ||
+--------------+------------------+----------------------------------+ | ||
| employees | 300024 | 4ec56ab5ba37218d187cf6ab09ce1aa1 | | ||
| departments | 9 | d1af5e170d2d1591d776d5638d71fc5f | | ||
| dept_manager | 24 | 8720e2f0853ac9096b689c14664f847e | | ||
| dept_emp | 331603 | ccf6fe516f990bdaa49713fc478701b7 | | ||
| titles | 443308 | bfa016c472df68e70a03facafa1bc0a8 | | ||
| salaries | 2844047 | fd220654e95aea1b169624ffe3fca934 | | ||
+--------------+------------------+----------------------------------+ | ||
+--------------+------------------+----------------------------------+ | ||
| table_name | found_records | found_crc | | ||
+--------------+------------------+----------------------------------+ | ||
| employees | 300024 | 4ec56ab5ba37218d187cf6ab09ce1aa1 | | ||
| departments | 9 | d1af5e170d2d1591d776d5638d71fc5f | | ||
| dept_manager | 24 | 8720e2f0853ac9096b689c14664f847e | | ||
| dept_emp | 331603 | ccf6fe516f990bdaa49713fc478701b7 | | ||
| titles | 443308 | bfa016c472df68e70a03facafa1bc0a8 | | ||
| salaries | 2844047 | fd220654e95aea1b169624ffe3fca934 | | ||
+--------------+------------------+----------------------------------+ | ||
+--------------+---------------+-----------+ | ||
| table_name | records_match | crc_match | | ||
+--------------+---------------+-----------+ | ||
| employees | OK | ok | | ||
| departments | OK | ok | | ||
| dept_manager | OK | ok | | ||
| dept_emp | OK | ok | | ||
| titles | OK | ok | | ||
| salaries | OK | ok | | ||
+--------------+---------------+-----------+ | ||
|
||
|
||
## DISCLAIMER | ||
|
||
To the best of my knowledge, this data is fabricated, and | ||
it does not correspond to real people. | ||
Any similarity to existing people is purely coincidental. | ||
|
||
|
||
## LICENSE | ||
This work is licensed under the | ||
Creative Commons Attribution-Share Alike 3.0 Unported License. | ||
To view a copy of this license, visit | ||
http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to | ||
Creative Commons, 171 Second Street, Suite 300, San Francisco, | ||
California, 94105, USA. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
-- Sample employee database | ||
-- See changelog table for details | ||
-- Copyright (C) 2007,2008, MySQL AB | ||
-- | ||
-- Original data created by Fusheng Wang and Carlo Zaniolo | ||
-- http://www.cs.aau.dk/TimeCenter/software.htm | ||
-- http://www.cs.aau.dk/TimeCenter/Data/employeeTemporalDataSet.zip | ||
-- | ||
-- Current schema by Giuseppe Maxia | ||
-- Data conversion from XML to relational by Patrick Crews | ||
-- | ||
-- This work is licensed under the | ||
-- Creative Commons Attribution-Share Alike 3.0 Unported License. | ||
-- To view a copy of this license, visit | ||
-- http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to | ||
-- Creative Commons, 171 Second Street, Suite 300, San Francisco, | ||
-- California, 94105, USA. | ||
-- | ||
-- DISCLAIMER | ||
-- To the best of our knowledge, this data is fabricated, and | ||
-- it does not correspond to real people. | ||
-- Any similarity to existing people is purely coincidental. | ||
-- | ||
|
||
DROP DATABASE IF EXISTS employees; | ||
CREATE DATABASE IF NOT EXISTS employees; | ||
USE employees; | ||
|
||
SELECT 'CREATING DATABASE STRUCTURE' as 'INFO'; | ||
|
||
DROP TABLE IF EXISTS dept_emp, | ||
dept_manager, | ||
titles, | ||
salaries, | ||
employees, | ||
departments; | ||
|
||
set default_storage_engine = InnoDB; | ||
|
||
select CONCAT('storage engine: ', @@default_storage_engine) as INFO; | ||
|
||
CREATE TABLE employees ( | ||
emp_no INT NOT NULL, | ||
birth_date DATE NOT NULL, | ||
first_name VARCHAR(14) NOT NULL, | ||
last_name VARCHAR(16) NOT NULL, | ||
gender ENUM ('M','F') NOT NULL, | ||
hire_date DATE NOT NULL, | ||
PRIMARY KEY (emp_no) | ||
); | ||
|
||
CREATE TABLE departments ( | ||
dept_no CHAR(4) NOT NULL, | ||
dept_name VARCHAR(40) NOT NULL, | ||
PRIMARY KEY (dept_no), | ||
UNIQUE KEY (dept_name) | ||
); | ||
|
||
CREATE TABLE dept_manager ( | ||
emp_no INT NOT NULL, | ||
dept_no CHAR(4) NOT NULL, | ||
from_date DATE NOT NULL, | ||
to_date DATE NOT NULL, | ||
FOREIGN KEY (emp_no) REFERENCES employees (emp_no) ON DELETE CASCADE, | ||
FOREIGN KEY (dept_no) REFERENCES departments (dept_no) ON DELETE CASCADE, | ||
PRIMARY KEY (emp_no,dept_no) | ||
); | ||
|
||
CREATE TABLE dept_emp ( | ||
emp_no INT NOT NULL, | ||
dept_no CHAR(4) NOT NULL, | ||
from_date DATE NOT NULL, | ||
to_date DATE NOT NULL, | ||
FOREIGN KEY (emp_no) REFERENCES employees (emp_no) ON DELETE CASCADE, | ||
FOREIGN KEY (dept_no) REFERENCES departments (dept_no) ON DELETE CASCADE, | ||
PRIMARY KEY (emp_no,dept_no) | ||
); | ||
|
||
CREATE TABLE titles ( | ||
emp_no INT NOT NULL, | ||
title VARCHAR(50) NOT NULL, | ||
from_date DATE NOT NULL, | ||
to_date DATE, | ||
FOREIGN KEY (emp_no) REFERENCES employees (emp_no) ON DELETE CASCADE, | ||
PRIMARY KEY (emp_no,title, from_date) | ||
) | ||
; | ||
|
||
CREATE TABLE salaries ( | ||
emp_no INT NOT NULL, | ||
salary INT NOT NULL, | ||
from_date DATE NOT NULL, | ||
to_date DATE NOT NULL, | ||
FOREIGN KEY (emp_no) REFERENCES employees (emp_no) ON DELETE CASCADE, | ||
PRIMARY KEY (emp_no, from_date) | ||
) | ||
; | ||
|
||
flush binary logs; | ||
|
||
SELECT 'LOADING departments' as 'INFO'; | ||
source load_departments.dump ; | ||
SELECT 'LOADING employees' as 'INFO'; | ||
source load_employees.dump ; | ||
SELECT 'LOADING dept_emp' as 'INFO'; | ||
source load_dept_emp.dump ; | ||
SELECT 'LOADING dept_manager' as 'INFO'; | ||
source load_dept_manager.dump ; | ||
SELECT 'LOADING titles' as 'INFO'; | ||
source load_titles.dump ; | ||
SELECT 'LOADING salaries' as 'INFO'; | ||
source load_salaries1.dump ; | ||
source load_salaries2.dump ; | ||
|
Oops, something went wrong.