a934c18b9881eaaab71f6e9db43a886dc4db6cd7
[koha.git] / marcschema.sql
1 #  $Id$
2 #  
3 #  $Log$
4 #  Revision 1.14  2002/06/04 08:13:31  tipaul
5 #  ouuppsss... forget the 1.13 version, i made a mistake. This version works and should be the last
6 #
7 #  Revision 1.13/1.14  2002/06/04 07:56:56  tipaul
8 #  New and hopefully last version of the MARC-DB. Is the fastest in benchmark, everybody agree ;-) (Sergey, Steve and me, Paul)
9 #
10 #  Revision 1.13 2002/06/04 Paul
11 #  should be the last version... remains only 2 tables : the main table and the subfield one.
12 #  benchmark shows this structure is the fastest. I had to add indicator in the subfield table. should be in a tag_table, but as it s the
13 #  only real information that should be in this table, it has been thrown to subfield table (not a normal form, but an optimized one...)
14 #
15 #  Revision 1.12  2002/05/31 20:03:17  tonnesen
16 #  removed another _sergey
17 #
18 #  Revision 1.11  2002/05/31 19:41:29  tonnesen
19 #  removed fieldid in favour of tagid, removed _sergey from table names, added
20 #  tagorder field to tag table, renamed marc_field_table to marc_tag_table.
21 #
22 #
23 #
24 #  These first three tables store the data from a MARC record.
25         
26 # marc_biblio contains 1 record for each biblio in the DB
27 CREATE TABLE marc_biblio (
28                 bibid bigint(20) unsigned NOT NULL auto_increment,
29                 datecreated date NOT NULL default '0000-00-00',
30                 datemodified date default NULL,
31                 origincode char(20) default NULL,
32                 PRIMARY KEY  (bibid),
33                 KEY origincode (origincode)
34                 ) TYPE=MyISAM;
35
36 CREATE TABLE marc_subfield_table (
37         subfieldid  bigint(20) unsigned NOT NULL auto_increment,# subfield identifier
38         bibid bigint(20) unsigned NOT NULL,                     # link to marc_biblio table
39         tag char(3) NOT NULL,                                   # tag number
40         tagorder tinyint(4) NOT NULL default '1',               # display order for tags within a biblio when a tag is repeated
41         tag_indicator char(2) NOT NULL,                         # tag indicator
42         subfieldcode char(1) NOT NULL default '',               # subfield code
43         subfieldorder tinyint(4) NOT NULL default '1',          # display order for subfields within a tag when a subfield is repeated
44         subfieldvalue varchar(255) default NULL,                # the subfields value if not longer than 255 char
45         valuebloblink bigint(20) default NULL,                  # the link to the blob, if value is longer than 255 char
46         PRIMARY KEY (subfieldid),
47         KEY bibid (bibid),
48         KEY tag (tag),
49         KEY tag_indicator (tag_indicator),
50         KEY subfieldorder (subfieldorder),
51         KEY subfieldcode (subfieldcode),
52         KEY subfieldvalue (subfieldvalue)
53 );
54
55 # marc_blob_subfield containts subfields longer than 255 car.
56 # They are linked to a marc_subfield_table record by bloblink
57         CREATE TABLE marc_blob_subfield (
58                 blobidlink bigint(20) NOT NULL auto_increment,
59                 subfieldvalue longtext NOT NULL,
60                 PRIMARY KEY  (blobidlink)
61                 ) TYPE=MyISAM;
62
63 # The next two tables are used for labelling the tags and subfields for
64 # different implementions of marc USMARC, UNIMARC, CANMARC, UKMARC, etc.
65
66 # marc_tag_structure contains the definition of the marc tags.
67 # any MARC is supposed to be support-able
68         CREATE TABLE marc_tag_structure (
69                 tagfield char(3) NOT NULL default '',
70                 liblibrarian char(255) NOT NULL default '',
71                 libopac char(255) NOT NULL default '',
72                 repeatable tinyint(4) NOT NULL default '0',
73                 mandatory tinyint(4) NOT NULL default '0',
74                 PRIMARY KEY  (tagfield)
75                 ) TYPE=MyISAM;
76
77
78 # marc_subfield_structure contains the definition of the marc
79 # subfields. Any MARC is supposed to be support-able
80         CREATE TABLE marc_subfield_structure (
81                 tagfield char(3) NOT NULL default '',
82                 tagsubfield char(1) NOT NULL default '',
83                 liblibrarian char(255) NOT NULL default '',     # the text shown to a librarian
84                 libopac char(255) NOT NULL default '',          # the text shown to an opac user
85                 repeatable tinyint(4) NOT NULL default '0',     # is the field repeatable 0/1 ?
86                 mandatory tinyint(4) NOT NULL default '0',      # is the subfield mandatory in manual add 0/1 ?
87                 kohafield char(40) NOT NULL default '',         # the name of the normal-koha- DB field
88                 PRIMARY KEY  (tagfield,tagsubfield)
89                 ) TYPE=MyISAM;
90
91
92 # This table is the table used for searching the marc records
93
94 # marc_tag_word contains 1 record for each word in each subfield in each tag in each biblio
95         CREATE TABLE marc_word (
96                 bibid bigint(20) NOT NULL default '0',
97                 tag char(3) NOT NULL default '',
98                 tagorder tinyint(4) NOT NULL default '1',
99                 subfieldid char(1) NOT NULL default '',
100                 subfieldorder tinyint(4) NOT NULL default '1',
101                 word varchar(255) NOT NULL default '',
102                 sndx_word varchar(255) NOT NULL default '',     # the soundex version of the word (indexed)
103                 KEY bibid (bibid),
104                 KEY tag (tag),
105                 KEY tagorder (tagorder),
106                 KEY subfieldid (subfieldid),
107                 KEY subfieldorder (subfieldorder),
108                 KEY word (word),
109                 KEY sndx_word (sndx_word)
110                 ) TYPE=MyISAM;
111