Under the Hood with MySQL

27
Under the Hood with MySQL Joe Atzberger, LibLime KohaCon 2009: Plano, TX

description

A look at Koha’s internal database structure using the mysql command-line. This isn’t to teach you SQL, but where to look in Koha tables for relevant data. - Joe Atzberger

Transcript of Under the Hood with MySQL

Page 1: Under the Hood with MySQL

Under the Hood with MySQL

Joe Atzberger, LibLime

KohaCon 2009: Plano, TX

Page 2: Under the Hood with MySQL

SQL Control

Page 6: Under the Hood with MySQL

SQL Control•mysqldump --no-data --xml -uyouruser -pyourpass koha_db >dump.sql

•~125 tables

•~1773 lines of XML

•That is a lot of stuff.

So what do you use to look at it all?

Page 7: Under the Hood with MySQL

SQL Tools• phpMyAdmin: web based table control, a

great way to break everything and not be able to fix it.

• MySQL Administrator, MySQL Query Browser: Free and “official”.

• Tons of OSS applications. Varying quality.

• Tons of proprietary software. Varying cost.

I once performed a tech inventory for the State of Ohio in one of its smaller departments. The single largest line item was $427,000 for 7 boxes of Oracle software.

Page 8: Under the Hood with MySQL

DB Design Principles

• Limit duplication of values

• Put related data together

• Proper data typing

• Keys, indexes, etc., etc., etc.

Page 9: Under the Hood with MySQL

DB Design Principles

Page 10: Under the Hood with MySQL

DB Design Principles

Does Koha do this?

Page 11: Under the Hood with MySQL

DB Design Principles

Does Koha do this?

• Yes

Page 12: Under the Hood with MySQL

DB Design Principles

Does Koha do this?

• Yes

• and No.

Page 13: Under the Hood with MySQL

DB Design Problems• MARC: not a relational design.

• MARC: limits on record dimensions.

• MARC: performance implications.

• Battle of MARCs. Legacy code and data.

• FRBR, holdings, bindings, serials, etc.

• Excuses, excuses, excuses...

Page 14: Under the Hood with MySQL

Core tables

Page 15: Under the Hood with MySQL

Core tables• systempreferences: system preferences

Page 16: Under the Hood with MySQL

Core tables• systempreferences: system preferences

• branches: the most frequently keyed table

Page 17: Under the Hood with MySQL

Core tables• systempreferences: system preferences

• branches: the most frequently keyed table

• borrowers: users, patrons, staff, people, whomever

Page 18: Under the Hood with MySQL

Core tables• systempreferences: system preferences

• branches: the most frequently keyed table

• borrowers: users, patrons, staff, people, whomever

• biblio: title level

Page 19: Under the Hood with MySQL

Core tables• systempreferences: system preferences

• branches: the most frequently keyed table

• borrowers: users, patrons, staff, people, whomever

• biblio: title level

• biblioitems: marc & marcxml, going away soon

Page 20: Under the Hood with MySQL

Core tables• systempreferences: system preferences

• branches: the most frequently keyed table

• borrowers: users, patrons, staff, people, whomever

• biblio: title level

• biblioitems: marc & marcxml, going away soon

• items: where the barcodes live

Page 21: Under the Hood with MySQL

Parallel tables

• deletedxxx: biblios, items, biblioitems, borrowers

• old_xxx: old_issues, old_reserves. Need more.

Page 22: Under the Hood with MySQL

Black Magicks

• marc_subfield_structure

• marc_tag_structure

You won’t be importing to any of these tables. Very application specific.

Page 23: Under the Hood with MySQL

So what’s left?

• Paul covered structure

• Nicole handled queries

Page 24: Under the Hood with MySQL

Pretty pictures?

Page 27: Under the Hood with MySQL

The End?