Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Under the Hood
 with MySQL
    Joe Atzberger, LibLime




   KohaCon 2009: Plano, TX
SQL Control
SQL Control
•Baseline: installer/data/
 mysql/kohastructure.sql
SQL Control
•Baseline: installer/data/
 mysql/kohastructure.sql
•Updates: installer/data/
 mysql/updatedatabase.pl
SQL Control
•Baseline: installer/data/
 mysql/kohastructure.sql
•Updates: installer/data/
 mysql/updatedatabase.pl
•This  ...
SQL Control
•mysqldump --no-data --xml
 -uyouruser -pyourpass koha_db
 >dump.sql
•~125 tables
•~1773 lines of XML
        ...
SQL Tools
• phpMyAdmin: web based table control, a
  great way to break everything and not be
  able to fix it.            ...
DB Design Principles

• Limit duplication of values
• Put related data together
• Proper data typing
• Keys, indexes, 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 implica...
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...
Core tables
•   systempreferences: system preferences

•   branches: the most frequently keyed table

•   borrowers: users...
Core tables
•   systempreferences: system preferences

•   branches: the most frequently keyed table

•   borrowers: users...
Core tables
•   systempreferences: system preferences

•   branches: the most frequently keyed table

•   borrowers: users...
Parallel tables

• deletedxxx: biblios, items, biblioitems,
  borrowers
• old_xxx: old_issues, old_reserves. Need
  more.
Black Magicks
                           You won’t be importing to
                           any of these tables.
       ...
So what’s left?

• Paul covered structure
• Nicole handled queries
Pretty pictures?
Pretty pictures?

• http://wiki.koha.org/doku.php?
  id=en:development:dbschema:3.01
Pretty pictures?

• http://wiki.koha.org/doku.php?
  id=en:development:dbschema:3.01
• Not that pretty!
The End?
Upcoming SlideShare
Loading in …5
×

Under the Hood with MySQL

6,657 views

Published on

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

Published in: Technology
  • Be the first to comment

Under the Hood with MySQL

  1. 1. Under the Hood with MySQL Joe Atzberger, LibLime KohaCon 2009: Plano, TX
  2. 2. SQL Control
  3. 3. SQL Control •Baseline: installer/data/ mysql/kohastructure.sql
  4. 4. SQL Control •Baseline: installer/data/ mysql/kohastructure.sql •Updates: installer/data/ mysql/updatedatabase.pl
  5. 5. SQL Control •Baseline: installer/data/ mysql/kohastructure.sql •Updates: installer/data/ mysql/updatedatabase.pl •This defines Koha’s Version!
  6. 6. SQL Control •mysqldump --no-data --xml -uyouruser -pyourpass koha_db >dump.sql •~125 tables •~1773 lines of XML So what do you use to look at it all? •That is a lot of stuff.
  7. 7. SQL Tools • phpMyAdmin: web based table control, a great way to break everything and not be able to fix it. I once performed a tech inventory for the State • MySQL Administrator, MySQL Query of Ohio in one of its smaller departments. The single largest line item was $427,000 for 7 Browser: Free and “official”. boxes of Oracle soft ware. • Tons of OSS applications. Varying quality. • Tons of proprietary software. Varying cost.
  8. 8. DB Design Principles • Limit duplication of values • Put related data together • Proper data typing • Keys, indexes, etc., etc., etc.
  9. 9. DB Design Principles
  10. 10. DB Design Principles Does Koha do this?
  11. 11. DB Design Principles Does Koha do this? • Yes
  12. 12. DB Design Principles Does Koha do this? • Yes • and No.
  13. 13. 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...
  14. 14. Core tables
  15. 15. Core tables • systempreferences: system preferences
  16. 16. Core tables • systempreferences: system preferences • branches: the most frequently keyed table
  17. 17. Core tables • systempreferences: system preferences • branches: the most frequently keyed table • borrowers: users, patrons, staff, people, whomever
  18. 18. Core tables • systempreferences: system preferences • branches: the most frequently keyed table • borrowers: users, patrons, staff, people, whomever • biblio: title level
  19. 19. 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
  20. 20. 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
  21. 21. Parallel tables • deletedxxx: biblios, items, biblioitems, borrowers • old_xxx: old_issues, old_reserves. Need more.
  22. 22. Black Magicks You won’t be importing to any of these tables. Very application specific. • marc_subfield_structure • marc_tag_structure
  23. 23. So what’s left? • Paul covered structure • Nicole handled queries
  24. 24. Pretty pictures?
  25. 25. Pretty pictures? • http://wiki.koha.org/doku.php? id=en:development:dbschema:3.01
  26. 26. Pretty pictures? • http://wiki.koha.org/doku.php? id=en:development:dbschema:3.01 • Not that pretty!
  27. 27. The End?

×