DBSchema::Sample - build and populate a realistic sample schema.
This program builds and populates a small but realistic database.
Install whatever database you want
Postgres 7.4, MySQL 4.0.14 and SQLite 2.8.6 have been tested
Create a database
CREATE DATABASE test
For SQLite, this step is not necessary.
Install DBI
Install appropriate DBD
DBD::SQLite and DBD::mysql have been tested
Install DBSchema::Sample
When it follows the prereqs, it installs DBIx::AnyDBD.
Load the Database
perl -MDBSchema::Sample -e load
Follow the prompts for DBI connection information and the tables will be built and populated.
SQLite users: (1) when this command is run, be sure to run it in a directory where there is no directory named the same as your database and if there is a file with the name of your database, that file is in fact your database. (2) the default username (undef) is just fine.
This creates the database schema discussed in "The Practical SQL Handbook by Bowman, Emerson and Darnovsky" (Addison-Wesley). It is useful to have something like this when you want to play around with a DBI wrapper (or 12) but don't feel like creating a realistic schema and populating it with sensible data.
load()
You can get a PDF of the schema to view here:
http://github.com/metaperl/dbschema-sample/blob/e94b148318147f835f27a6a17587f7d87c956fbb/etc/dbschema.pdf
au_id is a surrogate primary key for the authors table (au_id, title_id) is the primary key for the titleauthors table
au_id
(au_id, title_id)
title_id is a surrogate primary key for the titles table.
title_id
ed_id is a surrogate primary key for the authors table
ed_id
At first, I didn't understand how a title could have more than one royalty, then I realized that a title has varying royalties based on the total volume sold.
roysched has title_id as a foreign key. And title_id is the primary key in titles.
titles
pub_id is the surrogate primary key.
pub_id
sales has sonum as a primary key. sonum is a foreign key in salesdetails.
sonum
T. M. Brannon, tbone@cpan.org
http://github.com/metaperl/dbschema-sample/tree/master
DBIx::AnyDBD DBD::mysql DBD::SQLite DBIx::Recordset::Playground Class::DBI DBI
https://launchpad.net/test-db/ and http://datacharmer.blogspot.com/2008/07/dont-guess-test-sample-database-with.html
To install DBSchema::Sample, copy and paste the appropriate command in to your terminal.
cpanm
cpanm DBSchema::Sample
CPAN shell
perl -MCPAN -e shell install DBSchema::Sample
For more information on module installation, please visit the detailed CPAN module installation guide.