Bug 6716: Document aqbasket table
[koha.git] / installer / data / mysql / kohastructure.sql
1 -- MySQL dump 10.9
2 --
3 -- Host: localhost    Database: koha30test
4 -- ------------------------------------------------------
5 -- Server version       4.1.22
6
7 /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
8 /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
9 /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
10 /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
11 /*!40101 SET NAMES utf8 */;
12 /*!40103 SET TIME_ZONE='+00:00' */;
13 /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
14 /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
15 /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
16 /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
17
18 --
19 -- Table structure for table `auth_header`
20 --
21
22 DROP TABLE IF EXISTS `auth_header`;
23 CREATE TABLE `auth_header` (
24   `authid` bigint(20) unsigned NOT NULL auto_increment,
25   `authtypecode` varchar(10) NOT NULL default '',
26   `datecreated` date default NULL,
27   `datemodified` date default NULL,
28   `origincode` varchar(20) default NULL,
29   `authtrees` mediumtext,
30   `marc` blob,
31   `linkid` bigint(20) default NULL,
32   `marcxml` longtext NOT NULL,
33   PRIMARY KEY  (`authid`),
34   KEY `origincode` (`origincode`)
35 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
36
37 --
38 -- Table structure for table `auth_subfield_structure`
39 --
40
41 DROP TABLE IF EXISTS `auth_subfield_structure`;
42 CREATE TABLE `auth_subfield_structure` (
43   `authtypecode` varchar(10) NOT NULL default '',
44   `tagfield` varchar(3) NOT NULL default '',
45   `tagsubfield` varchar(1) NOT NULL default '',
46   `liblibrarian` varchar(255) NOT NULL default '',
47   `libopac` varchar(255) NOT NULL default '',
48   `repeatable` tinyint(4) NOT NULL default 0,
49   `mandatory` tinyint(4) NOT NULL default 0,
50   `tab` tinyint(1) default NULL,
51   `authorised_value` varchar(10) default NULL,
52   `value_builder` varchar(80) default NULL,
53   `seealso` varchar(255) default NULL,
54   `isurl` tinyint(1) default NULL,
55   `hidden` tinyint(3) NOT NULL default 0,
56   `linkid` tinyint(1) NOT NULL default 0,
57   `kohafield` varchar(45) NULL default '',
58   `frameworkcode` varchar(10) NOT NULL default '',
59   PRIMARY KEY  (`authtypecode`,`tagfield`,`tagsubfield`),
60   KEY `tab` (`authtypecode`,`tab`)
61 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
62
63 --
64 -- Table structure for table `auth_tag_structure`
65 --
66
67 DROP TABLE IF EXISTS `auth_tag_structure`;
68 CREATE TABLE `auth_tag_structure` (
69   `authtypecode` varchar(10) NOT NULL default '',
70   `tagfield` varchar(3) NOT NULL default '',
71   `liblibrarian` varchar(255) NOT NULL default '',
72   `libopac` varchar(255) NOT NULL default '',
73   `repeatable` tinyint(4) NOT NULL default 0,
74   `mandatory` tinyint(4) NOT NULL default 0,
75   `authorised_value` varchar(10) default NULL,
76   PRIMARY KEY  (`authtypecode`,`tagfield`),
77   CONSTRAINT `auth_tag_structure_ibfk_1` FOREIGN KEY (`authtypecode`) REFERENCES `auth_types` (`authtypecode`) ON DELETE CASCADE ON UPDATE CASCADE
78 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
79
80 --
81 -- Table structure for table `auth_types`
82 --
83
84 DROP TABLE IF EXISTS `auth_types`;
85 CREATE TABLE `auth_types` (
86   `authtypecode` varchar(10) NOT NULL default '',
87   `authtypetext` varchar(255) NOT NULL default '',
88   `auth_tag_to_report` varchar(3) NOT NULL default '',
89   `summary` mediumtext NOT NULL,
90   PRIMARY KEY  (`authtypecode`)
91 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
92
93 --
94 -- Table structure for table `authorised_values`
95 --
96
97 DROP TABLE IF EXISTS `authorised_values`;
98 CREATE TABLE `authorised_values` ( -- stores values for authorized values categories and values
99   `id` int(11) NOT NULL auto_increment, -- unique key, used to identify the authorized value
100   `category` varchar(10) NOT NULL default '', -- key used to identify the authorized value category
101   `authorised_value` varchar(80) NOT NULL default '', -- code use to identify the authorized value
102   `lib` varchar(80) default NULL, -- authorized value description as printed in the staff client
103   `lib_opac` VARCHAR(80) default NULL, -- authorized value description as printed in the OPAC
104   `imageurl` varchar(200) default NULL, -- authorized value URL
105   PRIMARY KEY  (`id`),
106   KEY `name` (`category`),
107   KEY `lib` (`lib`),
108   KEY `auth_value_idx` (`authorised_value`)
109 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
110
111 --
112 -- Table structure for table `biblio`
113 --
114
115 DROP TABLE IF EXISTS `biblio`;
116 CREATE TABLE `biblio` ( -- table that stores bibliographic information
117   `biblionumber` int(11) NOT NULL auto_increment, -- unique identifier assigned to each bibliographic record
118   `frameworkcode` varchar(4) NOT NULL default '', -- foriegn key from the biblio_framework table to identify which framework was used in cataloging this record
119   `author` mediumtext, -- statement of responsibility from MARC record (100$a in MARC21)
120   `title` mediumtext, -- title (without the subtitle) from the MARC record (245$a in MARC21)
121   `unititle` mediumtext, -- uniform title (without the subtitle) from the MARC record (240$a in MARC21)
122   `notes` mediumtext, -- values from the general notes field in the MARC record (500$a in MARC21) split by bar (|)
123   `serial` tinyint(1) default NULL, -- foreign key, linking to the subscriptionid in the serial table
124   `seriestitle` mediumtext,
125   `copyrightdate` smallint(6) default NULL, -- publication or copyright date from the MARC record
126   `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- date and time this record was last touched
127   `datecreated` DATE NOT NULL, -- the date this record was added to Koha
128   `abstract` mediumtext, -- summary from the MARC record (520$a in MARC21)
129   PRIMARY KEY  (`biblionumber`),
130   KEY `blbnoidx` (`biblionumber`)
131 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
132
133 --
134 -- Table structure for table `biblio_framework`
135 --
136
137 DROP TABLE IF EXISTS `biblio_framework`;
138 CREATE TABLE `biblio_framework` (
139   `frameworkcode` varchar(4) NOT NULL default '',
140   `frameworktext` varchar(255) NOT NULL default '',
141   PRIMARY KEY  (`frameworkcode`)
142 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
143
144 --
145 -- Table structure for table `biblioitems`
146 --
147
148 DROP TABLE IF EXISTS `biblioitems`;
149 CREATE TABLE `biblioitems` ( -- information related to bibliographic records in Koha
150   `biblioitemnumber` int(11) NOT NULL auto_increment, -- primary key, unique identifier assigned by Koha
151   `biblionumber` int(11) NOT NULL default 0, -- foreign key linking this table to the biblio table
152   `volume` mediumtext,
153   `number` mediumtext,
154   `itemtype` varchar(10) default NULL, -- biblio level item type (MARC21 942$c)
155   `isbn` varchar(30) default NULL, -- ISBN (MARC21 020$a)
156   `issn` varchar(9) default NULL, -- ISSN (MARC21 022$a)
157   `ean` varchar(13) default NULL,
158   `publicationyear` text,
159   `publishercode` varchar(255) default NULL, -- publisher (MARC21 260$b)
160   `volumedate` date default NULL,
161   `volumedesc` text, -- volume information (MARC21 362$a)
162   `collectiontitle` mediumtext default NULL,
163   `collectionissn` text default NULL,
164   `collectionvolume` mediumtext default NULL,
165   `editionstatement` text default NULL,
166   `editionresponsibility` text default NULL,
167   `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
168   `illus` varchar(255) default NULL, -- illustrations (MARC21 300$b)
169   `pages` varchar(255) default NULL, -- number of pages (MARC21 300$c)
170   `notes` mediumtext,
171   `size` varchar(255) default NULL, -- material size (MARC21 300$c)
172   `place` varchar(255) default NULL, -- publication place (MARC21 260$a)
173   `lccn` varchar(25) default NULL, -- library of congress control number (MARC21 010$a)
174   `marc` longblob, -- full bibliographic MARC record
175   `url` varchar(255) default NULL, -- url (MARC21 856$u)
176   `cn_source` varchar(10) default NULL, -- classification source (MARC21 942$2)
177   `cn_class` varchar(30) default NULL,
178   `cn_item` varchar(10) default NULL,
179   `cn_suffix` varchar(10) default NULL,
180   `cn_sort` varchar(30) default NULL,
181   `totalissues` int(10),
182   `marcxml` longtext NOT NULL, -- full bibliographic MARC record in MARCXML
183   PRIMARY KEY  (`biblioitemnumber`),
184   KEY `bibinoidx` (`biblioitemnumber`),
185   KEY `bibnoidx` (`biblionumber`),
186   KEY `isbn` (`isbn`),
187   KEY `issn` (`issn`),
188   KEY `publishercode` (`publishercode`),
189   CONSTRAINT `biblioitems_ibfk_1` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE
190 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
191
192 --
193 -- Table structure for table `borrowers`
194 --
195
196 DROP TABLE IF EXISTS `borrowers`;
197 CREATE TABLE `borrowers` ( -- this table includes information about your patrons/borrowers/members
198   `borrowernumber` int(11) NOT NULL auto_increment, -- primary key, Koha assigned ID number for patrons/borrowers
199   `cardnumber` varchar(16) default NULL, -- unique key, library assigned ID number for patrons/borrowers
200   `surname` mediumtext NOT NULL, -- patron/borrower's last name (surname)
201   `firstname` text, -- patron/borrower's first name
202   `title` mediumtext, -- patron/borrower's title, for example: Mr. or Mrs.
203   `othernames` mediumtext, -- any other names associated with the patron/borrower
204   `initials` text, -- initials for your patron/borrower
205   `streetnumber` varchar(10) default NULL, -- the house number for your patron/borrower's primary address
206   `streettype` varchar(50) default NULL, -- the street type (Rd., Blvd, etc) for your patron/borrower's primary address
207   `address` mediumtext NOT NULL, -- the first address line for your patron/borrower's primary address
208   `address2` text, -- the second address line for your patron/borrower's primary address
209   `city` mediumtext NOT NULL, -- the city or town for your patron/borrower's primary address
210   `state` text default NULL, -- the state or province for your patron/borrower's primary address
211   `zipcode` varchar(25) default NULL, -- the zip or postal code for your patron/borrower's primary address
212   `country` text, -- the country for your patron/borrower's primary address
213   `email` mediumtext, -- the primary email address for your patron/borrower's primary address
214   `phone` text, -- the primary phone number for your patron/borrower's primary address
215   `mobile` varchar(50) default NULL, -- the other phone number for your patron/borrower's primary address
216   `fax` mediumtext, -- the fax number for your patron/borrower's primary address
217   `emailpro` text, -- the secondary email addres for your patron/borrower's primary address
218   `phonepro` text, -- the secondary phone number for your patron/borrower's primary address
219   `B_streetnumber` varchar(10) default NULL, -- the house number for your patron/borrower's alternate address
220   `B_streettype` varchar(50) default NULL, -- the street type (Rd., Blvd, etc) for your patron/borrower's alternate address
221   `B_address` varchar(100) default NULL, -- the first address line for your patron/borrower's alternate address
222   `B_address2` text default NULL, -- the second address line for your patron/borrower's alternate address
223   `B_city` mediumtext, -- the city or town for your patron/borrower's alternate address
224   `B_state` text default NULL, -- the state for your patron/borrower's alternate address
225   `B_zipcode` varchar(25) default NULL, -- the zip or postal code for your patron/borrower's alternate address
226   `B_country` text, -- the country for your patron/borrower's alternate address
227   `B_email` text, -- the patron/borrower's alternate email address
228   `B_phone` mediumtext, -- the patron/borrower's alternate phone number
229   `dateofbirth` date default NULL, -- the patron/borrower's date of birth (YYYY-MM-DD)
230   `branchcode` varchar(10) NOT NULL default '', -- foreign key from the branches table, includes the code of the patron/borrower's home branch
231   `categorycode` varchar(10) NOT NULL default '', -- foreign key from the categories table, includes the code of the patron category
232   `dateenrolled` date default NULL, -- date the patron was added to Koha (YYYY-MM-DD)
233   `dateexpiry` date default NULL, -- date the patron/borrower's card is set to expire (YYYY-MM-DD)
234   `gonenoaddress` tinyint(1) default NULL, -- set to 1 for yes and 0 for no, flag to note that library marked this patron/borrower as having an unconfirmed address
235   `lost` tinyint(1) default NULL, -- set to 1 for yes and 0 for no, flag to note that library marked this patron/borrower as having lost their card
236   `debarred` date default NULL, -- until this date the patron can only check-in (no loans, no holds, etc.), is a fine based on days instead of money (YYY-MM-DD)
237   `debarredcomment` VARCHAR(255) DEFAULT NULL, -- comment on the stop of the patron
238   `contactname` mediumtext, -- used for children and profesionals to include surname or last name of guarentor or organization name
239   `contactfirstname` text, -- used for children to include first name of guarentor
240   `contacttitle` text, -- used for children to include title (Mr., Mrs., etc) of guarentor
241   `guarantorid` int(11) default NULL, -- borrowernumber used for children or professionals to link them to guarentors or organizations
242   `borrowernotes` mediumtext, -- a note on the patron/borroewr's account that is only visible in the staff client
243   `relationship` varchar(100) default NULL, -- used for children to include the relationship to their guarentor
244   `ethnicity` varchar(50) default NULL, -- unused in Koha
245   `ethnotes` varchar(255) default NULL, -- unused in Koha
246   `sex` varchar(1) default NULL, -- patron/borrower's gender
247   `password` varchar(30) default NULL, -- patron/borrower's encrypted password
248   `flags` int(11) default NULL, -- will include a number associated with the staff member's permissions
249   `userid` varchar(75) default NULL, -- patron/borrower's opac and/or staff client log in
250   `opacnote` mediumtext, -- a note on the patron/borrower's account that is visible in the OPAC and staff client
251   `contactnote` varchar(255) default NULL, -- a note related to the patron/borrower's alternate address
252   `sort1` varchar(80) default NULL, -- a field that can be used for any information unique to the library
253   `sort2` varchar(80) default NULL, -- a field that can be used for any information unique to the library
254   `altcontactfirstname` varchar(255) default NULL, -- first name of alternate contact for the patron/borrower
255   `altcontactsurname` varchar(255) default NULL, -- surname or last name of the alternate contact for the patron/borrower
256   `altcontactaddress1` varchar(255) default NULL, -- the first address line for the alternate contact for the patron/borrower
257   `altcontactaddress2` varchar(255) default NULL, -- the second address line for the alternate contact for the patron/borrower
258   `altcontactaddress3` varchar(255) default NULL, -- the third address line for the alternate contact for the patron/borrower
259   `altcontactstate` text default NULL, -- the city and state for the alternate contact for the patron/borrower
260   `altcontactzipcode` varchar(50) default NULL, -- the zipcode for the alternate contact for the patron/borrower
261   `altcontactcountry` text default NULL, -- the country for the alternate contact for the patron/borrower
262   `altcontactphone` varchar(50) default NULL, -- the phone number for the alternate contact for the patron/borrower
263   `smsalertnumber` varchar(50) default NULL, -- the mobile phone number where the patron/borrower would like to receive notices (if SNS turned on)
264   `privacy` integer(11) DEFAULT '1' NOT NULL, -- patron/borrower's privacy settings related to their reading history
265   UNIQUE KEY `cardnumber` (`cardnumber`),
266   PRIMARY KEY `borrowernumber` (`borrowernumber`),
267   KEY `categorycode` (`categorycode`),
268   KEY `branchcode` (`branchcode`),
269   KEY `userid` (`userid`),
270   KEY `guarantorid` (`guarantorid`),
271   CONSTRAINT `borrowers_ibfk_1` FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`),
272   CONSTRAINT `borrowers_ibfk_2` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`)
273 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
274
275 --
276 -- Table structure for table `borrower_attribute_types`
277 --
278
279 DROP TABLE IF EXISTS `borrower_attribute_types`;
280 CREATE TABLE `borrower_attribute_types` ( -- definitions for custom patron fields known as extended patron attributes
281   `code` varchar(10) NOT NULL, -- unique key used to identify each custom field
282   `description` varchar(255) NOT NULL, -- description for each custom field
283   `repeatable` tinyint(1) NOT NULL default 0, -- defines whether one patron/borrower can have multiple values for this custom field  (1 for yes, 0 for no)
284   `unique_id` tinyint(1) NOT NULL default 0, -- defines if this value needs to be unique (1 for yes, 0 for no)
285   `opac_display` tinyint(1) NOT NULL default 0, -- defines if this field is visible to patrons on their account in the OPAC (1 for yes, 0 for no)
286   `password_allowed` tinyint(1) NOT NULL default 0, -- defines if it is possible to associate a password with this custom field (1 for yes, 0 for no)
287   `staff_searchable` tinyint(1) NOT NULL default 0, -- defines if this field is searchable via the patron search in the staff client (1 for yes, 0 for no)
288   `authorised_value_category` varchar(10) default NULL, -- foreign key from authorised_values that links this custom field to an authorized value category
289   `display_checkout` tinyint(1) NOT NULL default 0,-- defines if this field displays in checkout screens
290   `category_code` VARCHAR(1) NULL DEFAULT NULL,-- defines a category for an attribute_type
291   `class` VARCHAR(255) NOT NULL DEFAULT '',-- defines a class for an attribute_type
292   PRIMARY KEY  (`code`),
293   KEY `auth_val_cat_idx` (`authorised_value_category`)
294 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
295
296 --
297 -- Table structure for table `borrower_attributes`
298 --
299
300 DROP TABLE IF EXISTS `borrower_attributes`;
301 CREATE TABLE `borrower_attributes` ( -- values of custom patron fields known as extended patron attributes linked to patrons/borrowers
302   `borrowernumber` int(11) NOT NULL, -- foreign key from the borrowers table, defines which patron/borrower has this attribute
303   `code` varchar(10) NOT NULL, -- foreign key from the borrower_attribute_types table, defines which custom field this value was entered for
304   `attribute` varchar(64) default NULL, -- custom patron field value
305   `password` varchar(64) default NULL, -- password associated with this field
306   KEY `borrowernumber` (`borrowernumber`),
307   KEY `code_attribute` (`code`, `attribute`),
308   CONSTRAINT `borrower_attributes_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`)
309     ON DELETE CASCADE ON UPDATE CASCADE,
310   CONSTRAINT `borrower_attributes_ibfk_2` FOREIGN KEY (`code`) REFERENCES `borrower_attribute_types` (`code`)
311     ON DELETE CASCADE ON UPDATE CASCADE
312 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
313
314 --
315 -- Table structure for table `branch_item_rules`
316 --
317
318 DROP TABLE IF EXISTS `branch_item_rules`;
319 CREATE TABLE `branch_item_rules` (
320   `branchcode` varchar(10) NOT NULL,
321   `itemtype` varchar(10) NOT NULL,
322   `holdallowed` tinyint(1) default NULL,
323   `returnbranch` varchar(15) default NULL,
324   PRIMARY KEY  (`itemtype`,`branchcode`),
325   KEY `branch_item_rules_ibfk_2` (`branchcode`),
326   CONSTRAINT `branch_item_rules_ibfk_1` FOREIGN KEY (`itemtype`) REFERENCES `itemtypes` (`itemtype`)
327     ON DELETE CASCADE ON UPDATE CASCADE,
328   CONSTRAINT `branch_item_rules_ibfk_2` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`)
329     ON DELETE CASCADE ON UPDATE CASCADE
330 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
331
332 --
333 -- Table structure for table `branchcategories`
334 --
335
336 DROP TABLE IF EXISTS `branchcategories`;
337 CREATE TABLE `branchcategories` ( -- information related to library/branch groups
338   `categorycode` varchar(10) NOT NULL default '', -- unique identifier for the library/branch group
339   `categoryname` varchar(32), -- name of the library/branch group
340   `codedescription` mediumtext, -- longer description of the library/branch group
341   `categorytype` varchar(16), -- says whether this is a search group or a properties group
342   PRIMARY KEY  (`categorycode`)
343 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
344
345 --
346 -- Table structure for table `branches`
347 --
348
349 DROP TABLE IF EXISTS `branches`;
350 CREATE TABLE `branches` ( -- information about your libraries or branches are stored here
351   `branchcode` varchar(10) NOT NULL default '', -- a unique key assigned to each branch
352   `branchname` mediumtext NOT NULL, -- the name of your library or branch
353   `branchaddress1` mediumtext, -- the first address line of for your library or branch
354   `branchaddress2` mediumtext, -- the second address line of for your library or branch
355   `branchaddress3` mediumtext, -- the third address line of for your library or branch
356   `branchzip` varchar(25) default NULL, -- the zip or postal code for your library or branch
357   `branchcity` mediumtext, -- the city or province for your library or branch
358   `branchstate` mediumtext, -- the state for your library or branch
359   `branchcountry` text, -- the county for your library or branch
360   `branchphone` mediumtext, -- the primary phone for your library or branch
361   `branchfax` mediumtext, -- the fax number for your library or branch
362   `branchemail` mediumtext, -- the primary email address for your library or branch
363   `branchurl` mediumtext, -- the URL for your library or branch's website
364   `issuing` tinyint(4) default NULL, -- unused in Koha
365   `branchip` varchar(15) default NULL, -- the IP address for your library or branch
366   `branchprinter` varchar(100) default NULL, -- unused in Koha
367   `branchnotes` mediumtext, -- notes related to your library or branch
368   opac_info text, -- HTML that displays in OPAC
369   PRIMARY KEY (`branchcode`)
370 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
371
372 --
373 -- Table structure for table `branchrelations`
374 --
375
376 DROP TABLE IF EXISTS `branchrelations`;
377 CREATE TABLE `branchrelations` ( -- this table links libraries/branches to groups
378   `branchcode` varchar(10) NOT NULL default '', -- foreign key from the branches table to identify the branch
379   `categorycode` varchar(10) NOT NULL default '', -- foreign key from the branchcategories table to identify the group
380   PRIMARY KEY  (`branchcode`,`categorycode`),
381   KEY `branchcode` (`branchcode`),
382   KEY `categorycode` (`categorycode`),
383   CONSTRAINT `branchrelations_ibfk_1` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE,
384   CONSTRAINT `branchrelations_ibfk_2` FOREIGN KEY (`categorycode`) REFERENCES `branchcategories` (`categorycode`) ON DELETE CASCADE ON UPDATE CASCADE
385 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
386
387 --
388 -- Table structure for table `branchtransfers`
389 --
390
391 DROP TABLE IF EXISTS `branchtransfers`;
392 CREATE TABLE `branchtransfers` ( -- information for items that are in transit between branches
393   `itemnumber` int(11) NOT NULL default 0, -- the itemnumber that it is in transit (items.itemnumber)
394   `datesent` datetime default NULL, -- the date the transfer was initialized
395   `frombranch` varchar(10) NOT NULL default '', -- the branch the transfer is coming from
396   `datearrived` datetime default NULL, -- the date the transfer arrived at its destination
397   `tobranch` varchar(10) NOT NULL default '', -- the branch the transfer was going to
398   `comments` mediumtext, -- any comments related to the transfer
399   KEY `frombranch` (`frombranch`),
400   KEY `tobranch` (`tobranch`),
401   KEY `itemnumber` (`itemnumber`),
402   CONSTRAINT `branchtransfers_ibfk_1` FOREIGN KEY (`frombranch`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE,
403   CONSTRAINT `branchtransfers_ibfk_2` FOREIGN KEY (`tobranch`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE,
404   CONSTRAINT `branchtransfers_ibfk_3` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE
405 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
406
407
408 --
409 -- Table structure for table `browser`
410 --
411 DROP TABLE IF EXISTS `browser`;
412 CREATE TABLE `browser` (
413   `level` int(11) NOT NULL,
414   `classification` varchar(20) NOT NULL,
415   `description` varchar(255) NOT NULL,
416   `number` bigint(20) NOT NULL,
417   `endnode` tinyint(4) NOT NULL
418 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
419
420 --
421 -- Table structure for table `categories`
422 --
423
424 DROP TABLE IF EXISTS `categories`;
425 CREATE TABLE `categories` ( -- this table shows information related to Koha patron categories
426   `categorycode` varchar(10) NOT NULL default '', -- unique primary key used to idenfity the patron category
427   `description` mediumtext, -- description of the patron category
428   `enrolmentperiod` smallint(6) default NULL, -- number of months the patron is enrolled for (will be NULL if enrolmentperioddate is set)
429   `enrolmentperioddate` DATE NULL DEFAULT NULL, -- date the patron is enrolled until (will be NULL if enrolmentperiod is set)
430   `upperagelimit` smallint(6) default NULL, -- age limit for the patron
431   `dateofbirthrequired` tinyint(1) default NULL,
432   `finetype` varchar(30) default NULL, -- unused in Koha
433   `bulk` tinyint(1) default NULL,
434   `enrolmentfee` decimal(28,6) default NULL, -- enrollment fee for the patron
435   `overduenoticerequired` tinyint(1) default NULL, -- are overdue notices sent to this patron category (1 for yes, 0 for no)
436   `issuelimit` smallint(6) default NULL, -- unused in Koha
437   `reservefee` decimal(28,6) default NULL, -- cost to place holds
438   `hidelostitems` tinyint(1) NOT NULL default '0', -- are lost items shown to this category (1 for yes, 0 for no)
439   `category_type` varchar(1) NOT NULL default 'A', -- type of Koha patron (Adult, Child, Professional, Organizational, Statistical, Staff)
440   PRIMARY KEY  (`categorycode`),
441   UNIQUE KEY `categorycode` (`categorycode`)
442 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
443
444 --
445 -- Table: collections
446 --
447 DROP TABLE IF EXISTS collections;
448 CREATE TABLE collections (
449   colId integer(11) NOT NULL auto_increment,
450   colTitle varchar(100) NOT NULL DEFAULT '',
451   colDesc text NOT NULL,
452   colBranchcode varchar(4) DEFAULT NULL comment 'branchcode for branch where item should be held.',
453   PRIMARY KEY (colId)
454 ) ENGINE=InnoDB DEFAULT CHARACTER SET utf8;
455
456 --
457 -- Table: collections_tracking
458 --
459 DROP TABLE IF EXISTS collections_tracking;
460 CREATE TABLE collections_tracking (
461   ctId integer(11) NOT NULL auto_increment,
462   colId integer(11) NOT NULL DEFAULT 0 comment 'collections.colId',
463   itemnumber integer(11) NOT NULL DEFAULT 0 comment 'items.itemnumber',
464   PRIMARY KEY (ctId)
465 ) ENGINE=InnoDB DEFAULT CHARACTER SET utf8;
466
467 --
468 -- Table structure for table `borrower_branch_circ_rules`
469 --
470
471 DROP TABLE IF EXISTS `branch_borrower_circ_rules`;
472 CREATE TABLE `branch_borrower_circ_rules` (
473   `branchcode` VARCHAR(10) NOT NULL,
474   `categorycode` VARCHAR(10) NOT NULL,
475   `maxissueqty` int(4) default NULL,
476   PRIMARY KEY (`categorycode`, `branchcode`),
477   CONSTRAINT `branch_borrower_circ_rules_ibfk_1` FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`)
478     ON DELETE CASCADE ON UPDATE CASCADE,
479   CONSTRAINT `branch_borrower_circ_rules_ibfk_2` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`)
480     ON DELETE CASCADE ON UPDATE CASCADE
481 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
482
483 --
484 -- Table structure for table `default_borrower_circ_rules`
485 --
486
487 DROP TABLE IF EXISTS `default_borrower_circ_rules`;
488 CREATE TABLE `default_borrower_circ_rules` (
489   `categorycode` VARCHAR(10) NOT NULL,
490   `maxissueqty` int(4) default NULL,
491   PRIMARY KEY (`categorycode`),
492   CONSTRAINT `borrower_borrower_circ_rules_ibfk_1` FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`)
493     ON DELETE CASCADE ON UPDATE CASCADE
494 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
495
496 --
497 -- Table structure for table `default_branch_circ_rules`
498 --
499
500 DROP TABLE IF EXISTS `default_branch_circ_rules`;
501 CREATE TABLE `default_branch_circ_rules` (
502   `branchcode` VARCHAR(10) NOT NULL,
503   `maxissueqty` int(4) default NULL,
504   `holdallowed` tinyint(1) default NULL,
505   `returnbranch` varchar(15) default NULL,
506   PRIMARY KEY (`branchcode`),
507   CONSTRAINT `default_branch_circ_rules_ibfk_1` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`)
508     ON DELETE CASCADE ON UPDATE CASCADE
509 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
510
511 --
512 -- Table structure for table `default_branch_item_rules`
513 --
514 DROP TABLE IF EXISTS `default_branch_item_rules`;
515 CREATE TABLE `default_branch_item_rules` (
516   `itemtype` varchar(10) NOT NULL,
517   `holdallowed` tinyint(1) default NULL,
518   `returnbranch` varchar(15) default NULL,
519   PRIMARY KEY  (`itemtype`),
520   CONSTRAINT `default_branch_item_rules_ibfk_1` FOREIGN KEY (`itemtype`) REFERENCES `itemtypes` (`itemtype`)
521     ON DELETE CASCADE ON UPDATE CASCADE
522 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
523
524 --
525 -- Table structure for table `default_circ_rules`
526 --
527
528 DROP TABLE IF EXISTS `default_circ_rules`;
529 CREATE TABLE `default_circ_rules` (
530     `singleton` enum('singleton') NOT NULL default 'singleton',
531     `maxissueqty` int(4) default NULL,
532     `holdallowed` int(1) default NULL,
533     `returnbranch` varchar(15) default NULL,
534     PRIMARY KEY (`singleton`)
535 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
536
537 --
538 -- Table structure for table `cities`
539 --
540
541 DROP TABLE IF EXISTS `cities`;
542 CREATE TABLE `cities` ( -- authorized values for cities/states/countries to choose when adding/editing a patron/borrower
543   `cityid` int(11) NOT NULL auto_increment, -- unique identifier added by Koha
544   `city_name` varchar(100) NOT NULL default '', -- name of the city
545   `city_state` VARCHAR( 100 ) NULL DEFAULT NULL, -- name of the state/province
546   `city_country` VARCHAR( 100 ) NULL DEFAULT NULL, -- name of the country
547   `city_zipcode` varchar(20) default NULL, -- zip or postal code
548   PRIMARY KEY  (`cityid`)
549 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
550
551 --
552 -- Table structure for table `class_sort_rules`
553 --
554
555 DROP TABLE IF EXISTS `class_sort_rules`;
556 CREATE TABLE `class_sort_rules` (
557   `class_sort_rule` varchar(10) NOT NULL default '',
558   `description` mediumtext,
559   `sort_routine` varchar(30) NOT NULL default '',
560   PRIMARY KEY (`class_sort_rule`),
561   UNIQUE KEY `class_sort_rule_idx` (`class_sort_rule`)
562 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
563
564 --
565 -- Table structure for table `class_sources`
566 --
567
568 DROP TABLE IF EXISTS `class_sources`;
569 CREATE TABLE `class_sources` (
570   `cn_source` varchar(10) NOT NULL default '',
571   `description` mediumtext,
572   `used` tinyint(4) NOT NULL default 0,
573   `class_sort_rule` varchar(10) NOT NULL default '',
574   PRIMARY KEY (`cn_source`),
575   UNIQUE KEY `cn_source_idx` (`cn_source`),
576   KEY `used_idx` (`used`),
577   CONSTRAINT `class_source_ibfk_1` FOREIGN KEY (`class_sort_rule`) REFERENCES `class_sort_rules` (`class_sort_rule`)
578 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
579
580 --
581 -- Table structure for table `currency`
582 --
583
584 DROP TABLE IF EXISTS `currency`;
585 CREATE TABLE `currency` (
586   `currency` varchar(10) NOT NULL default '',
587   `symbol` varchar(5) default NULL,
588   `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
589   `rate` float(15,5) default NULL,
590   `active` tinyint(1) default NULL,
591   PRIMARY KEY  (`currency`)
592 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
593
594 --
595 -- Table structure for table `deletedbiblio`
596 --
597
598 DROP TABLE IF EXISTS `deletedbiblio`;
599 CREATE TABLE `deletedbiblio` ( -- stores information about bibliographic records that have been deleted
600   `biblionumber` int(11) NOT NULL auto_increment, -- unique identifier assigned to each bibliographic record
601   `frameworkcode` varchar(4) NOT NULL default '', -- foriegn key from the biblio_framework table to identify which framework was used in cataloging this record
602   `author` mediumtext, -- statement of responsibility from MARC record (100$a in MARC21)
603   `title` mediumtext, -- title (without the subtitle) from the MARC record (245$a in MARC21)
604   `unititle` mediumtext, -- uniform title (without the subtitle) from the MARC record (240$a in MARC21)
605   `notes` mediumtext, -- values from the general notes field in the MARC record (500$a in MARC21) split by bar (|)
606   `serial` tinyint(1) default NULL, -- foreign key, linking to the subscriptionid in the serial table
607   `seriestitle` mediumtext,
608   `copyrightdate` smallint(6) default NULL, -- publication or copyright date from the MARC record
609   `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- date and time this record was last touched
610   `datecreated` DATE NOT NULL, -- the date this record was added to Koha
611   `abstract` mediumtext, -- summary from the MARC record (520$a in MARC21)
612   PRIMARY KEY  (`biblionumber`),
613   KEY `blbnoidx` (`biblionumber`)
614 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
615
616 --
617 -- Table structure for table `deletedbiblioitems`
618 --
619
620 DROP TABLE IF EXISTS `deletedbiblioitems`;
621 CREATE TABLE `deletedbiblioitems` ( -- information about bibliographic records that have been deleted
622   `biblioitemnumber` int(11) NOT NULL default 0, -- primary key, unique identifier assigned by Koha
623   `biblionumber` int(11) NOT NULL default 0, -- foreign key linking this table to the biblio table
624   `volume` mediumtext,
625   `number` mediumtext,
626   `itemtype` varchar(10) default NULL, -- biblio level item type (MARC21 942$c)
627   `isbn` varchar(30) default NULL, -- ISBN (MARC21 020$a)
628   `issn` varchar(9) default NULL, -- ISSN (MARC21 022$a)
629   `ean` varchar(13) default NULL,
630   `publicationyear` text,
631   `publishercode` varchar(255) default NULL, -- publisher (MARC21 260$b)
632   `volumedate` date default NULL,
633   `volumedesc` text, -- volume information (MARC21 362$a)
634   `collectiontitle` mediumtext default NULL,
635   `collectionissn` text default NULL,
636   `collectionvolume` mediumtext default NULL,
637   `editionstatement` text default NULL,
638   `editionresponsibility` text default NULL,
639   `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
640   `illus` varchar(255) default NULL, -- illustrations (MARC21 300$b)
641   `pages` varchar(255) default NULL, -- number of pages (MARC21 300$c)
642   `notes` mediumtext,
643   `size` varchar(255) default NULL, -- material size (MARC21 300$c)
644   `place` varchar(255) default NULL, -- publication place (MARC21 260$a)
645   `lccn` varchar(25) default NULL, -- library of congress control number (MARC21 010$a)
646   `marc` longblob, -- full bibliographic MARC record
647   `url` varchar(255) default NULL, -- url (MARC21 856$u)
648   `cn_source` varchar(10) default NULL, -- classification source (MARC21 942$2)
649   `cn_class` varchar(30) default NULL,
650   `cn_item` varchar(10) default NULL,
651   `cn_suffix` varchar(10) default NULL,
652   `cn_sort` varchar(30) default NULL,
653   `totalissues` int(10),
654   `marcxml` longtext NOT NULL, -- full bibliographic MARC record in MARCXML
655   PRIMARY KEY  (`biblioitemnumber`),
656   KEY `bibinoidx` (`biblioitemnumber`),
657   KEY `bibnoidx` (`biblionumber`),
658   KEY `isbn` (`isbn`),
659   KEY `publishercode` (`publishercode`)
660 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
661
662 --
663 -- Table structure for table `deletedborrowers`
664 --
665
666 DROP TABLE IF EXISTS `deletedborrowers`;
667 CREATE TABLE `deletedborrowers` ( -- stores data related to the patrons/borrowers you have deleted
668   `borrowernumber` int(11) NOT NULL default 0, -- primary key, Koha assigned ID number for patrons/borrowers
669   `cardnumber` varchar(16) default NULL, -- unique key, library assigned ID number for patrons/borrowers
670   `surname` mediumtext NOT NULL, -- patron/borrower's last name (surname)
671   `firstname` text, -- patron/borrower's first name
672   `title` mediumtext, -- patron/borrower's title, for example: Mr. or Mrs.
673   `othernames` mediumtext, -- any other names associated with the patron/borrower
674   `initials` text, -- initials for your patron/borrower
675   `streetnumber` varchar(10) default NULL, -- the house number for your patron/borrower's primary address
676   `streettype` varchar(50) default NULL, -- the street type (Rd., Blvd, etc) for your patron/borrower's primary address
677   `address` mediumtext NOT NULL, -- the first address line for your patron/borrower's primary address
678   `address2` text, -- the second address line for your patron/borrower's primary address
679   `city` mediumtext NOT NULL, -- the city or town for your patron/borrower's primary address
680   `state` text default NULL, -- the state or province for your patron/borrower's primary address
681   `zipcode` varchar(25) default NULL, -- the zip or postal code for your patron/borrower's primary address
682   `country` text, -- the country for your patron/borrower's primary address
683   `email` mediumtext, -- the primary email address for your patron/borrower's primary address
684   `phone` text, -- the primary phone number for your patron/borrower's primary address
685   `mobile` varchar(50) default NULL, -- the other phone number for your patron/borrower's primary address
686   `fax` mediumtext, -- the fax number for your patron/borrower's primary address
687   `emailpro` text, -- the secondary email addres for your patron/borrower's primary address
688   `phonepro` text, -- the secondary phone number for your patron/borrower's primary address
689   `B_streetnumber` varchar(10) default NULL, -- the house number for your patron/borrower's alternate address
690   `B_streettype` varchar(50) default NULL, -- the street type (Rd., Blvd, etc) for your patron/borrower's alternate address
691   `B_address` varchar(100) default NULL, -- the first address line for your patron/borrower's alternate address
692   `B_address2` text default NULL, -- the second address line for your patron/borrower's alternate address
693   `B_city` mediumtext, -- the city or town for your patron/borrower's alternate address
694   `B_state` text default NULL, -- the state for your patron/borrower's alternate address
695   `B_zipcode` varchar(25) default NULL, -- the zip or postal code for your patron/borrower's alternate address
696   `B_country` text, -- the country for your patron/borrower's alternate address
697   `B_email` text, -- the patron/borrower's alternate email address
698   `B_phone` mediumtext, -- the patron/borrower's alternate phone number
699   `dateofbirth` date default NULL, -- the patron/borrower's date of birth (YYYY-MM-DD)
700   `branchcode` varchar(10) NOT NULL default '', -- foreign key from the branches table, includes the code of the patron/borrower's home branch
701   `categorycode` varchar(10) NOT NULL default '', -- foreign key from the categories table, includes the code of the patron category
702   `dateenrolled` date default NULL, -- date the patron was added to Koha (YYYY-MM-DD)
703   `dateexpiry` date default NULL, -- date the patron/borrower's card is set to expire (YYYY-MM-DD)
704   `gonenoaddress` tinyint(1) default NULL, -- set to 1 for yes and 0 for no, flag to note that library marked this patron/borrower as having an unconfirmed address
705   `lost` tinyint(1) default NULL, -- set to 1 for yes and 0 for no, flag to note that library marked this patron/borrower as having lost their card
706   `debarred` date default NULL, -- until this date the patron can only check-in (no loans, no holds, etc.), is a fine based on days instead of money (YYY-MM-DD)
707   `debarredcomment` VARCHAR(255) DEFAULT NULL, -- comment on the stop of patron
708   `contactname` mediumtext, -- used for children and profesionals to include surname or last name of guarentor or organization name
709   `contactfirstname` text, -- used for children to include first name of guarentor
710   `contacttitle` text, -- used for children to include title (Mr., Mrs., etc) of guarentor
711   `guarantorid` int(11) default NULL, -- borrowernumber used for children or professionals to link them to guarentors or organizations
712   `borrowernotes` mediumtext, -- a note on the patron/borroewr's account that is only visible in the staff client
713   `relationship` varchar(100) default NULL, -- used for children to include the relationship to their guarentor
714   `ethnicity` varchar(50) default NULL, -- unused in Koha
715   `ethnotes` varchar(255) default NULL, -- unused in Koha
716   `sex` varchar(1) default NULL, -- patron/borrower's gender
717   `password` varchar(30) default NULL, -- patron/borrower's encrypted password
718   `flags` int(11) default NULL, -- will include a number associated with the staff member's permissions
719   `userid` varchar(30) default NULL, -- patron/borrower's opac and/or staff client log in
720   `opacnote` mediumtext, -- a note on the patron/borrower's account that is visible in the OPAC and staff client
721   `contactnote` varchar(255) default NULL, -- a note related to the patron/borrower's alternate address
722   `sort1` varchar(80) default NULL, -- a field that can be used for any information unique to the library
723   `sort2` varchar(80) default NULL, -- a field that can be used for any information unique to the library
724   `altcontactfirstname` varchar(255) default NULL, -- first name of alternate contact for the patron/borrower
725   `altcontactsurname` varchar(255) default NULL, -- surname or last name of the alternate contact for the patron/borrower
726   `altcontactaddress1` varchar(255) default NULL, -- the first address line for the alternate contact for the patron/borrower
727   `altcontactaddress2` varchar(255) default NULL, -- the second address line for the alternate contact for the patron/borrower
728   `altcontactaddress3` varchar(255) default NULL, -- the third address line for the alternate contact for the patron/borrower
729   `altcontactstate` text default NULL, -- the city and state for the alternate contact for the patron/borrower
730   `altcontactzipcode` varchar(50) default NULL, -- the zipcode for the alternate contact for the patron/borrower
731   `altcontactcountry` text default NULL, -- the country for the alternate contact for the patron/borrower
732   `altcontactphone` varchar(50) default NULL, -- the phone number for the alternate contact for the patron/borrower
733   `smsalertnumber` varchar(50) default NULL, -- the mobile phone number where the patron/borrower would like to receive notices (if SNS turned on)
734   `privacy` integer(11) DEFAULT '1' NOT NULL, -- patron/borrower's privacy settings related to their reading history  KEY `borrowernumber` (`borrowernumber`),
735   KEY borrowernumber (borrowernumber),
736   KEY `cardnumber` (`cardnumber`)
737 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
738
739 --
740 -- Table structure for table `deleteditems`
741 --
742
743 DROP TABLE IF EXISTS `deleteditems`;
744 CREATE TABLE `deleteditems` (
745   `itemnumber` int(11) NOT NULL default 0, -- primary key and unique identifier added by Koha
746   `biblionumber` int(11) NOT NULL default 0, -- foreign key from biblio table used to link this item to the right bib record
747   `biblioitemnumber` int(11) NOT NULL default 0, -- foreign key from the biblioitems table to link to item to additional information
748   `barcode` varchar(20) default NULL, -- item barcode (MARC21 952$p)
749   `dateaccessioned` date default NULL, -- date the item was acquired or added to Koha (MARC21 952$d)
750   `booksellerid` mediumtext default NULL, -- where the item was purchased (MARC21 952$e)
751   `homebranch` varchar(10) default NULL, -- foreign key from the branches table for the library that owns this item (MARC21 952$a)
752   `price` decimal(8,2) default NULL, -- purchase price (MARC21 952$g)
753   `replacementprice` decimal(8,2) default NULL, -- cost the library charges to replace the item if it has been marked lost (MARC21 952$v)
754   `replacementpricedate` date default NULL, -- the date the price is effective from (MARC21 952$w)
755   `datelastborrowed` date default NULL, -- the date the item was last checked out
756   `datelastseen` date default NULL, -- the date the item was last see (usually the last time the barcode was scanned or inventory was done)
757   `stack` tinyint(1) default NULL,
758   `notforloan` tinyint(1) NOT NULL default 0, -- authorized value defining why this item is not for loan (MARC21 952$7)
759   `damaged` tinyint(1) NOT NULL default 0, -- authorized value defining this item as damaged (MARC21 952$4)
760   `itemlost` tinyint(1) NOT NULL default 0, -- authorized value defining this item as lost (MARC21 952$1)
761   `wthdrawn` tinyint(1) NOT NULL default 0, -- authorized value defining this item as withdrawn (MARC21 952$0)
762   `itemcallnumber` varchar(255) default NULL, -- call number for this item (MARC21 952$o)
763   `issues` smallint(6) default NULL, -- number of times this item has been checked out
764   `renewals` smallint(6) default NULL, -- number of times this item has been renewed
765   `reserves` smallint(6) default NULL, -- number of times this item has been placed on hold/reserved
766   `restricted` tinyint(1) default NULL, -- authorized value defining use restrictions for this item (MARC21 952$5)
767   `itemnotes` mediumtext, -- public notes on this item (MARC21 952$x)
768   `holdingbranch` varchar(10) default NULL, -- foreign key from the branches table for the library that is currently in possession item (MARC21 952$b)
769   `paidfor` mediumtext,
770   `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- date and time this item was last altered
771   `location` varchar(80) default NULL, -- authorized value for the shelving location for this item (MARC21 952$c)
772   `permanent_location` varchar(80) default NULL, -- linked to the CART and PROC temporary locations feature, stores the permanent shelving location
773   `onloan` date default NULL, -- defines if this item is currently checked out (1 for yes, 0 for no)
774   `cn_source` varchar(10) default NULL, -- classification source used on this item (MARC21 952$2)
775   `cn_sort` varchar(30) default NULL, -- normalized form of the call number (MARC21 952$o) used for sorting
776   `ccode` varchar(10) default NULL, -- authorized value for the collection code associated with this item (MARC21 952$8)
777   `materials` varchar(10) default NULL, -- materials specified (MARC21 952$3)
778   `uri` varchar(255) default NULL, -- URL for the item (MARC21 952$u)
779   `itype` varchar(10) default NULL, -- foreign key from the itemtypes table defining the type for this item (MARC21 952$y)
780   `more_subfields_xml` longtext default NULL, -- additional 952 subfields in XML format
781   `enumchron` text default NULL, -- serial enumeration/chronology for the item (MARC21 952$h)
782   `copynumber` varchar(32) default NULL, -- copy number (MARC21 952$t)
783   `stocknumber` varchar(32) default NULL, -- inventory number (MARC21 952$i)
784   `marc` longblob, -- unused in Koha
785   PRIMARY KEY  (`itemnumber`),
786   KEY `delitembarcodeidx` (`barcode`),
787   KEY `delitemstocknumberidx` (`stocknumber`),
788   KEY `delitembinoidx` (`biblioitemnumber`),
789   KEY `delitembibnoidx` (`biblionumber`),
790   KEY `delhomebranch` (`homebranch`),
791   KEY `delholdingbranch` (`holdingbranch`)
792 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
793
794 --
795 -- Table structure for table `ethnicity`
796 --
797
798 DROP TABLE IF EXISTS `ethnicity`;
799 CREATE TABLE `ethnicity` (
800   `code` varchar(10) NOT NULL default '',
801   `name` varchar(255) default NULL,
802   PRIMARY KEY  (`code`)
803 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
804
805 --
806 -- Table structure for table `export_format`
807 --
808
809 DROP TABLE IF EXISTS `export_format`;
810 CREATE TABLE `export_format` (
811   `export_format_id` int(11) NOT NULL auto_increment,
812   `profile` varchar(255) NOT NULL,
813   `description` mediumtext NOT NULL,
814   `marcfields` mediumtext NOT NULL,
815   `csv_separator` varchar(2) NOT NULL,
816   `field_separator` varchar(2) NOT NULL,
817   `subfield_separator` varchar(2) NOT NULL,
818   `encoding` varchar(255) NOT NULL,
819   PRIMARY KEY  (`export_format_id`)
820 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Used for CSV export';
821
822
823 --
824 -- Table structure for table `hold_fill_targets`
825 --
826
827 DROP TABLE IF EXISTS `hold_fill_targets`;
828 CREATE TABLE hold_fill_targets (
829   `borrowernumber` int(11) NOT NULL,
830   `biblionumber` int(11) NOT NULL,
831   `itemnumber` int(11) NOT NULL,
832   `source_branchcode`  varchar(10) default NULL,
833   `item_level_request` tinyint(4) NOT NULL default 0,
834   PRIMARY KEY `itemnumber` (`itemnumber`),
835   KEY `bib_branch` (`biblionumber`, `source_branchcode`),
836   CONSTRAINT `hold_fill_targets_ibfk_1` FOREIGN KEY (`borrowernumber`)
837     REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
838   CONSTRAINT `hold_fill_targets_ibfk_2` FOREIGN KEY (`biblionumber`)
839     REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE,
840   CONSTRAINT `hold_fill_targets_ibfk_3` FOREIGN KEY (`itemnumber`)
841     REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE,
842   CONSTRAINT `hold_fill_targets_ibfk_4` FOREIGN KEY (`source_branchcode`)
843     REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE
844 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
845
846 --
847 -- Table structure for table `import_batches`
848 --
849
850 DROP TABLE IF EXISTS `import_batches`;
851 CREATE TABLE `import_batches` (
852   `import_batch_id` int(11) NOT NULL auto_increment,
853   `matcher_id` int(11) default NULL,
854   `template_id` int(11) default NULL,
855   `branchcode` varchar(10) default NULL,
856   `num_biblios` int(11) NOT NULL default 0,
857   `num_items` int(11) NOT NULL default 0,
858   `upload_timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP,
859   `overlay_action` enum('replace', 'create_new', 'use_template', 'ignore') NOT NULL default 'create_new',
860   `nomatch_action` enum('create_new', 'ignore') NOT NULL default 'create_new',
861   `item_action` enum('always_add', 'add_only_for_matches', 'add_only_for_new', 'ignore') NOT NULL default 'always_add',
862   `import_status` enum('staging', 'staged', 'importing', 'imported', 'reverting', 'reverted', 'cleaned') NOT NULL default 'staging',
863   `batch_type` enum('batch', 'z3950', 'webservice') NOT NULL default 'batch',
864   `file_name` varchar(100),
865   `comments` mediumtext,
866   PRIMARY KEY (`import_batch_id`),
867   KEY `branchcode` (`branchcode`)
868 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
869
870 --
871 -- Table structure for table `import_records`
872 --
873
874 DROP TABLE IF EXISTS `import_records`;
875 CREATE TABLE `import_records` (
876   `import_record_id` int(11) NOT NULL auto_increment,
877   `import_batch_id` int(11) NOT NULL,
878   `branchcode` varchar(10) default NULL,
879   `record_sequence` int(11) NOT NULL default 0,
880   `upload_timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP,
881   `import_date` DATE default NULL,
882   `marc` longblob NOT NULL,
883   `marcxml` longtext NOT NULL,
884   `marcxml_old` longtext NOT NULL,
885   `record_type` enum('biblio', 'auth', 'holdings') NOT NULL default 'biblio',
886   `overlay_status` enum('no_match', 'auto_match', 'manual_match', 'match_applied') NOT NULL default 'no_match',
887   `status` enum('error', 'staged', 'imported', 'reverted', 'items_reverted', 'ignored') NOT NULL default 'staged',
888   `import_error` mediumtext,
889   `encoding` varchar(40) NOT NULL default '',
890   `z3950random` varchar(40) default NULL,
891   PRIMARY KEY (`import_record_id`),
892   CONSTRAINT `import_records_ifbk_1` FOREIGN KEY (`import_batch_id`)
893              REFERENCES `import_batches` (`import_batch_id`) ON DELETE CASCADE ON UPDATE CASCADE,
894   KEY `branchcode` (`branchcode`),
895   KEY `batch_sequence` (`import_batch_id`, `record_sequence`)
896 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
897
898 --
899 -- Table structure for `import_record_matches`
900 --
901 DROP TABLE IF EXISTS `import_record_matches`;
902 CREATE TABLE `import_record_matches` (
903   `import_record_id` int(11) NOT NULL,
904   `candidate_match_id` int(11) NOT NULL,
905   `score` int(11) NOT NULL default 0,
906   CONSTRAINT `import_record_matches_ibfk_1` FOREIGN KEY (`import_record_id`)
907              REFERENCES `import_records` (`import_record_id`) ON DELETE CASCADE ON UPDATE CASCADE,
908   KEY `record_score` (`import_record_id`, `score`)
909 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
910
911 --
912 -- Table structure for table `import_biblios`
913 --
914
915 DROP TABLE IF EXISTS `import_biblios`;
916 CREATE TABLE `import_biblios` (
917   `import_record_id` int(11) NOT NULL,
918   `matched_biblionumber` int(11) default NULL,
919   `control_number` varchar(25) default NULL,
920   `original_source` varchar(25) default NULL,
921   `title` varchar(128) default NULL,
922   `author` varchar(80) default NULL,
923   `isbn` varchar(30) default NULL,
924   `issn` varchar(9) default NULL,
925   `has_items` tinyint(1) NOT NULL default 0,
926   CONSTRAINT `import_biblios_ibfk_1` FOREIGN KEY (`import_record_id`)
927              REFERENCES `import_records` (`import_record_id`) ON DELETE CASCADE ON UPDATE CASCADE,
928   KEY `matched_biblionumber` (`matched_biblionumber`),
929   KEY `title` (`title`),
930   KEY `isbn` (`isbn`)
931 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
932
933 --
934 -- Table structure for table `import_items`
935 --
936
937 DROP TABLE IF EXISTS `import_items`;
938 CREATE TABLE `import_items` (
939   `import_items_id` int(11) NOT NULL auto_increment,
940   `import_record_id` int(11) NOT NULL,
941   `itemnumber` int(11) default NULL,
942   `branchcode` varchar(10) default NULL,
943   `status` enum('error', 'staged', 'imported', 'reverted', 'ignored') NOT NULL default 'staged',
944   `marcxml` longtext NOT NULL,
945   `import_error` mediumtext,
946   PRIMARY KEY (`import_items_id`),
947   CONSTRAINT `import_items_ibfk_1` FOREIGN KEY (`import_record_id`)
948              REFERENCES `import_records` (`import_record_id`) ON DELETE CASCADE ON UPDATE CASCADE,
949   KEY `itemnumber` (`itemnumber`),
950   KEY `branchcode` (`branchcode`)
951 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
952
953 --
954 -- Table structure for table `issues`
955 --
956
957 DROP TABLE IF EXISTS `issues`;
958 CREATE TABLE `issues` ( -- information related to check outs or issues
959   `borrowernumber` int(11), -- foreign key, linking this to the borrowers table for the patron this item was checked out to
960   `itemnumber` int(11), -- foreign key, linking this to the items table for the item that was checked out
961   `date_due` datetime default NULL, -- datetime the item is due (yyyy-mm-dd hh:mm::ss)
962   `branchcode` varchar(10) default NULL, -- foreign key, linking to the branches table for the location the item was checked out
963   `issuingbranch` varchar(18) default NULL,
964   `returndate` datetime default NULL, -- date the item was returned, will be NULL until moved to old_issues
965   `lastreneweddate` datetime default NULL, -- date the item was last renewed
966   `return` varchar(4) default NULL,
967   `renewals` tinyint(4) default NULL, -- lists the number of times the item was renewed
968   `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- the date and time this record was last touched
969   `issuedate` datetime default NULL, -- date the item was checked out or issued
970   KEY `issuesborridx` (`borrowernumber`),
971   KEY `bordate` (`borrowernumber`,`timestamp`),
972   CONSTRAINT `issues_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE RESTRICT ON UPDATE CASCADE,
973   CONSTRAINT `issues_ibfk_2` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE RESTRICT ON UPDATE CASCADE
974 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
975
976 --
977 -- Table structure for table `issuingrules`
978 --
979
980 DROP TABLE IF EXISTS `issuingrules`;
981 CREATE TABLE `issuingrules` (
982   `categorycode` varchar(10) NOT NULL default '',
983   `itemtype` varchar(10) NOT NULL default '',
984   `restrictedtype` tinyint(1) default NULL,
985   `rentaldiscount` decimal(28,6) default NULL,
986   `reservecharge` decimal(28,6) default NULL,
987   `fine` decimal(28,6) default NULL,
988   `finedays` int(11) default NULL,
989   `firstremind` int(11) default NULL,
990   `chargeperiod` int(11) default NULL,
991   `accountsent` int(11) default NULL,
992   `chargename` varchar(100) default NULL,
993   `maxissueqty` int(4) default NULL,
994   `issuelength` int(4) default NULL,
995   `lengthunit` varchar(10) default 'days',
996   `hardduedate` date default NULL,
997   `hardduedatecompare` tinyint NOT NULL default "0",
998   `renewalsallowed` smallint(6) NOT NULL default "0",
999   `reservesallowed` smallint(6) NOT NULL default "0",
1000   `branchcode` varchar(10) NOT NULL default '',
1001   PRIMARY KEY  (`branchcode`,`categorycode`,`itemtype`),
1002   KEY `categorycode` (`categorycode`),
1003   KEY `itemtype` (`itemtype`)
1004 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1005
1006 --
1007 -- Table structure for table `items`
1008 --
1009
1010 DROP TABLE IF EXISTS `items`;
1011 CREATE TABLE `items` ( -- holdings/item information 
1012   `itemnumber` int(11) NOT NULL auto_increment, -- primary key and unique identifier added by Koha
1013   `biblionumber` int(11) NOT NULL default 0, -- foreign key from biblio table used to link this item to the right bib record
1014   `biblioitemnumber` int(11) NOT NULL default 0, -- foreign key from the biblioitems table to link to item to additional information
1015   `barcode` varchar(20) default NULL, -- item barcode (MARC21 952$p)
1016   `dateaccessioned` date default NULL, -- date the item was acquired or added to Koha (MARC21 952$d)
1017   `booksellerid` mediumtext default NULL, -- where the item was purchased (MARC21 952$e)
1018   `homebranch` varchar(10) default NULL, -- foreign key from the branches table for the library that owns this item (MARC21 952$a)
1019   `price` decimal(8,2) default NULL, -- purchase price (MARC21 952$g)
1020   `replacementprice` decimal(8,2) default NULL, -- cost the library charges to replace the item if it has been marked lost (MARC21 952$v)
1021   `replacementpricedate` date default NULL, -- the date the price is effective from (MARC21 952$w)
1022   `datelastborrowed` date default NULL, -- the date the item was last checked out/issued
1023   `datelastseen` date default NULL, -- the date the item was last see (usually the last time the barcode was scanned or inventory was done)
1024   `stack` tinyint(1) default NULL,
1025   `notforloan` tinyint(1) NOT NULL default 0, -- authorized value defining why this item is not for loan (MARC21 952$7)
1026   `damaged` tinyint(1) NOT NULL default 0, -- authorized value defining this item as damaged (MARC21 952$4)
1027   `itemlost` tinyint(1) NOT NULL default 0, -- authorized value defining this item as lost (MARC21 952$1)
1028   `wthdrawn` tinyint(1) NOT NULL default 0, -- authorized value defining this item as withdrawn (MARC21 952$0)
1029   `itemcallnumber` varchar(255) default NULL, -- call number for this item (MARC21 952$o)
1030   `issues` smallint(6) default NULL, -- number of times this item has been checked out/issued
1031   `renewals` smallint(6) default NULL, -- number of times this item has been renewed
1032   `reserves` smallint(6) default NULL, -- number of times this item has been placed on hold/reserved
1033   `restricted` tinyint(1) default NULL, -- authorized value defining use restrictions for this item (MARC21 952$5)
1034   `itemnotes` mediumtext, -- public notes on this item (MARC21 952$x)
1035   `holdingbranch` varchar(10) default NULL, -- foreign key from the branches table for the library that is currently in possession item (MARC21 952$b)
1036   `paidfor` mediumtext,
1037   `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- date and time this item was last altered
1038   `location` varchar(80) default NULL, -- authorized value for the shelving location for this item (MARC21 952$c)
1039   `permanent_location` varchar(80) default NULL, -- linked to the CART and PROC temporary locations feature, stores the permanent shelving location
1040   `onloan` date default NULL, -- defines if this item is currently checked out (1 for yes, 0 for no)
1041   `cn_source` varchar(10) default NULL, -- classification source used on this item (MARC21 952$2)
1042   `cn_sort` varchar(30) default NULL,  -- normalized form of the call number (MARC21 952$o) used for sorting
1043   `ccode` varchar(10) default NULL, -- authorized value for the collection code associated with this item (MARC21 952$8)
1044   `materials` text default NULL, -- materials specified (MARC21 952$3)
1045   `uri` varchar(255) default NULL, -- URL for the item (MARC21 952$u)
1046   `itype` varchar(10) default NULL, -- foreign key from the itemtypes table defining the type for this item (MARC21 952$y)
1047   `more_subfields_xml` longtext default NULL, -- additional 952 subfields in XML format
1048   `enumchron` text default NULL, -- serial enumeration/chronology for the item (MARC21 952$h)
1049   `copynumber` varchar(32) default NULL, -- copy number (MARC21 952$t)
1050   `stocknumber` varchar(32) default NULL, -- inventory number (MARC21 952$i)
1051   PRIMARY KEY  (`itemnumber`),
1052   UNIQUE KEY `itembarcodeidx` (`barcode`),
1053   KEY `itemstocknumberidx` (`stocknumber`),
1054   KEY `itembinoidx` (`biblioitemnumber`),
1055   KEY `itembibnoidx` (`biblionumber`),
1056   KEY `homebranch` (`homebranch`),
1057   KEY `holdingbranch` (`holdingbranch`),
1058   KEY `itemcallnumber` (`itemcallnumber`),
1059   KEY `items_location` (`location`),
1060   KEY `items_ccode` (`ccode`),
1061   CONSTRAINT `items_ibfk_1` FOREIGN KEY (`biblioitemnumber`) REFERENCES `biblioitems` (`biblioitemnumber`) ON DELETE CASCADE ON UPDATE CASCADE,
1062   CONSTRAINT `items_ibfk_2` FOREIGN KEY (`homebranch`) REFERENCES `branches` (`branchcode`) ON UPDATE CASCADE,
1063   CONSTRAINT `items_ibfk_3` FOREIGN KEY (`holdingbranch`) REFERENCES `branches` (`branchcode`) ON UPDATE CASCADE
1064 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1065
1066 --
1067 -- Table structure for table `itemtypes`
1068 --
1069
1070 DROP TABLE IF EXISTS `itemtypes`;
1071 CREATE TABLE `itemtypes` ( -- defines the item types
1072   `itemtype` varchar(10) NOT NULL default '', -- unique key, a code associated with the item type
1073   `description` mediumtext, -- a plain text explanation of the item type
1074   `rentalcharge` double(16,4) default NULL, -- the amount charged when this item is checked out/issued
1075   `notforloan` smallint(6) default NULL, -- 1 if the item is not for loan, 0 if the item is available for loan
1076   `imageurl` varchar(200) default NULL, -- URL for the item type icon
1077   `summary` text, -- information from the summary field, may include HTML
1078   PRIMARY KEY  (`itemtype`),
1079   UNIQUE KEY `itemtype` (`itemtype`)
1080 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1081
1082 --
1083 -- Table structure for table `creator_batches`
1084 --
1085
1086 DROP TABLE IF EXISTS `creator_batches`;
1087 SET @saved_cs_client     = @@character_set_client;
1088 SET character_set_client = utf8;
1089 CREATE TABLE `creator_batches` (
1090   `label_id` int(11) NOT NULL AUTO_INCREMENT,
1091   `batch_id` int(10) NOT NULL DEFAULT '1',
1092   `item_number` int(11) DEFAULT NULL,
1093   `borrower_number` int(11) DEFAULT NULL,
1094   `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
1095   `branch_code` varchar(10) NOT NULL DEFAULT 'NB',
1096   `creator` char(15) NOT NULL DEFAULT 'Labels',
1097   PRIMARY KEY (`label_id`),
1098   KEY `branch_fk_constraint` (`branch_code`),
1099   KEY `item_fk_constraint` (`item_number`),
1100   KEY `borrower_fk_constraint` (`borrower_number`),
1101   CONSTRAINT `creator_batches_ibfk_1` FOREIGN KEY (`borrower_number`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
1102   CONSTRAINT `creator_batches_ibfk_2` FOREIGN KEY (`branch_code`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE,
1103   CONSTRAINT `creator_batches_ibfk_3` FOREIGN KEY (`item_number`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE
1104 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1105
1106 --
1107 -- Table structure for table `creator_images`
1108 --
1109
1110 DROP TABLE IF EXISTS `creator_images`;
1111 SET @saved_cs_client     = @@character_set_client;
1112 SET character_set_client = utf8;
1113 CREATE TABLE `creator_images` (
1114   `image_id` int(4) NOT NULL AUTO_INCREMENT,
1115   `imagefile` mediumblob,
1116   `image_name` char(20) NOT NULL DEFAULT 'DEFAULT',
1117   PRIMARY KEY (`image_id`),
1118   UNIQUE KEY `image_name_index` (`image_name`)
1119 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1120
1121 --
1122 -- Table structure for table `creator_layouts`
1123 --
1124
1125 DROP TABLE IF EXISTS `creator_layouts`;
1126 SET @saved_cs_client     = @@character_set_client;
1127 SET character_set_client = utf8;
1128 CREATE TABLE `creator_layouts` (
1129   `layout_id` int(4) NOT NULL AUTO_INCREMENT,
1130   `barcode_type` char(100) NOT NULL DEFAULT 'CODE39',
1131   `start_label` int(2) NOT NULL DEFAULT '1',
1132   `printing_type` char(32) NOT NULL DEFAULT 'BAR',
1133   `layout_name` char(20) NOT NULL DEFAULT 'DEFAULT',
1134   `guidebox` int(1) DEFAULT '0',
1135   `font` char(10) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT 'TR',
1136   `font_size` int(4) NOT NULL DEFAULT '10',
1137   `units` char(20) NOT NULL DEFAULT 'POINT',
1138   `callnum_split` int(1) DEFAULT '0',
1139   `text_justify` char(1) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT 'L',
1140   `format_string` varchar(210) NOT NULL DEFAULT 'barcode',
1141   `layout_xml` text NOT NULL,
1142   `creator` char(15) NOT NULL DEFAULT 'Labels',
1143   PRIMARY KEY (`layout_id`)
1144 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1145
1146 --
1147 -- Table structure for table `creator_templates`
1148 --
1149
1150 DROP TABLE IF EXISTS `creator_templates`;
1151 SET @saved_cs_client     = @@character_set_client;
1152 SET character_set_client = utf8;
1153 CREATE TABLE `creator_templates` (
1154   `template_id` int(4) NOT NULL AUTO_INCREMENT,
1155   `profile_id` int(4) DEFAULT NULL,
1156   `template_code` char(100) NOT NULL DEFAULT 'DEFAULT TEMPLATE',
1157   `template_desc` char(100) NOT NULL DEFAULT 'Default description',
1158   `page_width` float NOT NULL DEFAULT '0',
1159   `page_height` float NOT NULL DEFAULT '0',
1160   `label_width` float NOT NULL DEFAULT '0',
1161   `label_height` float NOT NULL DEFAULT '0',
1162   `top_text_margin` float NOT NULL DEFAULT '0',
1163   `left_text_margin` float NOT NULL DEFAULT '0',
1164   `top_margin` float NOT NULL DEFAULT '0',
1165   `left_margin` float NOT NULL DEFAULT '0',
1166   `cols` int(2) NOT NULL DEFAULT '0',
1167   `rows` int(2) NOT NULL DEFAULT '0',
1168   `col_gap` float NOT NULL DEFAULT '0',
1169   `row_gap` float NOT NULL DEFAULT '0',
1170   `units` char(20) NOT NULL DEFAULT 'POINT',
1171   `creator` char(15) NOT NULL DEFAULT 'Labels',
1172   PRIMARY KEY (`template_id`),
1173   KEY `template_profile_fk_constraint` (`profile_id`)
1174 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1175
1176 --
1177 -- Table structure for table `letter`
1178 --
1179
1180 DROP TABLE IF EXISTS `letter`;
1181 CREATE TABLE `letter` ( -- table for all notice templates in Koha
1182   `module` varchar(20) NOT NULL default '', -- Koha module that triggers this notice
1183   `code` varchar(20) NOT NULL default '', -- unique identifier for this notice
1184   `branchcode` varchar(10) default NULL, -- foreign key, linking to the branches table for the location the item was checked out
1185   `name` varchar(100) NOT NULL default '', -- plain text name for this notice
1186   `is_html` tinyint(1) default 0,
1187   `title` varchar(200) NOT NULL default '', -- subject line of the notice
1188   `content` text, -- body text for the notice
1189   PRIMARY KEY  (`module`,`code`, `branchcode`)
1190 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1191
1192 --
1193 -- Table structure for table `marc_subfield_structure`
1194 --
1195
1196 DROP TABLE IF EXISTS `marc_subfield_structure`;
1197 CREATE TABLE `marc_subfield_structure` (
1198   `tagfield` varchar(3) NOT NULL default '',
1199   `tagsubfield` varchar(1) NOT NULL default '' COLLATE utf8_bin,
1200   `liblibrarian` varchar(255) NOT NULL default '',
1201   `libopac` varchar(255) NOT NULL default '',
1202   `repeatable` tinyint(4) NOT NULL default 0,
1203   `mandatory` tinyint(4) NOT NULL default 0,
1204   `kohafield` varchar(40) default NULL,
1205   `tab` tinyint(1) default NULL,
1206   `authorised_value` varchar(20) default NULL,
1207   `authtypecode` varchar(20) default NULL,
1208   `value_builder` varchar(80) default NULL,
1209   `isurl` tinyint(1) default NULL,
1210   `hidden` tinyint(1) default NULL,
1211   `frameworkcode` varchar(4) NOT NULL default '',
1212   `seealso` varchar(1100) default NULL,
1213   `link` varchar(80) default NULL,
1214   `defaultvalue` text default NULL,
1215   `maxlength` int(4) NOT NULL DEFAULT '9999',
1216   PRIMARY KEY  (`frameworkcode`,`tagfield`,`tagsubfield`),
1217   KEY `kohafield_2` (`kohafield`),
1218   KEY `tab` (`frameworkcode`,`tab`),
1219   KEY `kohafield` (`frameworkcode`,`kohafield`)
1220 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1221
1222 --
1223 -- Table structure for table `marc_tag_structure`
1224 --
1225
1226 DROP TABLE IF EXISTS `marc_tag_structure`;
1227 CREATE TABLE `marc_tag_structure` (
1228   `tagfield` varchar(3) NOT NULL default '',
1229   `liblibrarian` varchar(255) NOT NULL default '',
1230   `libopac` varchar(255) NOT NULL default '',
1231   `repeatable` tinyint(4) NOT NULL default 0,
1232   `mandatory` tinyint(4) NOT NULL default 0,
1233   `authorised_value` varchar(10) default NULL,
1234   `frameworkcode` varchar(4) NOT NULL default '',
1235   PRIMARY KEY  (`frameworkcode`,`tagfield`)
1236 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1237
1238 --
1239 -- Table structure for table `marc_matchers`
1240 --
1241
1242 DROP TABLE IF EXISTS `marc_matchers`;
1243 CREATE TABLE `marc_matchers` (
1244   `matcher_id` int(11) NOT NULL auto_increment,
1245   `code` varchar(10) NOT NULL default '',
1246   `description` varchar(255) NOT NULL default '',
1247   `record_type` varchar(10) NOT NULL default 'biblio',
1248   `threshold` int(11) NOT NULL default 0,
1249   PRIMARY KEY (`matcher_id`),
1250   KEY `code` (`code`),
1251   KEY `record_type` (`record_type`)
1252 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1253
1254 --
1255 -- Table structure for table `matchpoints`
1256 --
1257 DROP TABLE IF EXISTS `matchpoints`;
1258 CREATE TABLE `matchpoints` (
1259   `matcher_id` int(11) NOT NULL,
1260   `matchpoint_id` int(11) NOT NULL auto_increment,
1261   `search_index` varchar(30) NOT NULL default '',
1262   `score` int(11) NOT NULL default 0,
1263   PRIMARY KEY (`matchpoint_id`),
1264   CONSTRAINT `matchpoints_ifbk_1` FOREIGN KEY (`matcher_id`)
1265   REFERENCES `marc_matchers` (`matcher_id`) ON DELETE CASCADE ON UPDATE CASCADE
1266 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1267
1268
1269 --
1270 -- Table structure for table `matchpoint_components`
1271 --
1272 DROP TABLE IF EXISTS `matchpoint_components`;
1273 CREATE TABLE `matchpoint_components` (
1274   `matchpoint_id` int(11) NOT NULL,
1275   `matchpoint_component_id` int(11) NOT NULL auto_increment,
1276   sequence int(11) NOT NULL default 0,
1277   tag varchar(3) NOT NULL default '',
1278   subfields varchar(40) NOT NULL default '',
1279   offset int(4) NOT NULL default 0,
1280   length int(4) NOT NULL default 0,
1281   PRIMARY KEY (`matchpoint_component_id`),
1282   KEY `by_sequence` (`matchpoint_id`, `sequence`),
1283   CONSTRAINT `matchpoint_components_ifbk_1` FOREIGN KEY (`matchpoint_id`)
1284   REFERENCES `matchpoints` (`matchpoint_id`) ON DELETE CASCADE ON UPDATE CASCADE
1285 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1286
1287 --
1288 -- Table structure for table `matcher_component_norms`
1289 --
1290 DROP TABLE IF EXISTS `matchpoint_component_norms`;
1291 CREATE TABLE `matchpoint_component_norms` (
1292   `matchpoint_component_id` int(11) NOT NULL,
1293   `sequence`  int(11) NOT NULL default 0,
1294   `norm_routine` varchar(50) NOT NULL default '',
1295   KEY `matchpoint_component_norms` (`matchpoint_component_id`, `sequence`),
1296   CONSTRAINT `matchpoint_component_norms_ifbk_1` FOREIGN KEY (`matchpoint_component_id`)
1297   REFERENCES `matchpoint_components` (`matchpoint_component_id`) ON DELETE CASCADE ON UPDATE CASCADE
1298 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1299
1300 --
1301 -- Table structure for table `matcher_matchpoints`
1302 --
1303 DROP TABLE IF EXISTS `matcher_matchpoints`;
1304 CREATE TABLE `matcher_matchpoints` (
1305   `matcher_id` int(11) NOT NULL,
1306   `matchpoint_id` int(11) NOT NULL,
1307   CONSTRAINT `matcher_matchpoints_ifbk_1` FOREIGN KEY (`matcher_id`)
1308   REFERENCES `marc_matchers` (`matcher_id`) ON DELETE CASCADE ON UPDATE CASCADE,
1309   CONSTRAINT `matcher_matchpoints_ifbk_2` FOREIGN KEY (`matchpoint_id`)
1310   REFERENCES `matchpoints` (`matchpoint_id`) ON DELETE CASCADE ON UPDATE CASCADE
1311 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1312
1313 --
1314 -- Table structure for table `matchchecks`
1315 --
1316 DROP TABLE IF EXISTS `matchchecks`;
1317 CREATE TABLE `matchchecks` (
1318   `matcher_id` int(11) NOT NULL,
1319   `matchcheck_id` int(11) NOT NULL auto_increment,
1320   `source_matchpoint_id` int(11) NOT NULL,
1321   `target_matchpoint_id` int(11) NOT NULL,
1322   PRIMARY KEY (`matchcheck_id`),
1323   CONSTRAINT `matcher_matchchecks_ifbk_1` FOREIGN KEY (`matcher_id`)
1324   REFERENCES `marc_matchers` (`matcher_id`) ON DELETE CASCADE ON UPDATE CASCADE,
1325   CONSTRAINT `matcher_matchchecks_ifbk_2` FOREIGN KEY (`source_matchpoint_id`)
1326   REFERENCES `matchpoints` (`matchpoint_id`) ON DELETE CASCADE ON UPDATE CASCADE,
1327   CONSTRAINT `matcher_matchchecks_ifbk_3` FOREIGN KEY (`target_matchpoint_id`)
1328   REFERENCES `matchpoints` (`matchpoint_id`) ON DELETE CASCADE ON UPDATE CASCADE
1329 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1330
1331 --
1332 -- Table structure for table `need_merge_authorities`
1333 --
1334
1335 DROP TABLE IF EXISTS `need_merge_authorities`;
1336 CREATE TABLE `need_merge_authorities` ( -- keeping track of authority records still to be merged by merge_authority cron job (used only if pref dontmerge is ON)
1337   `id` int NOT NULL auto_increment PRIMARY KEY, -- unique id
1338   `authid` bigint NOT NULL, -- reference to authority record
1339   `done` tinyint DEFAULT 0  -- indication whether merge has been executed (0=not done, 1= done, 2= in progress)
1340 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1341
1342 --
1343 -- Table structure for table `notifys`
1344 --
1345
1346 DROP TABLE IF EXISTS `notifys`;
1347 CREATE TABLE `notifys` (
1348   `notify_id` int(11) NOT NULL default 0,
1349   `borrowernumber` int(11) NOT NULL default 0,
1350   `itemnumber` int(11) NOT NULL default 0,
1351   `notify_date` date default NULL,
1352   `notify_send_date` date default NULL,
1353   `notify_level` int(1) NOT NULL default 0,
1354   `method` varchar(20) NOT NULL default ''
1355 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1356
1357 --
1358 -- Table structure for table `nozebra`
1359 --
1360
1361 DROP TABLE IF EXISTS `nozebra`;
1362 CREATE TABLE `nozebra` (
1363   `server` varchar(20)     NOT NULL,
1364   `indexname` varchar(40)  NOT NULL,
1365   `value` varchar(250)     NOT NULL,
1366   `biblionumbers` longtext NOT NULL,
1367   KEY `indexname` (`server`,`indexname`),
1368   KEY `value` (`server`,`value`))
1369   ENGINE=InnoDB DEFAULT CHARSET=utf8;
1370
1371 --
1372 -- Table structure for table `oai_sets`
1373 --
1374
1375 DROP TABLE IF EXISTS `oai_sets`;
1376 CREATE TABLE `oai_sets` (
1377   `id` int(11) NOT NULL auto_increment,
1378   `spec` varchar(80) NOT NULL UNIQUE,
1379   `name` varchar(80) NOT NULL,
1380   PRIMARY KEY (`id`)
1381 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1382
1383 --
1384 -- Table structure for table `oai_sets_descriptions`
1385 --
1386
1387 DROP TABLE IF EXISTS `oai_sets_descriptions`;
1388 CREATE TABLE `oai_sets_descriptions` (
1389   `set_id` int(11) NOT NULL,
1390   `description` varchar(255) NOT NULL,
1391   CONSTRAINT `oai_sets_descriptions_ibfk_1` FOREIGN KEY (`set_id`) REFERENCES `oai_sets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
1392 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1393
1394 --
1395 -- Table structure for table `oai_sets_mappings`
1396 --
1397
1398 DROP TABLE IF EXISTS `oai_sets_mappings`;
1399 CREATE TABLE `oai_sets_mappings` (
1400   `set_id` int(11) NOT NULL,
1401   `marcfield` char(3) NOT NULL,
1402   `marcsubfield` char(1) NOT NULL,
1403   `marcvalue` varchar(80) NOT NULL,
1404   CONSTRAINT `oai_sets_mappings_ibfk_1` FOREIGN KEY (`set_id`) REFERENCES `oai_sets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
1405 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1406
1407 --
1408 -- Table structure for table `oai_sets_biblios`
1409 --
1410
1411 DROP TABLE IF EXISTS `oai_sets_biblios`;
1412 CREATE TABLE `oai_sets_biblios` (
1413   `biblionumber` int(11) NOT NULL,
1414   `set_id` int(11) NOT NULL,
1415   PRIMARY KEY (`biblionumber`, `set_id`),
1416   CONSTRAINT `oai_sets_biblios_ibfk_1` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE,
1417   CONSTRAINT `oai_sets_biblios_ibfk_2` FOREIGN KEY (`set_id`) REFERENCES `oai_sets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
1418 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1419
1420 --
1421 -- Table structure for table `old_issues`
1422 --
1423
1424 DROP TABLE IF EXISTS `old_issues`;
1425 CREATE TABLE `old_issues` ( -- lists items that were checked out and have been returned
1426   `borrowernumber` int(11) default NULL, -- foreign key, linking this to the borrowers table for the patron this item was checked out to
1427   `itemnumber` int(11) default NULL, -- foreign key, linking this to the items table for the item that was checked out
1428   `date_due` datetime default NULL, -- date the item is due (yyyy-mm-dd)
1429   `branchcode` varchar(10) default NULL, -- foreign key, linking to the branches table for the location the item was checked out
1430   `issuingbranch` varchar(18) default NULL,
1431   `returndate` datetime default NULL, -- date the item was returned
1432   `lastreneweddate` datetime default NULL, -- date the item was last renewed
1433   `return` varchar(4) default NULL,
1434   `renewals` tinyint(4) default NULL, -- lists the number of times the item was renewed
1435   `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- the date and time this record was last touched
1436   `issuedate` datetime default NULL, -- date the item was checked out or issued
1437   KEY `old_issuesborridx` (`borrowernumber`),
1438   KEY `old_issuesitemidx` (`itemnumber`),
1439   KEY `old_bordate` (`borrowernumber`,`timestamp`),
1440   CONSTRAINT `old_issues_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`)
1441     ON DELETE SET NULL ON UPDATE SET NULL,
1442   CONSTRAINT `old_issues_ibfk_2` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`)
1443     ON DELETE SET NULL ON UPDATE SET NULL
1444 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1445
1446 --
1447 -- Table structure for table `old_reserves`
1448 --
1449 DROP TABLE IF EXISTS `old_reserves`;
1450 CREATE TABLE `old_reserves` ( -- this table holds all holds/reserves that have been completed (either filled or cancelled)
1451   `reserve_id` int(11) NOT NULL, -- primary key
1452   `borrowernumber` int(11) default NULL, -- foreign key from the borrowers table defining which patron this hold is for
1453   `reservedate` date default NULL, -- the date the hold was places
1454   `biblionumber` int(11) default NULL, -- foreign key from the biblio table defining which bib record this hold is on
1455   `constrainttype` varchar(1) default NULL,
1456   `branchcode` varchar(10) default NULL, -- foreign key from the branches table defining which branch the patron wishes to pick this hold up at
1457   `notificationdate` date default NULL, -- currently unused
1458   `reminderdate` date default NULL, -- currently unused
1459   `cancellationdate` date default NULL, -- the date this hold was cancelled
1460   `reservenotes` mediumtext, -- notes related to this hold
1461   `priority` smallint(6) default NULL, -- where in the queue the patron sits
1462   `found` varchar(1) default NULL, -- a one letter code defining what the status is of the hold is after it has been confirmed
1463   `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- the date and time this hold was last updated
1464   `itemnumber` int(11) default NULL, -- foreign key from the items table defining the specific item the patron has placed on hold or the item this hold was filled with
1465   `waitingdate` date default NULL, -- the date the item was marked as waiting for the patron at the library
1466   `expirationdate` DATE DEFAULT NULL, -- the date the hold expires (usually the date entered by the patron to say they don't need the hold after a certain date)
1467   `lowestPriority` tinyint(1) NOT NULL,
1468   `suspend` BOOLEAN NOT NULL DEFAULT 0,
1469   `suspend_until` DATETIME NULL DEFAULT NULL,
1470   PRIMARY KEY (`reserve_id`),
1471   KEY `old_reserves_borrowernumber` (`borrowernumber`),
1472   KEY `old_reserves_biblionumber` (`biblionumber`),
1473   KEY `old_reserves_itemnumber` (`itemnumber`),
1474   KEY `old_reserves_branchcode` (`branchcode`),
1475   CONSTRAINT `old_reserves_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`)
1476     ON DELETE SET NULL ON UPDATE SET NULL,
1477   CONSTRAINT `old_reserves_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`)
1478     ON DELETE SET NULL ON UPDATE SET NULL,
1479   CONSTRAINT `old_reserves_ibfk_3` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`)
1480     ON DELETE SET NULL ON UPDATE SET NULL
1481 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1482
1483 --
1484 -- Table structure for table `opac_news`
1485 --
1486
1487 DROP TABLE IF EXISTS `opac_news`;
1488 CREATE TABLE `opac_news` ( -- data from the news tool
1489   `idnew` int(10) unsigned NOT NULL auto_increment, -- unique identifier for the news article
1490   `title` varchar(250) NOT NULL default '', -- title of the news article
1491   `new` text NOT NULL, -- the body of your news article
1492   `lang` varchar(25) NOT NULL default '', -- location for the article (koha is the staff client, slip is the circulation receipt and language codes are for the opac)
1493   `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP, -- pulibcation date and time
1494   `expirationdate` date default NULL, -- date the article is set to expire or no longer be visible
1495   `number` int(11) default NULL, -- the order in which this article appears in that specific location
1496   PRIMARY KEY  (`idnew`)
1497 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1498
1499 --
1500 -- Table structure for table `overduerules`
1501 --
1502
1503 DROP TABLE IF EXISTS `overduerules`;
1504 CREATE TABLE `overduerules` ( -- overdue notice status and triggers
1505   `branchcode` varchar(10) NOT NULL default '', -- foreign key from the branches table to define which branch this rule is for (if blank it's all libraries)
1506   `categorycode` varchar(10) NOT NULL default '', -- foreign key from the categories table to define which patron category this rule is for
1507   `delay1` int(4) default NULL, -- number of days after the item is overdue that the first notice is sent
1508   `letter1` varchar(20) default NULL, -- foreign key from the letter table to define which notice should be sent as the first notice
1509   `debarred1` varchar(1) default 0, -- is the patron restricted when the first notice is sent (1 for yes, 0 for no)
1510   `delay2` int(4) default NULL, -- number of days after the item is overdue that the second notice is sent
1511   `debarred2` varchar(1) default 0, -- is the patron restricted when the second notice is sent (1 for yes, 0 for no)
1512   `letter2` varchar(20) default NULL, -- foreign key from the letter table to define which notice should be sent as the second notice
1513   `delay3` int(4) default NULL, -- number of days after the item is overdue that the third notice is sent
1514   `letter3` varchar(20) default NULL, -- foreign key from the letter table to define which notice should be sent as the third notice
1515   `debarred3` int(1) default 0, -- is the patron restricted when the third notice is sent (1 for yes, 0 for no)
1516   PRIMARY KEY  (`branchcode`,`categorycode`)
1517 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1518
1519 --
1520 -- Table structure for table `patroncards`
1521 --
1522
1523 DROP TABLE IF EXISTS `patroncards`;
1524 CREATE TABLE `patroncards` (
1525   `cardid` int(11) NOT NULL auto_increment,
1526   `batch_id` varchar(10) NOT NULL default '1',
1527   `borrowernumber` int(11) NOT NULL,
1528   `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
1529    PRIMARY KEY  (`cardid`),
1530    KEY `patroncards_ibfk_1` (`borrowernumber`),
1531    CONSTRAINT `patroncards_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE
1532 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1533
1534 --
1535 -- Table structure for table `patronimage`
1536 --
1537
1538 DROP TABLE IF EXISTS `patronimage`;
1539 CREATE TABLE `patronimage` (
1540   `cardnumber` varchar(16) NOT NULL,
1541   `mimetype` varchar(15) NOT NULL,
1542   `imagefile` mediumblob NOT NULL,
1543   PRIMARY KEY  (`cardnumber`),
1544   CONSTRAINT `patronimage_fk1` FOREIGN KEY (`cardnumber`) REFERENCES `borrowers` (`cardnumber`) ON DELETE CASCADE ON UPDATE CASCADE
1545 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1546
1547 -- Table structure for table `pending_offline_operations`
1548 --
1549 -- this table is MyISAM, InnoDB tables are growing only and this table is filled/emptied/filled/emptied...
1550 -- so MyISAM is better in this case
1551
1552 DROP TABLE IF EXISTS `pending_offline_operations`;
1553 CREATE TABLE `pending_offline_operations` (
1554   `operationid` int(11) NOT NULL AUTO_INCREMENT,
1555   `userid` varchar(30) NOT NULL,
1556   `branchcode` varchar(10) NOT NULL,
1557   `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
1558   `action` varchar(10) NOT NULL,
1559   `barcode` varchar(20) NOT NULL,
1560   `cardnumber` varchar(16) DEFAULT NULL,
1561   PRIMARY KEY (`operationid`)
1562 ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
1563
1564
1565
1566 --
1567 -- Table structure for table `printers`
1568 --
1569
1570 DROP TABLE IF EXISTS `printers`;
1571 CREATE TABLE `printers` (
1572   `printername` varchar(40) NOT NULL default '',
1573   `printqueue` varchar(20) default NULL,
1574   `printtype` varchar(20) default NULL,
1575   PRIMARY KEY  (`printername`)
1576 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1577
1578 --
1579 -- Table structure for table `printers_profile`
1580 --
1581
1582 DROP TABLE IF EXISTS `printers_profile`;
1583 CREATE TABLE `printers_profile` (
1584   `profile_id` int(4) NOT NULL auto_increment,
1585   `printer_name` varchar(40) NOT NULL default 'Default Printer',
1586   `template_id` int(4) NOT NULL default '0',
1587   `paper_bin` varchar(20) NOT NULL default 'Bypass',
1588   `offset_horz` float NOT NULL default '0',
1589   `offset_vert` float NOT NULL default '0',
1590   `creep_horz` float NOT NULL default '0',
1591   `creep_vert` float NOT NULL default '0',
1592   `units` char(20) NOT NULL default 'POINT',
1593   `creator` char(15) NOT NULL DEFAULT 'Labels',
1594   PRIMARY KEY  (`profile_id`),
1595   UNIQUE KEY `printername` (`printer_name`,`template_id`,`paper_bin`,`creator`)
1596 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1597
1598 --
1599 -- Table structure for table `repeatable_holidays`
1600 --
1601
1602 DROP TABLE IF EXISTS `repeatable_holidays`;
1603 CREATE TABLE `repeatable_holidays` ( -- information for the days the library is closed
1604   `id` int(11) NOT NULL auto_increment, -- unique identifier assigned by Koha
1605   `branchcode` varchar(10) NOT NULL default '', -- foreign key from the branches table, defines which branch this closing is for
1606   `weekday` smallint(6) default NULL, -- day of the week (0=Sunday, 1=Monday, etc) this closing is repeated on
1607   `day` smallint(6) default NULL, -- day of the month this closing is on
1608   `month` smallint(6) default NULL, -- month this closing is in
1609   `title` varchar(50) NOT NULL default '', -- title of this closing
1610   `description` text NOT NULL, -- description for this closing
1611   PRIMARY KEY  (`id`)
1612 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1613
1614 --
1615 -- Table structure for table `reports_dictionary`
1616 --
1617
1618 DROP TABLE IF EXISTS `reports_dictionary`;
1619 CREATE TABLE reports_dictionary ( -- definitions (or snippets of SQL) stored for use in reports
1620    `id` int(11) NOT NULL auto_increment, -- unique identifier assigned by Koha
1621    `name` varchar(255) default NULL, -- name for this definition
1622    `description` text, -- description for this definition
1623    `date_created` datetime default NULL, -- date and time this definition was created
1624    `date_modified` datetime default NULL, -- date and time this definition was last modified
1625    `saved_sql` text, -- SQL snippet for us in reports
1626    `area` int(11) default NULL, -- Koha module this definition is for (1 = Circulation, 2 = Catalog, 3 = Patrons, 4 = Acquistions, 5 = Accounts)
1627    PRIMARY KEY  (`id`)
1628 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1629
1630 --
1631 -- Table structure for table `reserveconstraints`
1632 --
1633
1634 DROP TABLE IF EXISTS `reserveconstraints`;
1635 CREATE TABLE `reserveconstraints` (
1636   `borrowernumber` int(11) NOT NULL default 0,
1637   `reservedate` date default NULL,
1638   `biblionumber` int(11) NOT NULL default 0,
1639   `biblioitemnumber` int(11) default NULL,
1640   `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP
1641 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1642
1643 --
1644 -- Table structure for table `reserves`
1645 --
1646
1647 DROP TABLE IF EXISTS `reserves`;
1648 CREATE TABLE `reserves` ( -- information related to holds/reserves in Koha
1649   `reserve_id` int(11) NOT NULL auto_increment, -- primary key
1650   `borrowernumber` int(11) NOT NULL default 0, -- foreign key from the borrowers table defining which patron this hold is for
1651   `reservedate` date default NULL, -- the date the hold was places
1652   `biblionumber` int(11) NOT NULL default 0, -- foreign key from the biblio table defining which bib record this hold is on
1653   `constrainttype` varchar(1) default NULL,
1654   `branchcode` varchar(10) default NULL, -- foreign key from the branches table defining which branch the patron wishes to pick this hold up at
1655   `notificationdate` date default NULL, -- currently unused
1656   `reminderdate` date default NULL, -- currently unused
1657   `cancellationdate` date default NULL, -- the date this hold was cancelled
1658   `reservenotes` mediumtext, -- notes related to this hold
1659   `priority` smallint(6) default NULL, -- where in the queue the patron sits
1660   `found` varchar(1) default NULL, -- a one letter code defining what the status is of the hold is after it has been confirmed
1661   `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- the date and time this hold was last updated
1662   `itemnumber` int(11) default NULL, -- foreign key from the items table defining the specific item the patron has placed on hold or the item this hold was filled with
1663   `waitingdate` date default NULL, -- the date the item was marked as waiting for the patron at the library
1664   `expirationdate` DATE DEFAULT NULL, -- the date the hold expires (usually the date entered by the patron to say they don't need the hold after a certain date)
1665   `lowestPriority` tinyint(1) NOT NULL,
1666   `suspend` BOOLEAN NOT NULL DEFAULT 0,
1667   `suspend_until` DATETIME NULL DEFAULT NULL,
1668   PRIMARY KEY (`reserve_id`),
1669   KEY priorityfoundidx (priority,found),
1670   KEY `borrowernumber` (`borrowernumber`),
1671   KEY `biblionumber` (`biblionumber`),
1672   KEY `itemnumber` (`itemnumber`),
1673   KEY `branchcode` (`branchcode`),
1674   CONSTRAINT `reserves_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
1675   CONSTRAINT `reserves_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE,
1676   CONSTRAINT `reserves_ibfk_3` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE,
1677   CONSTRAINT `reserves_ibfk_4` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE
1678 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1679
1680 --
1681 -- Table structure for table `reviews`
1682 --
1683
1684 DROP TABLE IF EXISTS `reviews`;
1685 CREATE TABLE `reviews` ( -- patron opac comments
1686   `reviewid` int(11) NOT NULL auto_increment, -- unique identifier for this comment
1687   `borrowernumber` int(11) default NULL, -- foreign key from the borrowers table defining which patron left this comment
1688   `biblionumber` int(11) default NULL, -- foreign key from the biblio table defining which bibliographic record this comment is for
1689   `review` text, -- the body of the comment
1690   `approved` tinyint(4) default NULL, -- whether this comment has been approved by a librarian (1 for yes, 0 for no)
1691   `datereviewed` datetime default NULL, -- the date the comment was left
1692   PRIMARY KEY  (`reviewid`),
1693   CONSTRAINT `reviews_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE,
1694   CONSTRAINT `reviews_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE
1695 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1696
1697 --
1698 -- Table structure for table `roadtype`
1699 --
1700
1701 DROP TABLE IF EXISTS `roadtype`;
1702 CREATE TABLE `roadtype` ( -- road types defined in administration and used in patron management
1703   `roadtypeid` int(11) NOT NULL auto_increment, -- unique identifier assigned by Koha for each road type
1704   `road_type` varchar(100) NOT NULL default '', -- text for road type
1705   PRIMARY KEY  (`roadtypeid`)
1706 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1707
1708 --
1709 -- Table structure for table `saved_sql`
1710 --
1711
1712 DROP TABLE IF EXISTS `saved_sql`;
1713 CREATE TABLE saved_sql (
1714    `id` int(11) NOT NULL auto_increment,
1715    `borrowernumber` int(11) default NULL,
1716    `date_created` datetime default NULL,
1717    `last_modified` datetime default NULL,
1718    `savedsql` text,
1719    `last_run` datetime default NULL,
1720    `report_name` varchar(255) default NULL,
1721    `type` varchar(255) default NULL,
1722    `notes` text,
1723    `cache_expiry` int NOT NULL default 300,
1724    `public` boolean NOT NULL default FALSE,
1725    PRIMARY KEY  (`id`),
1726    KEY boridx (`borrowernumber`)
1727 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1728
1729
1730 --
1731 -- Table structure for `saved_reports`
1732 --
1733
1734 DROP TABLE IF EXISTS `saved_reports`;
1735 CREATE TABLE saved_reports (
1736    `id` int(11) NOT NULL auto_increment,
1737    `report_id` int(11) default NULL,
1738    `report` longtext,
1739    `date_run` datetime default NULL,
1740    PRIMARY KEY  (`id`)
1741 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1742
1743
1744 --
1745 -- Table structure for table `search_history`
1746 --
1747
1748 DROP TABLE IF EXISTS `search_history`;
1749 CREATE TABLE IF NOT EXISTS `search_history` (
1750   `userid` int(11) NOT NULL,
1751   `sessionid` varchar(32) NOT NULL,
1752   `query_desc` varchar(255) NOT NULL,
1753   `query_cgi` text NOT NULL,
1754   `total` int(11) NOT NULL,
1755   `time` timestamp NOT NULL default CURRENT_TIMESTAMP,
1756   KEY `userid` (`userid`),
1757   KEY `sessionid` (`sessionid`)
1758 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Opac search history results';
1759
1760
1761 --
1762 -- Table structure for table `serial`
1763 --
1764
1765 DROP TABLE IF EXISTS `serial`;
1766 CREATE TABLE `serial` (
1767   `serialid` int(11) NOT NULL auto_increment,
1768   `biblionumber` varchar(100) NOT NULL default '',
1769   `subscriptionid` varchar(100) NOT NULL default '',
1770   `serialseq` varchar(100) NOT NULL default '',
1771   `status` tinyint(4) NOT NULL default 0,
1772   `planneddate` date default NULL,
1773   `notes` text,
1774   `publisheddate` date default NULL,
1775   `itemnumber` text default NULL,
1776   `claimdate` date default NULL,
1777   `routingnotes` text,
1778   PRIMARY KEY  (`serialid`)
1779 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1780
1781 --
1782 -- Table structure for table `sessions`
1783 --
1784
1785 DROP TABLE IF EXISTS sessions;
1786 CREATE TABLE sessions (
1787   `id` varchar(32) NOT NULL,
1788   `a_session` text NOT NULL,
1789   PRIMARY KEY (`id`)
1790 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1791
1792 --
1793 -- Table structure for table `special_holidays`
1794 --
1795
1796 DROP TABLE IF EXISTS `special_holidays`;
1797 CREATE TABLE `special_holidays` ( -- non repeatable holidays/library closings
1798   `id` int(11) NOT NULL auto_increment, -- unique identifier assigned by Koha
1799   `branchcode` varchar(10) NOT NULL default '', -- foreign key from the branches table, defines which branch this closing is for
1800   `day` smallint(6) NOT NULL default 0, -- day of the month this closing is on
1801   `month` smallint(6) NOT NULL default 0, -- month this closing is in
1802   `year` smallint(6) NOT NULL default 0, -- year this closing is in
1803   `isexception` smallint(1) NOT NULL default 1, -- is this a holiday exception to a repeatable holiday (1 for yes, 0 for no)
1804   `title` varchar(50) NOT NULL default '', -- title for this closing
1805   `description` text NOT NULL, -- description of this closing
1806   PRIMARY KEY  (`id`)
1807 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1808
1809 --
1810 -- Table structure for table `statistics`
1811 --
1812
1813 DROP TABLE IF EXISTS `statistics`;
1814 CREATE TABLE `statistics` ( -- information related to transactions (circulation and fines) in Koha
1815   `datetime` datetime default NULL, -- date and time of the transaction
1816   `branch` varchar(10) default NULL, -- foreign key, branch where the transaction occurred
1817   `proccode` varchar(4) default NULL, -- proceedure code 
1818   `value` double(16,4) default NULL, -- monetary value associated with the transaction
1819   `type` varchar(16) default NULL, -- transaction type (locause, issue, return, renew, writeoff, payment, Credit*)
1820   `other` mediumtext,
1821   `usercode` varchar(10) default NULL,
1822   `itemnumber` int(11) default NULL, -- foreign key from the items table, links transaction to a specific item
1823   `itemtype` varchar(10) default NULL, -- foreign key from the itemtypes table, links transaction to a specific item type
1824   `borrowernumber` int(11) default NULL, -- foreign key from the borrowers table, links transaction to a specific borrower
1825   `associatedborrower` int(11) default NULL,
1826   KEY `timeidx` (`datetime`)
1827 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1828
1829 --
1830 -- Table structure for table `stopwords`
1831 --
1832
1833 DROP TABLE IF EXISTS `stopwords`;
1834   CREATE TABLE `stopwords` (
1835   `word` varchar(255) default NULL
1836 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1837
1838 --
1839 -- Table structure for table `subscription`
1840 --
1841
1842 DROP TABLE IF EXISTS `subscription`;
1843 CREATE TABLE `subscription` (
1844   `biblionumber` int(11) NOT NULL default 0,
1845   `subscriptionid` int(11) NOT NULL auto_increment,
1846   `librarian` varchar(100) default '',
1847   `startdate` date default NULL,
1848   `aqbooksellerid` int(11) default 0,
1849   `cost` int(11) default 0,
1850   `aqbudgetid` int(11) default 0,
1851   `weeklength` int(11) default 0,
1852   `monthlength` int(11) default 0,
1853   `numberlength` int(11) default 0,
1854   `periodicity` tinyint(4) default 0,
1855   `dow` varchar(100) default '',
1856   `numberingmethod` varchar(100) default '',
1857   `notes` mediumtext,
1858   `status` varchar(100) NOT NULL default '',
1859   `add1` int(11) default 0,
1860   `every1` int(11) default 0,
1861   `whenmorethan1` int(11) default 0,
1862   `setto1` int(11) default NULL,
1863   `lastvalue1` int(11) default NULL,
1864   `add2` int(11) default 0,
1865   `every2` int(11) default 0,
1866   `whenmorethan2` int(11) default 0,
1867   `setto2` int(11) default NULL,
1868   `lastvalue2` int(11) default NULL,
1869   `add3` int(11) default 0,
1870   `every3` int(11) default 0,
1871   `innerloop1` int(11) default 0,
1872   `innerloop2` int(11) default 0,
1873   `innerloop3` int(11) default 0,
1874   `whenmorethan3` int(11) default 0,
1875   `setto3` int(11) default NULL,
1876   `lastvalue3` int(11) default NULL,
1877   `issuesatonce` tinyint(3) NOT NULL default 1,
1878   `firstacquidate` date default NULL,
1879   `manualhistory` tinyint(1) NOT NULL default 0,
1880   `irregularity` text,
1881   `letter` varchar(20) default NULL,
1882   `numberpattern` tinyint(3) default 0,
1883   `distributedto` text,
1884   `internalnotes` longtext,
1885   `callnumber` text,
1886   `location` varchar(80) NULL default '',
1887   `branchcode` varchar(10) NOT NULL default '',
1888   `hemisphere` tinyint(3) default 0,
1889   `lastbranch` varchar(10),
1890   `serialsadditems` tinyint(1) NOT NULL default '0',
1891   `staffdisplaycount` VARCHAR(10) NULL,
1892   `opacdisplaycount` VARCHAR(10) NULL,
1893   `graceperiod` int(11) NOT NULL default '0',
1894   `enddate` date default NULL,
1895   PRIMARY KEY  (`subscriptionid`)
1896 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1897
1898 --
1899 -- Table structure for table `subscriptionhistory`
1900 --
1901
1902 DROP TABLE IF EXISTS `subscriptionhistory`;
1903 CREATE TABLE `subscriptionhistory` (
1904   `biblionumber` int(11) NOT NULL default 0,
1905   `subscriptionid` int(11) NOT NULL default 0,
1906   `histstartdate` date default NULL,
1907   `histenddate` date default NULL,
1908   `missinglist` longtext NOT NULL,
1909   `recievedlist` longtext NOT NULL,
1910   `opacnote` varchar(150) NOT NULL default '',
1911   `librariannote` varchar(150) NOT NULL default '',
1912   PRIMARY KEY  (`subscriptionid`),
1913   KEY `biblionumber` (`biblionumber`)
1914 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1915
1916 --
1917 -- Table structure for table `subscriptionroutinglist`
1918 --
1919
1920 DROP TABLE IF EXISTS `subscriptionroutinglist`;
1921 CREATE TABLE `subscriptionroutinglist` ( -- information related to the routing lists attached to subscriptions
1922   `routingid` int(11) NOT NULL auto_increment, -- unique identifier assigned by Koha
1923   `borrowernumber` int(11) NOT NULL, -- foreign key from the borrowers table, defines with patron is on the routing list
1924   `ranking` int(11) default NULL, -- where the patron stands in line to receive the serial
1925   `subscriptionid` int(11) NOT NULL, -- foreign key from the subscription table, defines which subscription this routing list is for
1926   PRIMARY KEY  (`routingid`),
1927   UNIQUE (`subscriptionid`, `borrowernumber`),
1928   CONSTRAINT `subscriptionroutinglist_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`)
1929     ON DELETE CASCADE ON UPDATE CASCADE,
1930   CONSTRAINT `subscriptionroutinglist_ibfk_2` FOREIGN KEY (`subscriptionid`) REFERENCES `subscription` (`subscriptionid`)
1931     ON DELETE CASCADE ON UPDATE CASCADE
1932 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1933
1934 --
1935 -- Table structure for table `suggestions`
1936 --
1937
1938 DROP TABLE IF EXISTS `suggestions`;
1939 CREATE TABLE `suggestions` ( -- purchase suggestions
1940   `suggestionid` int(8) NOT NULL auto_increment, -- unique identifier assigned automatically by Koha
1941   `suggestedby` int(11) NOT NULL default 0, -- borrowernumber for the person making the suggestion, foreign key linking to the borrowers table
1942   `suggesteddate` date NOT NULL default 0, -- date the suggestion was submitted
1943   `managedby` int(11) default NULL, -- borrowernumber for the librarian managing the suggestion, foreign key linking to the borrowers table
1944   `manageddate` date default NULL, -- date the suggestion was updated
1945    acceptedby INT(11) default NULL, -- borrowernumber for the librarian who accepted the suggestion, foreign key linking to the borrowers table
1946    accepteddate date default NULL, -- date the suggestion was marked as accepted
1947    rejectedby INT(11) default NULL, -- borrowernumber for the librarian who rejected the suggestion, foreign key linking to the borrowers table
1948    rejecteddate date default NULL, -- date the suggestion was marked as rejected
1949   `STATUS` varchar(10) NOT NULL default '', -- suggestion status (ASKED, CHECKED, ACCEPTED, or REJECTED)
1950   `note` mediumtext, -- note entered on the suggestion
1951   `author` varchar(80) default NULL, -- author of the suggested item
1952   `title` varchar(80) default NULL, -- title of the suggested item
1953   `copyrightdate` smallint(6) default NULL, -- copyright date of the suggested item
1954   `publishercode` varchar(255) default NULL, -- publisher of the suggested item
1955   `date` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,  -- date and time the suggestion was updated
1956   `volumedesc` varchar(255) default NULL,
1957   `publicationyear` smallint(6) default 0,
1958   `place` varchar(255) default NULL, -- publication place of the suggested item
1959   `isbn` varchar(30) default NULL, -- isbn of the suggested item
1960   `mailoverseeing` smallint(1) default 0,
1961   `biblionumber` int(11) default NULL, -- foreign key linking the suggestion to the biblio table after the suggestion has been ordered
1962   `reason` text, -- reason for accepting or rejecting the suggestion
1963   `patronreason` text, -- reason for making the suggestion
1964    budgetid INT(11), -- foreign key linking the suggested budget to the aqbudgets table
1965    branchcode VARCHAR(10) default NULL, -- foreign key linking the suggested branch to the branches table
1966    collectiontitle text default NULL, -- collection name for the suggested item
1967    itemtype VARCHAR(30) default NULL, -- suggested item type 
1968         quantity SMALLINT(6) default NULL, -- suggested quantity to be purchased
1969         currency VARCHAR(3) default NULL, -- suggested currency for the suggested price
1970         price DECIMAL(28,6) default NULL, -- suggested price
1971         total DECIMAL(28,6) default NULL, -- suggested total cost (price*quantity updated for currency)
1972   PRIMARY KEY  (`suggestionid`),
1973   KEY `suggestedby` (`suggestedby`),
1974   KEY `managedby` (`managedby`)
1975 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1976
1977 --
1978 -- Table structure for table `systempreferences`
1979 --
1980
1981 DROP TABLE IF EXISTS `systempreferences`;
1982 CREATE TABLE `systempreferences` ( -- global system preferences
1983   `variable` varchar(50) NOT NULL default '', -- system preference name
1984   `value` text, -- system preference values
1985   `options` mediumtext, -- options for multiple choice system preferences
1986   `explanation` text, -- descriptive text for the system preference
1987   `type` varchar(20) default NULL, -- type of question this preference asks (multiple choice, plain text, yes or no, etc)
1988   PRIMARY KEY  (`variable`)
1989 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1990
1991 --
1992 -- Table structure for table `tags`
1993 --
1994
1995 DROP TABLE IF EXISTS `tags`;
1996 CREATE TABLE `tags` (
1997   `entry` varchar(255) NOT NULL default '',
1998   `weight` bigint(20) NOT NULL default 0,
1999   PRIMARY KEY  (`entry`)
2000 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2001
2002 --
2003 -- Table structure for table `tags_all`
2004 --
2005
2006 DROP TABLE IF EXISTS `tags_all`;
2007 CREATE TABLE `tags_all` (
2008   `tag_id`         int(11) NOT NULL auto_increment,
2009   `borrowernumber` int(11) NOT NULL,
2010   `biblionumber`   int(11) NOT NULL,
2011   `term`      varchar(255) NOT NULL,
2012   `language`       int(4) default NULL,
2013   `date_created` datetime  NOT NULL,
2014   PRIMARY KEY  (`tag_id`),
2015   KEY `tags_borrowers_fk_1` (`borrowernumber`),
2016   KEY `tags_biblionumber_fk_1` (`biblionumber`),
2017   CONSTRAINT `tags_borrowers_fk_1` FOREIGN KEY (`borrowernumber`)
2018         REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
2019   CONSTRAINT `tags_biblionumber_fk_1` FOREIGN KEY (`biblionumber`)
2020         REFERENCES `biblio`     (`biblionumber`)  ON DELETE CASCADE ON UPDATE CASCADE
2021 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2022
2023 --
2024 -- Table structure for table `tags_approval`
2025 --
2026
2027 DROP TABLE IF EXISTS `tags_approval`;
2028 CREATE TABLE `tags_approval` (
2029   `term`   varchar(255) NOT NULL,
2030   `approved`     int(1) NOT NULL default '0',
2031   `date_approved` datetime       default NULL,
2032   `approved_by` int(11)          default NULL,
2033   `weight_total` int(9) NOT NULL default '1',
2034   PRIMARY KEY  (`term`),
2035   KEY `tags_approval_borrowers_fk_1` (`approved_by`),
2036   CONSTRAINT `tags_approval_borrowers_fk_1` FOREIGN KEY (`approved_by`)
2037         REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE
2038 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2039
2040 --
2041 -- Table structure for table `tags_index`
2042 --
2043
2044 DROP TABLE IF EXISTS `tags_index`;
2045 CREATE TABLE `tags_index` (
2046   `term`    varchar(255) NOT NULL,
2047   `biblionumber` int(11) NOT NULL,
2048   `weight`        int(9) NOT NULL default '1',
2049   PRIMARY KEY  (`term`,`biblionumber`),
2050   KEY `tags_index_biblionumber_fk_1` (`biblionumber`),
2051   CONSTRAINT `tags_index_term_fk_1` FOREIGN KEY (`term`)
2052         REFERENCES `tags_approval` (`term`)  ON DELETE CASCADE ON UPDATE CASCADE,
2053   CONSTRAINT `tags_index_biblionumber_fk_1` FOREIGN KEY (`biblionumber`)
2054         REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE
2055 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2056
2057 --
2058 -- Table structure for table `userflags`
2059 --
2060
2061 DROP TABLE IF EXISTS `userflags`;
2062 CREATE TABLE `userflags` (
2063   `bit` int(11) NOT NULL default 0,
2064   `flag` varchar(30) default NULL,
2065   `flagdesc` varchar(255) default NULL,
2066   `defaulton` int(11) default NULL,
2067   PRIMARY KEY  (`bit`)
2068 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2069
2070 --
2071 -- Table structure for table `virtualshelves`
2072 --
2073
2074 DROP TABLE IF EXISTS `virtualshelves`;
2075 CREATE TABLE `virtualshelves` ( -- information about lists (or virtual shelves) 
2076   `shelfnumber` int(11) NOT NULL auto_increment, -- unique identifier assigned by Koha
2077   `shelfname` varchar(255) default NULL, -- name of the list
2078   `owner` int default NULL, -- foreign key linking to the borrowers table (using borrowernumber) for the creator of this list (changed from varchar(80) to int)
2079   `category` varchar(1) default NULL, -- type of list (private [1], public [2])
2080   `sortfield` varchar(16) default NULL, -- the field this list is sorted on
2081   `lastmodified` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- date and time the list was last modified
2082   `allow_add` tinyint(1) default 0, -- permission for adding entries to list
2083   `allow_delete_own` tinyint(1) default 1, -- permission for deleting entries frm list that you added yourself
2084   `allow_delete_other` tinyint(1) default 0, -- permission for deleting entries from list that another person added
2085   PRIMARY KEY  (`shelfnumber`),
2086   CONSTRAINT `virtualshelves_ibfk_1` FOREIGN KEY (`owner`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE SET NULL -- no cascaded delete, please see HandleDelBorrower in VirtualShelves.pm
2087 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2088
2089 --
2090 -- Table structure for table `virtualshelfcontents`
2091 --
2092
2093 DROP TABLE IF EXISTS `virtualshelfcontents`;
2094 CREATE TABLE `virtualshelfcontents` ( -- information about the titles in a list (or virtual shelf)
2095   `shelfnumber` int(11) NOT NULL default 0, -- foreign key linking to the virtualshelves table, defines the list that this record has been added to
2096   `biblionumber` int(11) NOT NULL default 0, -- foreign key linking to the biblio table, defines the bib record that has been added to the list
2097   `flags` int(11) default NULL,
2098   `dateadded` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, -- date and time this bib record was added to the list
2099   `borrowernumber` int, -- borrower number that created this list entry (only the first one is saved: no need for use in/as key)
2100   KEY `shelfnumber` (`shelfnumber`),
2101   KEY `biblionumber` (`biblionumber`),
2102   CONSTRAINT `virtualshelfcontents_ibfk_1` FOREIGN KEY (`shelfnumber`) REFERENCES `virtualshelves` (`shelfnumber`) ON DELETE CASCADE ON UPDATE CASCADE,
2103   CONSTRAINT `shelfcontents_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE,
2104   CONSTRAINT `shelfcontents_ibfk_3` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE SET NULL -- no cascaded delete, please see HandleDelBorrower in VirtualShelves.pm
2105 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2106
2107 --
2108 -- Table structure for table `virtualshelfshares`
2109 --
2110
2111 DROP TABLE IF EXISTS `virtualshelfshares`;
2112 CREATE TABLE `virtualshelfshares` ( -- shared private lists
2113   `id` int AUTO_INCREMENT PRIMARY KEY,  -- unique key
2114   `shelfnumber` int NOT NULL,  -- foreign key for virtualshelves
2115   `borrowernumber` int,  -- borrower that accepted access to this list
2116   `invitekey` varchar(10), -- temporary string used in accepting the invitation to access thist list; not-empty means that the invitation has not been accepted yet
2117   `sharedate` datetime,  -- date of invitation or acceptance of invitation
2118   CONSTRAINT `virtualshelfshares_ibfk_1` FOREIGN KEY (`shelfnumber`) REFERENCES `virtualshelves` (`shelfnumber`) ON DELETE CASCADE ON UPDATE CASCADE,
2119   CONSTRAINT `virtualshelfshares_ibfk_2` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE SET NULL -- no cascaded delete, please see HandleDelBorrower in VirtualShelves.pm
2120 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2121
2122 --
2123 -- Table structure for table `z3950servers`
2124 --
2125
2126 DROP TABLE IF EXISTS `z3950servers`;
2127 CREATE TABLE `z3950servers` ( -- connection information for the Z39.50 targets used in cataloging
2128   `host` varchar(255) default NULL, -- target's host name
2129   `port` int(11) default NULL, -- port number used to connect to target
2130   `db` varchar(255) default NULL, -- target's database name
2131   `userid` varchar(255) default NULL, -- username needed to log in to target
2132   `password` varchar(255) default NULL, -- password needed to log in to target
2133   `name` mediumtext, -- name given to the target by the library
2134   `id` int(11) NOT NULL auto_increment, -- unique identifier assigned by Koha
2135   `checked` smallint(6) default NULL, -- whether this target is checked by default  (1 for yes, 0 for no)
2136   `rank` int(11) default NULL, -- where this target appears in the list of targets
2137   `syntax` varchar(80) default NULL, -- marc format provided by this target
2138   `timeout` int(11) NOT NULL DEFAULT '0',
2139   `icon` text, -- unused in Koha
2140   `position` enum('primary','secondary','') NOT NULL default 'primary',
2141   `type` enum('zed','opensearch') NOT NULL default 'zed',
2142   `encoding` text default NULL, -- characters encoding provided by this target
2143   `description` text NOT NULL, -- unused in Koha
2144   PRIMARY KEY  (`id`)
2145 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2146
2147 --
2148 -- Table structure for table `zebraqueue`
2149 --
2150
2151 DROP TABLE IF EXISTS `zebraqueue`;
2152 CREATE TABLE `zebraqueue` (
2153   `id` int(11) NOT NULL auto_increment,
2154   `biblio_auth_number` bigint(20) unsigned NOT NULL default '0',
2155   `operation` char(20) NOT NULL default '',
2156   `server` char(20) NOT NULL default '',
2157   `done` int(11) NOT NULL default '0',
2158   `time` timestamp NOT NULL default CURRENT_TIMESTAMP,
2159   PRIMARY KEY  (`id`),
2160   KEY `zebraqueue_lookup` (`server`, `biblio_auth_number`, `operation`, `done`)
2161 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2162
2163 --
2164 -- Table structure for table `services_throttle`
2165 --
2166
2167 DROP TABLE IF EXISTS `services_throttle`;
2168 CREATE TABLE `services_throttle` (
2169   `service_type` varchar(10) NOT NULL default '',
2170   `service_count` varchar(45) default NULL,
2171   PRIMARY KEY  (`service_type`)
2172 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2173
2174 --
2175 -- Table structure for table `language_subtag_registry`
2176 -- http://www.w3.org/International/articles/language-tags/
2177 -- RFC4646
2178 --
2179
2180 DROP TABLE IF EXISTS language_subtag_registry;
2181 CREATE TABLE language_subtag_registry (
2182         subtag varchar(25),
2183         type varchar(25), -- language-script-region-variant-extension-privateuse
2184         description varchar(25), -- only one of the possible descriptions for ease of reference, see language_descriptions for the complete list
2185         added date,
2186         id int(11) NOT NULL auto_increment,
2187         PRIMARY KEY  (`id`),
2188         KEY `subtag` (`subtag`)
2189 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2190
2191 --
2192 -- Table structure for table `language_rfc4646_to_iso639`
2193 -- TODO: add suppress_scripts
2194 -- this maps three letter codes defined in iso639.2 back to their
2195 -- two letter equivilents in rfc4646 (LOC maintains iso639+)
2196 --
2197
2198 DROP TABLE IF EXISTS language_rfc4646_to_iso639;
2199 CREATE TABLE language_rfc4646_to_iso639 (
2200         rfc4646_subtag varchar(25),
2201         iso639_2_code varchar(25),
2202         id int(11) NOT NULL auto_increment,
2203         PRIMARY KEY  (`id`),
2204         KEY `rfc4646_subtag` (`rfc4646_subtag`)
2205 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2206
2207 --
2208 -- Table structure for table `language_descriptions`
2209 --
2210
2211 DROP TABLE IF EXISTS language_descriptions;
2212 CREATE TABLE language_descriptions (
2213         subtag varchar(25),
2214         type varchar(25),
2215         lang varchar(25),
2216         description varchar(255),
2217         id int(11) NOT NULL auto_increment,
2218         PRIMARY KEY  (`id`),
2219         KEY `lang` (`lang`),
2220         KEY `subtag_type_lang` (`subtag`, `type`, `lang`)
2221 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2222
2223 --
2224 -- Table structure for table `language_script_bidi`
2225 -- bi-directional support, keyed by script subcode
2226 --
2227
2228 DROP TABLE IF EXISTS language_script_bidi;
2229 CREATE TABLE language_script_bidi (
2230         rfc4646_subtag varchar(25), -- script subtag, Arab, Hebr, etc.
2231         bidi varchar(3), -- rtl ltr
2232         KEY `rfc4646_subtag` (`rfc4646_subtag`)
2233 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2234
2235 --
2236 -- Table structure for table `language_script_mapping`
2237 -- TODO: need to map language subtags to script subtags for detection
2238 -- of bidi when script is not specified (like ar, he)
2239 --
2240
2241 DROP TABLE IF EXISTS language_script_mapping;
2242 CREATE TABLE language_script_mapping (
2243         language_subtag varchar(25),
2244         script_subtag varchar(25),
2245         KEY `language_subtag` (`language_subtag`)
2246 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2247
2248 --
2249 -- Table structure for table `permissions`
2250 --
2251
2252 DROP TABLE IF EXISTS `permissions`;
2253 CREATE TABLE `permissions` (
2254   `module_bit` int(11) NOT NULL DEFAULT 0,
2255   `code` varchar(64) DEFAULT NULL,
2256   `description` varchar(255) DEFAULT NULL,
2257   PRIMARY KEY  (`module_bit`, `code`),
2258   CONSTRAINT `permissions_ibfk_1` FOREIGN KEY (`module_bit`) REFERENCES `userflags` (`bit`)
2259     ON DELETE CASCADE ON UPDATE CASCADE
2260 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2261
2262 --
2263 -- Table structure for table `serialitems`
2264 --
2265
2266 DROP TABLE IF EXISTS `serialitems`;
2267 CREATE TABLE `serialitems` (
2268         `itemnumber` int(11) NOT NULL,
2269         `serialid` int(11) NOT NULL,
2270         UNIQUE KEY `serialitemsidx` (`itemnumber`),
2271         KEY `serialitems_sfk_1` (`serialid`),
2272         CONSTRAINT `serialitems_sfk_1` FOREIGN KEY (`serialid`) REFERENCES `serial` (`serialid`) ON DELETE CASCADE ON UPDATE CASCADE,
2273         CONSTRAINT `serialitems_sfk_2` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE
2274 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2275
2276 --
2277 -- Table structure for table `user_permissions`
2278 --
2279
2280 DROP TABLE IF EXISTS `user_permissions`;
2281 CREATE TABLE `user_permissions` (
2282   `borrowernumber` int(11) NOT NULL DEFAULT 0,
2283   `module_bit` int(11) NOT NULL DEFAULT 0,
2284   `code` varchar(64) DEFAULT NULL,
2285   CONSTRAINT `user_permissions_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`)
2286     ON DELETE CASCADE ON UPDATE CASCADE,
2287   CONSTRAINT `user_permissions_ibfk_2` FOREIGN KEY (`module_bit`, `code`) REFERENCES `permissions` (`module_bit`, `code`)
2288     ON DELETE CASCADE ON UPDATE CASCADE
2289 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2290
2291 --
2292 -- Table structure for table `tmp_holdsqueue`
2293 --
2294
2295 DROP TABLE IF EXISTS `tmp_holdsqueue`;
2296 CREATE TABLE `tmp_holdsqueue` (
2297   `biblionumber` int(11) default NULL,
2298   `itemnumber` int(11) default NULL,
2299   `barcode` varchar(20) default NULL,
2300   `surname` mediumtext NOT NULL,
2301   `firstname` text,
2302   `phone` text,
2303   `borrowernumber` int(11) NOT NULL,
2304   `cardnumber` varchar(16) default NULL,
2305   `reservedate` date default NULL,
2306   `title` mediumtext,
2307   `itemcallnumber` varchar(255) default NULL,
2308   `holdingbranch` varchar(10) default NULL,
2309   `pickbranch` varchar(10) default NULL,
2310   `notes` text,
2311   `item_level_request` tinyint(4) NOT NULL default 0
2312 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2313
2314 --
2315 -- Table structure for table `message_queue`
2316 --
2317
2318 DROP TABLE IF EXISTS `message_queue`;
2319 CREATE TABLE `message_queue` (
2320   `message_id` int(11) NOT NULL auto_increment,
2321   `borrowernumber` int(11) default NULL,
2322   `subject` text,
2323   `content` text,
2324   `metadata` text DEFAULT NULL,
2325   `letter_code` varchar(64) DEFAULT NULL,
2326   `message_transport_type` varchar(20) NOT NULL,
2327   `status` enum('sent','pending','failed','deleted') NOT NULL default 'pending',
2328   `time_queued` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
2329   `to_address` mediumtext,
2330   `from_address` mediumtext,
2331   `content_type` text,
2332   KEY `message_id` (`message_id`),
2333   KEY `borrowernumber` (`borrowernumber`),
2334   KEY `message_transport_type` (`message_transport_type`),
2335   CONSTRAINT `messageq_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
2336   CONSTRAINT `messageq_ibfk_2` FOREIGN KEY (`message_transport_type`) REFERENCES `message_transport_types` (`message_transport_type`) ON DELETE RESTRICT ON UPDATE CASCADE
2337 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2338
2339 --
2340 -- Table structure for table `message_transport_types`
2341 --
2342
2343 DROP TABLE IF EXISTS `message_transport_types`;
2344 CREATE TABLE `message_transport_types` (
2345   `message_transport_type` varchar(20) NOT NULL,
2346   PRIMARY KEY  (`message_transport_type`)
2347 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2348
2349 --
2350 -- Table structure for table `message_attributes`
2351 --
2352
2353 DROP TABLE IF EXISTS `message_attributes`;
2354 CREATE TABLE `message_attributes` (
2355   `message_attribute_id` int(11) NOT NULL auto_increment,
2356   `message_name` varchar(40) NOT NULL default '',
2357   `takes_days` tinyint(1) NOT NULL default '0',
2358   PRIMARY KEY  (`message_attribute_id`),
2359   UNIQUE KEY `message_name` (`message_name`)
2360 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2361
2362 --
2363 -- Table structure for table `message_transports`
2364 --
2365
2366 DROP TABLE IF EXISTS `message_transports`;
2367 CREATE TABLE `message_transports` (
2368   `message_attribute_id` int(11) NOT NULL,
2369   `message_transport_type` varchar(20) NOT NULL,
2370   `is_digest` tinyint(1) NOT NULL default '0',
2371   `letter_module` varchar(20) NOT NULL default '',
2372   `letter_code` varchar(20) NOT NULL default '',
2373   `branchcode` varchar(10) NOT NULL default '',
2374   PRIMARY KEY  (`message_attribute_id`,`message_transport_type`,`is_digest`),
2375   KEY `message_transport_type` (`message_transport_type`),
2376   KEY `letter_module` (`letter_module`,`letter_code`),
2377   CONSTRAINT `message_transports_ibfk_1` FOREIGN KEY (`message_attribute_id`) REFERENCES `message_attributes` (`message_attribute_id`) ON DELETE CASCADE ON UPDATE CASCADE,
2378   CONSTRAINT `message_transports_ibfk_2` FOREIGN KEY (`message_transport_type`) REFERENCES `message_transport_types` (`message_transport_type`) ON DELETE CASCADE ON UPDATE CASCADE,
2379   CONSTRAINT `message_transports_ibfk_3` FOREIGN KEY (`letter_module`, `letter_code`, `branchcode`) REFERENCES `letter` (`module`, `code`, `branchcode`) ON DELETE CASCADE ON UPDATE CASCADE
2380 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2381
2382 --
2383 -- Table structure for table `borrower_message_preferences`
2384 --
2385
2386 DROP TABLE IF EXISTS `borrower_message_preferences`;
2387 CREATE TABLE `borrower_message_preferences` (
2388   `borrower_message_preference_id` int(11) NOT NULL auto_increment,
2389   `borrowernumber` int(11) default NULL,
2390   `categorycode` varchar(10) default NULL,
2391   `message_attribute_id` int(11) default '0',
2392   `days_in_advance` int(11) default '0',
2393   `wants_digest` tinyint(1) NOT NULL default '0',
2394   PRIMARY KEY  (`borrower_message_preference_id`),
2395   KEY `borrowernumber` (`borrowernumber`),
2396   KEY `categorycode` (`categorycode`),
2397   KEY `message_attribute_id` (`message_attribute_id`),
2398   CONSTRAINT `borrower_message_preferences_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
2399   CONSTRAINT `borrower_message_preferences_ibfk_2` FOREIGN KEY (`message_attribute_id`) REFERENCES `message_attributes` (`message_attribute_id`) ON DELETE CASCADE ON UPDATE CASCADE,
2400   CONSTRAINT `borrower_message_preferences_ibfk_3` FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`) ON DELETE CASCADE ON UPDATE CASCADE
2401 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2402
2403 --
2404 -- Table structure for table `borrower_message_transport_preferences`
2405 --
2406
2407 DROP TABLE IF EXISTS `borrower_message_transport_preferences`;
2408 CREATE TABLE `borrower_message_transport_preferences` (
2409   `borrower_message_preference_id` int(11) NOT NULL default '0',
2410   `message_transport_type` varchar(20) NOT NULL default '0',
2411   PRIMARY KEY  (`borrower_message_preference_id`,`message_transport_type`),
2412   KEY `message_transport_type` (`message_transport_type`),
2413   CONSTRAINT `borrower_message_transport_preferences_ibfk_1` FOREIGN KEY (`borrower_message_preference_id`) REFERENCES `borrower_message_preferences` (`borrower_message_preference_id`) ON DELETE CASCADE ON UPDATE CASCADE,
2414   CONSTRAINT `borrower_message_transport_preferences_ibfk_2` FOREIGN KEY (`message_transport_type`) REFERENCES `message_transport_types` (`message_transport_type`) ON DELETE CASCADE ON UPDATE CASCADE
2415 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2416
2417 --
2418 -- Table structure for the table branch_transfer_limits
2419 --
2420
2421 DROP TABLE IF EXISTS `branch_transfer_limits`;
2422 CREATE TABLE branch_transfer_limits (
2423     limitId int(8) NOT NULL auto_increment,
2424     toBranch varchar(10) NOT NULL,
2425     fromBranch varchar(10) NOT NULL,
2426     itemtype varchar(10) NULL,
2427     ccode varchar(10) NULL,
2428     PRIMARY KEY  (limitId)
2429 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2430
2431 --
2432 -- Table structure for table `item_circulation_alert_preferences`
2433 --
2434
2435 DROP TABLE IF EXISTS `item_circulation_alert_preferences`;
2436 CREATE TABLE `item_circulation_alert_preferences` (
2437   `id` int(11) NOT NULL auto_increment,
2438   `branchcode` varchar(10) NOT NULL,
2439   `categorycode` varchar(10) NOT NULL,
2440   `item_type` varchar(10) NOT NULL,
2441   `notification` varchar(16) NOT NULL,
2442   PRIMARY KEY  (`id`),
2443   KEY `branchcode` (`branchcode`,`categorycode`,`item_type`, `notification`)
2444 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2445
2446 --
2447 -- Table structure for table `messages`
2448 --
2449 DROP TABLE IF EXISTS `messages`;
2450 CREATE TABLE `messages` ( -- circulation messages left via the patron's check out screen
2451   `message_id` int(11) NOT NULL auto_increment, -- unique identifier assigned by Koha
2452   `borrowernumber` int(11) NOT NULL, -- foreign key linking this message to the borrowers table
2453   `branchcode` varchar(10) default NULL, -- foreign key linking the message to the branches table
2454   `message_type` varchar(1) NOT NULL, -- whether the message is for the librarians (L) or the patron (B)
2455   `message` text NOT NULL, -- the text of the message
2456   `message_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, -- the date and time the message was written
2457   PRIMARY KEY (`message_id`)
2458 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2459
2460 --
2461 -- Table structure for table `accountlines`
2462 --
2463
2464 DROP TABLE IF EXISTS `accountlines`;
2465 CREATE TABLE `accountlines` (
2466   `borrowernumber` int(11) NOT NULL default 0,
2467   `accountno` smallint(6) NOT NULL default 0,
2468   `itemnumber` int(11) default NULL,
2469   `date` date default NULL,
2470   `amount` decimal(28,6) default NULL,
2471   `description` mediumtext,
2472   `dispute` mediumtext,
2473   `accounttype` varchar(5) default NULL,
2474   `amountoutstanding` decimal(28,6) default NULL,
2475   `lastincrement` decimal(28,6) default NULL,
2476   `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
2477   `notify_id` int(11) NOT NULL default 0,
2478   `notify_level` int(2) NOT NULL default 0,
2479   `note` text NULL default NULL,
2480   `manager_id` int(11) NULL,
2481   KEY `acctsborridx` (`borrowernumber`),
2482   KEY `timeidx` (`timestamp`),
2483   KEY `itemnumber` (`itemnumber`),
2484   CONSTRAINT `accountlines_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
2485   CONSTRAINT `accountlines_ibfk_2` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE SET NULL ON UPDATE SET NULL
2486 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2487
2488 --
2489 -- Table structure for table `accountoffsets`
2490 --
2491
2492 DROP TABLE IF EXISTS `accountoffsets`;
2493 CREATE TABLE `accountoffsets` (
2494   `borrowernumber` int(11) NOT NULL default 0,
2495   `accountno` smallint(6) NOT NULL default 0,
2496   `offsetaccount` smallint(6) NOT NULL default 0,
2497   `offsetamount` decimal(28,6) default NULL,
2498   `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
2499   CONSTRAINT `accountoffsets_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE
2500 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2501
2502 --
2503 -- Table structure for table `action_logs`
2504 --
2505
2506 DROP TABLE IF EXISTS `action_logs`;
2507 CREATE TABLE `action_logs` ( -- logs of actions taken in Koha (requires that the logs be turned on)
2508   `action_id` int(11) NOT NULL auto_increment, -- unique identifier for each action
2509   `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- the date and time the action took place
2510   `user` int(11) NOT NULL default 0, -- the staff member who performed the action (borrowers.borrowernumber)
2511   `module` text, -- the module this action was taken against
2512   `action` text, -- the action (includes things like DELETED, ADDED, MODIFY, etc)
2513   `object` int(11) default NULL, -- the object that the action was taken against (could be a borrowernumber, itemnumber, etc)
2514   `info` text, -- information about the action (usually includes SQL statement)
2515   PRIMARY KEY (`action_id`),
2516   KEY  (`timestamp`,`user`)
2517 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2518
2519 --
2520 -- Table structure for table `alert`
2521 --
2522
2523 DROP TABLE IF EXISTS `alert`;
2524 CREATE TABLE `alert` (
2525   `alertid` int(11) NOT NULL auto_increment,
2526   `borrowernumber` int(11) NOT NULL default 0,
2527   `type` varchar(10) NOT NULL default '',
2528   `externalid` varchar(20) NOT NULL default '',
2529   PRIMARY KEY  (`alertid`),
2530   KEY `borrowernumber` (`borrowernumber`),
2531   KEY `type` (`type`,`externalid`)
2532 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2533
2534 --
2535 -- Table structure for table `aqbasketgroups`
2536 --
2537
2538 DROP TABLE IF EXISTS `aqbasketgroups`;
2539 CREATE TABLE `aqbasketgroups` (
2540   `id` int(11) NOT NULL auto_increment,
2541   `name` varchar(50) default NULL,
2542   `closed` tinyint(1) default NULL,
2543   `booksellerid` int(11) NOT NULL,
2544   `deliveryplace` varchar(10) default NULL,
2545   `freedeliveryplace` text default NULL,
2546   `deliverycomment` varchar(255) default NULL,
2547   `billingplace` varchar(10) default NULL,
2548   PRIMARY KEY  (`id`),
2549   KEY `booksellerid` (`booksellerid`),
2550   CONSTRAINT `aqbasketgroups_ibfk_1` FOREIGN KEY (`booksellerid`) REFERENCES `aqbooksellers` (`id`) ON UPDATE CASCADE ON DELETE CASCADE
2551 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2552
2553 --
2554 -- Table structure for table `aqbasket`
2555 --
2556
2557 DROP TABLE IF EXISTS `aqbasket`;
2558 CREATE TABLE `aqbasket` ( -- stores data about baskets in acquisitions
2559   `basketno` int(11) NOT NULL auto_increment, -- primary key, Koha defined number
2560   `basketname` varchar(50) default NULL, -- name given to the basket at creation
2561   `note` mediumtext, -- the internal note added at basket creation
2562   `booksellernote` mediumtext, -- the vendor note added at basket creation
2563   `contractnumber` int(11), -- links this basket to the aqcontract table (aqcontract.contractnumber)
2564   `creationdate` date default NULL, -- the date the basket was created
2565   `closedate` date default NULL, -- the date the basket was closed
2566   `booksellerid` int(11) NOT NULL default 1, -- the Koha assigned ID for the vendor (aqbooksellers.id)
2567   `authorisedby` varchar(10) default NULL, -- the borrowernumber of the person who created the basket
2568   `booksellerinvoicenumber` mediumtext, -- appears to always be NULL
2569   `basketgroupid` int(11), -- links this basket to its group (aqbasketgroups.id)
2570   PRIMARY KEY  (`basketno`),
2571   KEY `booksellerid` (`booksellerid`),
2572   KEY `basketgroupid` (`basketgroupid`),
2573   KEY `contractnumber` (`contractnumber`),
2574   CONSTRAINT `aqbasket_ibfk_1` FOREIGN KEY (`booksellerid`) REFERENCES `aqbooksellers` (`id`) ON UPDATE CASCADE,
2575   CONSTRAINT `aqbasket_ibfk_2` FOREIGN KEY (`contractnumber`) REFERENCES `aqcontract` (`contractnumber`),
2576   CONSTRAINT `aqbasket_ibfk_3` FOREIGN KEY (`basketgroupid`) REFERENCES `aqbasketgroups` (`id`) ON UPDATE CASCADE
2577 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2578
2579 --
2580 -- Table structure for table `aqbooksellers`
2581 --
2582
2583 DROP TABLE IF EXISTS `aqbooksellers`;
2584 CREATE TABLE `aqbooksellers` ( -- information about the vendors listed in acquisitions
2585   `id` int(11) NOT NULL auto_increment, -- primary key and unique identifier assigned by Koha
2586   `name` mediumtext NOT NULL, -- vendor name
2587   `address1` mediumtext, -- first line of vendor physical address
2588   `address2` mediumtext, -- second line of vendor physical address
2589   `address3` mediumtext, -- third line of vendor physical address
2590   `address4` mediumtext, -- fourth line of vendor physical address
2591   `phone` varchar(30) default NULL, -- vendor phone number
2592   `accountnumber` mediumtext, -- unused in Koha
2593   `othersupplier` mediumtext,  -- unused in Koha
2594   `currency` varchar(3) NOT NULL default '', -- unused in Koha
2595   `booksellerfax` mediumtext, -- vendor fax number
2596   `notes` mediumtext, -- order notes
2597   `bookselleremail` mediumtext, -- vendor email
2598   `booksellerurl` mediumtext, -- unused in Koha
2599   `contact` varchar(100) default NULL, -- name of contact at vendor
2600   `postal` mediumtext, -- vendor postal address (all lines)
2601   `url` varchar(255) default NULL, -- vendor web address
2602   `contpos` varchar(100) default NULL, -- contact person's position
2603   `contphone` varchar(100) default NULL, -- contact's phone number
2604   `contfax` varchar(100) default NULL,  -- contact's fax number
2605   `contaltphone` varchar(100) default NULL, -- contact's alternate phone number
2606   `contemail` varchar(100) default NULL, -- contact's email address
2607   `contnotes` mediumtext, -- notes related to the contact
2608   `active` tinyint(4) default NULL, -- is this vendor active (1 for yes, 0 for no)
2609   `listprice` varchar(10) default NULL, -- currency code for list prices
2610   `invoiceprice` varchar(10) default NULL, -- currency code for invoice prices
2611   `gstreg` tinyint(4) default NULL, -- is your library charged tax (1 for yes, 0 for no)
2612   `listincgst` tinyint(4) default NULL, -- is tax included in list prices (1 for yes, 0 for no)
2613   `invoiceincgst` tinyint(4) default NULL, -- is tax included in invoice prices (1 for yes, 0 for no)
2614   `gstrate` decimal(6,4) default NULL, -- the tax rate the library is charged
2615   `discount` float(6,4) default NULL, -- discount offered on all items ordered from this vendor
2616   `fax` varchar(50) default NULL, -- vendor fax number
2617   deliverytime int(11) default NULL, -- vendor delivery time
2618   PRIMARY KEY  (`id`),
2619   KEY `listprice` (`listprice`),
2620   KEY `invoiceprice` (`invoiceprice`),
2621   CONSTRAINT `aqbooksellers_ibfk_1` FOREIGN KEY (`listprice`) REFERENCES `currency` (`currency`) ON DELETE CASCADE ON UPDATE CASCADE,
2622   CONSTRAINT `aqbooksellers_ibfk_2` FOREIGN KEY (`invoiceprice`) REFERENCES `currency` (`currency`) ON DELETE CASCADE ON UPDATE CASCADE
2623 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2624
2625 --
2626 -- Table structure for table `aqbudgets`
2627 --
2628
2629 DROP TABLE IF EXISTS `aqbudgets`;
2630 CREATE TABLE `aqbudgets` ( -- information related to Funds
2631   `budget_id` int(11) NOT NULL auto_increment, -- primary key and unique number assigned to each fund by Koha
2632   `budget_parent_id` int(11) default NULL, -- if this fund is a child of another this will include the parent id (aqbudgets.budget_id)
2633   `budget_code` varchar(30) default NULL, -- code assigned to the fund by the user
2634   `budget_name` varchar(80) default NULL, -- name assigned to the fund by the user
2635   `budget_branchcode` varchar(10) default NULL, -- branch that this fund belongs to (branches.branchcode)
2636   `budget_amount` decimal(28,6) NULL default '0.00', -- total amount for this fund
2637   `budget_encumb` decimal(28,6) NULL default '0.00', -- not used in the code
2638   `budget_expend` decimal(28,6) NULL default '0.00', -- not used in the code
2639   `budget_notes` mediumtext, -- notes related to this fund
2640   `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- date and time this fund was last touched (created or modified)
2641   `budget_period_id` int(11) default NULL, -- id of the budget that this fund belongs to (aqbudgetperiods.budget_period_id)
2642   `sort1_authcat` varchar(80) default NULL, -- statistical category for this fund
2643   `sort2_authcat` varchar(80) default NULL, -- second statistical category for this fund
2644   `budget_owner_id` int(11) default NULL, -- borrowernumber of the person who owns this fund (borrowers.borrowernumber)
2645   `budget_permission` int(1) default '0', -- level of permission for this fund (used only by the owner, only by the library, or anyone)
2646   PRIMARY KEY  (`budget_id`)
2647 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2648
2649 --
2650 -- Table structure for table aqbudgetborrowers
2651 --
2652
2653 DROP TABLE IF EXISTS aqbudgetborrowers;
2654 CREATE TABLE aqbudgetborrowers (
2655   budget_id int(11) NOT NULL,
2656   borrowernumber int(11) NOT NULL,
2657   PRIMARY KEY (budget_id, borrowernumber),
2658   CONSTRAINT aqbudgetborrowers_ibfk_1 FOREIGN KEY (budget_id)
2659     REFERENCES aqbudgets (budget_id)
2660     ON DELETE CASCADE ON UPDATE CASCADE,
2661   CONSTRAINT aqbudgetborrowers_ibfk_2 FOREIGN KEY (borrowernumber)
2662     REFERENCES borrowers (borrowernumber)
2663     ON DELETE CASCADE ON UPDATE CASCADE
2664 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2665
2666 --
2667 -- Table structure for table `aqbudgetperiods`
2668 --
2669
2670
2671 DROP TABLE IF EXISTS `aqbudgetperiods`;
2672 CREATE TABLE `aqbudgetperiods` ( -- information related to Budgets
2673   `budget_period_id` int(11) NOT NULL auto_increment, -- primary key and unique number assigned by Koha
2674   `budget_period_startdate` date NOT NULL, -- date when the budget starts
2675   `budget_period_enddate` date NOT NULL, -- date when the budget ends
2676   `budget_period_active` tinyint(1) default '0', -- whether this budget is active or not (1 for yes, 0 for no)
2677   `budget_period_description` mediumtext, -- description assigned to this budget
2678   `budget_period_total` decimal(28,6), -- total amount available in this budget
2679   `budget_period_locked` tinyint(1) default NULL, -- whether this budget is locked or not (1 for yes, 0 for no)
2680   `sort1_authcat` varchar(10) default NULL, -- statistical category for this budget
2681   `sort2_authcat` varchar(10) default NULL, -- second statistical category for this budget
2682   PRIMARY KEY  (`budget_period_id`)
2683 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2684
2685 --
2686 -- Table structure for table `aqbudgets_planning`
2687 --
2688
2689 DROP TABLE IF EXISTS `aqbudgets_planning`;
2690 CREATE TABLE `aqbudgets_planning` (
2691   `plan_id` int(11) NOT NULL auto_increment,
2692   `budget_id` int(11) NOT NULL,
2693   `budget_period_id` int(11) NOT NULL,
2694   `estimated_amount` decimal(28,6) default NULL,
2695   `authcat` varchar(30) NOT NULL,
2696   `authvalue` varchar(30) NOT NULL,
2697   `display` tinyint(1) DEFAULT 1,
2698   PRIMARY KEY  (`plan_id`),
2699   CONSTRAINT `aqbudgets_planning_ifbk_1` FOREIGN KEY (`budget_id`) REFERENCES `aqbudgets` (`budget_id`) ON DELETE CASCADE ON UPDATE CASCADE
2700 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2701
2702 --
2703 -- Table structure for table 'aqcontract'
2704 --
2705
2706 DROP TABLE IF EXISTS `aqcontract`;
2707 CREATE TABLE `aqcontract` (
2708   `contractnumber` int(11) NOT NULL auto_increment,
2709   `contractstartdate` date default NULL,
2710   `contractenddate` date default NULL,
2711   `contractname` varchar(50) default NULL,
2712   `contractdescription` mediumtext,
2713   `booksellerid` int(11) not NULL,
2714   PRIMARY KEY  (`contractnumber`),
2715   CONSTRAINT `booksellerid_fk1` FOREIGN KEY (`booksellerid`)
2716        REFERENCES `aqbooksellers` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
2717 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
2718
2719 --
2720 -- Table structure for table `aqorderdelivery`
2721 --
2722
2723 DROP TABLE IF EXISTS `aqorderdelivery`;
2724 CREATE TABLE `aqorderdelivery` (
2725   `ordernumber` date default NULL,
2726   `deliverynumber` smallint(6) NOT NULL default 0,
2727   `deliverydate` varchar(18) default NULL,
2728   `qtydelivered` smallint(6) default NULL,
2729   `deliverycomments` mediumtext
2730 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2731
2732 --
2733 -- Table structure for table `aqorders`
2734 --
2735
2736 DROP TABLE IF EXISTS `aqorders`;
2737 CREATE TABLE `aqorders` ( --information related to the basket line items
2738   `ordernumber` int(11) NOT NULL auto_increment, -- primary key and unique identifier assigned by Koha to each line
2739   `biblionumber` int(11) default NULL, -- links the order to the biblio being ordered (biblio.biblionumber)
2740   `entrydate` date default NULL, -- the date the bib was added to the basket
2741   `quantity` smallint(6) default NULL, -- the quantity ordered
2742   `currency` varchar(3) default NULL, -- the currency used for the purchase
2743   `listprice` decimal(28,6) default NULL, -- the vendor price for this line item
2744   `totalamount` decimal(28,6) default NULL, -- not used? always NULL
2745   `datereceived` date default NULL, -- the date this order was received
2746   `booksellerinvoicenumber` mediumtext, -- the invoice number this line item was received on
2747   `freight` decimal(28,6) default NULL, -- shipping costs (not used)
2748   `unitprice` decimal(28,6) default NULL, -- the actual cost entered when receiving this line item
2749   `quantityreceived` smallint(6) NOT NULL default 0, -- the quantity that have been received so far
2750   `cancelledby` varchar(10) default NULL, -- not used? always NULL
2751   `datecancellationprinted` date default NULL, -- the date the line item was deleted
2752   `notes` mediumtext, -- notes related to this order line
2753   `supplierreference` mediumtext, -- not used? always NULL
2754   `purchaseordernumber` mediumtext, -- not used? always NULL
2755   `subscription` tinyint(1) default NULL, -- not used? always NULL
2756   `serialid` varchar(30) default NULL, -- not used? always NULL
2757   `basketno` int(11) default NULL, -- links this order line to a specific basket (aqbasket.basketno)
2758   `biblioitemnumber` int(11) default NULL, -- links this order line the biblioitems table (biblioitems.biblioitemnumber)
2759   `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- the date and time this order line was last modified
2760   `rrp` decimal(13,2) default NULL, -- the replacement cost for this line item
2761   `ecost` decimal(13,2) default NULL, -- the estimated cost for this line item
2762   `gst` decimal(13,2) default NULL, -- the tax rate for this line item
2763   `budget_id` int(11) NOT NULL, -- the fund this order goes against (aqbudgets.budget_id)
2764   `budgetgroup_id` int(11) NOT NULL, -- not used? always zero
2765   `budgetdate` date default NULL, -- not used? always NULL
2766   `sort1` varchar(80) default NULL, -- statistical field
2767   `sort2` varchar(80) default NULL, -- second statistical field
2768   `sort1_authcat` varchar(10) default NULL,
2769   `sort2_authcat` varchar(10) default NULL,
2770   `uncertainprice` tinyint(1), -- was this price uncertain (1 for yes, 0 for no)
2771   `claims_count` int(11) default 0, -- count of claim letters generated
2772   `claimed_date` date default NULL, -- last date a claim was generated
2773   PRIMARY KEY  (`ordernumber`),
2774   KEY `basketno` (`basketno`),
2775   KEY `biblionumber` (`biblionumber`),
2776   KEY `budget_id` (`budget_id`),
2777   CONSTRAINT `aqorders_ibfk_1` FOREIGN KEY (`basketno`) REFERENCES `aqbasket` (`basketno`) ON DELETE CASCADE ON UPDATE CASCADE,
2778   CONSTRAINT `aqorders_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE SET NULL ON UPDATE CASCADE
2779 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2780
2781
2782 --
2783 -- Table structure for table `aqorders_items`
2784 --
2785
2786 DROP TABLE IF EXISTS `aqorders_items`;
2787 CREATE TABLE `aqorders_items` ( -- information on items entered in the acquisitions process
2788   `ordernumber` int(11) NOT NULL, -- the order this item is attached to (aqorders.ordernumber)
2789   `itemnumber` int(11) NOT NULL, -- the item number for this item (items.itemnumber)
2790   `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- the date and time this order item was last touched
2791   PRIMARY KEY  (`itemnumber`),
2792   KEY `ordernumber` (`ordernumber`)
2793 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2794
2795 --
2796 -- Table structure for table `fieldmapping`
2797 --
2798
2799 DROP TABLE IF EXISTS `fieldmapping`;
2800 CREATE TABLE `fieldmapping` ( -- koha to keyword mapping
2801   `id` int(11) NOT NULL auto_increment, -- unique identifier assigned by Koha
2802   `field` varchar(255) NOT NULL, -- keyword to be mapped to (ex. subtitle)
2803   `frameworkcode` char(4) NOT NULL default '', -- foreign key from the biblio_framework table to link this mapping to a specific framework
2804   `fieldcode` char(3) NOT NULL, -- marc field number to map to this keyword
2805   `subfieldcode` char(1) NOT NULL, -- marc subfield associated with the fieldcode to map to this keyword
2806   PRIMARY KEY  (`id`)
2807 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2808
2809 --
2810 -- Table structure for table `biblioimages`
2811 --
2812
2813 DROP TABLE IF EXISTS `biblioimages`;
2814
2815 CREATE TABLE `biblioimages` (
2816  `imagenumber` int(11) NOT NULL AUTO_INCREMENT,
2817  `biblionumber` int(11) NOT NULL,
2818  `mimetype` varchar(15) NOT NULL,
2819  `imagefile` mediumblob NOT NULL,
2820  `thumbnail` mediumblob NOT NULL,
2821  PRIMARY KEY (`imagenumber`),
2822  CONSTRAINT `bibliocoverimage_fk1` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE
2823 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2824
2825 --
2826 -- Table structure for table `social_data`
2827 --
2828
2829 DROP TABLE IF EXISTS `social_data`;
2830 CREATE TABLE IF NOT EXISTS `social_data` (
2831   `isbn` VARCHAR(30),
2832   `num_critics` INT,
2833   `num_critics_pro` INT,
2834   `num_quotations` INT,
2835   `num_videos` INT,
2836   `score_avg` DECIMAL(5,2),
2837   `num_scores` INT,
2838   PRIMARY KEY  (`isbn`)
2839 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2840
2841 --
2842 -- 'Ratings' table. This tracks the star ratings set by borrowers.
2843 --
2844
2845 DROP TABLE IF EXISTS ratings;
2846 CREATE TABLE ratings ( -- information related to the star ratings in the OPAC
2847     borrowernumber int(11) NOT NULL, -- the borrowernumber of the patron who left this rating (borrowers.borrowernumber)
2848     biblionumber int(11) NOT NULL, -- the biblio this rating is for (biblio.biblionumber)
2849     rating_value tinyint(1) NOT NULL, -- the rating, from 1 to 5
2850     timestamp timestamp NOT NULL default CURRENT_TIMESTAMP,
2851     PRIMARY KEY  (borrowernumber,biblionumber),
2852     CONSTRAINT ratings_ibfk_1 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE,
2853     CONSTRAINT ratings_ibfk_2 FOREIGN KEY (biblionumber) REFERENCES biblio (biblionumber) ON DELETE CASCADE ON UPDATE CASCADE
2854 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2855
2856 --
2857 -- Table structure for table `quotes`
2858 --
2859
2860 DROP TABLE IF EXISTS quotes;
2861 CREATE TABLE `quotes` (
2862   `id` int(11) NOT NULL AUTO_INCREMENT,
2863   `source` text DEFAULT NULL,
2864   `text` mediumtext NOT NULL,
2865   `timestamp` datetime NOT NULL,
2866   PRIMARY KEY (`id`)
2867 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2868
2869 /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
2870 /*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
2871 /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
2872 /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
2873 /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
2874 /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
2875 /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
2876 /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
2877