Under the Hood with MySQL

Post on 13-May-2015

2.177 views 1 download

Tags:

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

Under the Hood with MySQL

Joe Atzberger, LibLime

KohaCon 2009: Plano, TX

SQL Control

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?

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.

DB Design Principles

• Limit duplication of values

• Put related data together

• Proper data typing

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

DB Design Principles

DB Design Principles

Does Koha do this?

DB Design Principles

Does Koha do this?

• Yes

DB Design Principles

Does Koha do this?

• Yes

• and No.

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...

Core tables

Core tables• systempreferences: system preferences

Core tables• systempreferences: system preferences

• branches: the most frequently keyed table

Core tables• systempreferences: system preferences

• branches: the most frequently keyed table

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

Core tables• systempreferences: system preferences

• branches: the most frequently keyed table

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

• biblio: title level

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

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

Parallel tables

• deletedxxx: biblios, items, biblioitems, borrowers

• old_xxx: old_issues, old_reserves. Need more.

Black Magicks

• marc_subfield_structure

• marc_tag_structure

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

So what’s left?

• Paul covered structure

• Nicole handled queries

Pretty pictures?

The End?