Added POD.
[koha.git] / marc / marcschema.sql
1 #  $Id$
2 #  
3 #  $Log$
4 #  Revision 1.16  2002/08/30 17:26:14  tonnesen
5 #  Added bibliothesaurus table
6 #
7 #  Revision 1.15  2002/07/24 15:52:53  tipaul
8 #  1st scripts for MARC-DB.
9 #
10 #  WARNING : YOU MUST DO THE FOLLOWING IF YOU EXPECT THE MAIN-BRANCH TO WORK.
11 #
12 #  * install MARC::Record package, from cpan or sourceforge
13 #  * OVERWRITE File.pm and USMARC.pm. The original misses 1 functionnality we absolutly need in koha (reading a MARC from a variable, not from a file). Thanks to Steve, who modified MARC::Record.
14 #  * modify your DB by adding marcschema.sql tables
15 #  * populate new tables by launching fill_usmarc.pl
16 #
17 #  Then, it should work...
18 #  What works exactly will come in the next commit, in a few minuts (hitchcock suspens...)
19 #
20 #  Revision 1.14  2002/06/04 08:13:31  tipaul
21 #  ouuppsss... forget the 1.13 version, i made a mistake. This version works and should be the last
22 #
23 #  Revision 1.13/1.14  2002/06/04 07:56:56  tipaul
24 #  New and hopefully last version of the MARC-DB. Is the fastest in benchmark, everybody agree ;-) (Sergey, Steve and me, Paul)
25 #
26 #  Revision 1.13 2002/06/04 Paul
27 #  should be the last version... remains only 2 tables : the main table and the subfield one.
28 #  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
29 #  only real information that should be in this table, it has been thrown to subfield table (not a normal form, but an optimized one...)
30 #
31 #  Revision 1.12  2002/05/31 20:03:17  tonnesen
32 #  removed another _sergey
33 #
34 #  Revision 1.11  2002/05/31 19:41:29  tonnesen
35 #  removed fieldid in favour of tagid, removed _sergey from table names, added
36 #  tagorder field to tag table, renamed marc_field_table to marc_tag_table.
37 #
38 #
39 #
40 #  These first three tables store the data from a MARC record.
41         
42 # marc_biblio contains 1 record for each biblio in the DB
43 CREATE TABLE marc_biblio (
44                 bibid bigint(20) unsigned NOT NULL auto_increment,
45                 biblionumber int(20) unsigned NOT NULL,
46                 datecreated date NOT NULL default '0000-00-00',
47                 datemodified date default NULL,
48                 origincode char(20) default NULL,
49                 PRIMARY KEY  (bibid),
50                 KEY origincode (origincode),
51                 KEY biblionumber (biblionumber)
52                 ) TYPE=MyISAM;
53
54 CREATE TABLE marc_subfield_table (
55         subfieldid  bigint(20) unsigned NOT NULL auto_increment,# subfield identifier
56         bibid bigint(20) unsigned NOT NULL,                     # link to marc_biblio table
57         tag char(3) NOT NULL,                                   # tag number
58         tagorder tinyint(4) NOT NULL default '1',               # display order for tags within a biblio when a tag is repeated
59         tag_indicator char(2) NOT NULL,                         # tag indicator
60         subfieldcode char(1) NOT NULL default '',               # subfield code
61         subfieldorder tinyint(4) NOT NULL default '1',          # display order for subfields within a tag when a subfield is repeated
62         subfieldvalue varchar(255) default NULL,                # the subfields value if not longer than 255 char
63         valuebloblink bigint(20) default NULL,                  # the link to the blob, if value is longer than 255 char
64         PRIMARY KEY (subfieldid),
65         KEY bibid (bibid),
66         KEY tag (tag),
67         KEY tag_indicator (tag_indicator),
68         KEY subfieldorder (subfieldorder),
69         KEY subfieldcode (subfieldcode),
70         KEY subfieldvalue (subfieldvalue)
71 );
72
73 # marc_blob_subfield containts subfields longer than 255 car.
74 # They are linked to a marc_subfield_table record by bloblink
75         CREATE TABLE marc_blob_subfield (
76                 blobidlink bigint(20) NOT NULL auto_increment,
77                 subfieldvalue longtext NOT NULL,
78                 PRIMARY KEY  (blobidlink)
79                 ) TYPE=MyISAM;
80
81 # The next two tables are used for labelling the tags and subfields for
82 # different implementions of marc USMARC, UNIMARC, CANMARC, UKMARC, etc.
83
84 # marc_tag_structure contains the definition of the marc tags.
85 # any MARC is supposed to be support-able
86         CREATE TABLE marc_tag_structure (
87                 tagfield char(3) NOT NULL default '',
88                 liblibrarian char(255) NOT NULL default '',
89                 libopac char(255) NOT NULL default '',
90                 repeatable tinyint(4) NOT NULL default '0',
91                 mandatory tinyint(4) NOT NULL default '0',
92                 PRIMARY KEY  (tagfield)
93                 ) TYPE=MyISAM;
94
95
96 # marc_subfield_structure contains the definition of the marc
97 # subfields. Any MARC is supposed to be support-able
98         CREATE TABLE marc_subfield_structure (
99                 tagfield char(3) NOT NULL default '',
100                 tagsubfield char(1) NOT NULL default '',
101                 liblibrarian char(255) NOT NULL default '',     # the text shown to a librarian
102                 libopac char(255) NOT NULL default '',          # the text shown to an opac user
103                 repeatable tinyint(4) NOT NULL default '0',     # is the field repeatable 0/1 ?
104                 mandatory tinyint(4) NOT NULL default '0',      # is the subfield mandatory in manual add 0/1 ?
105                 kohafield char(40) NOT NULL default '',         # the name of the normal-koha- DB field
106                 PRIMARY KEY  (tagfield,tagsubfield)
107                 ) TYPE=MyISAM;
108
109
110 # This table is the table used for searching the marc records
111
112 # marc_tag_word contains 1 record for each word in each subfield in each tag in each biblio
113         CREATE TABLE marc_word (
114                 bibid bigint(20) NOT NULL default '0',
115                 tag char(3) NOT NULL default '',
116                 tagorder tinyint(4) NOT NULL default '1',
117                 subfieldid char(1) NOT NULL default '',
118                 subfieldorder tinyint(4) NOT NULL default '1',
119                 word varchar(255) NOT NULL default '',
120                 sndx_word varchar(255) NOT NULL default '',     # the soundex version of the word (indexed)
121                 KEY bibid (bibid),
122                 KEY tag (tag),
123                 KEY tagorder (tagorder),
124                 KEY subfieldid (subfieldid),
125                 KEY subfieldorder (subfieldorder),
126                 KEY word (word),
127                 KEY sndx_word (sndx_word)
128                 ) TYPE=MyISAM;
129
130
131 CREATE TABLE bibliothesaurus ( 
132    code bigint(20) NOT NULL auto_increment, 
133    freelib char(255) NOT NULL default '', 
134    stdlib char(255) NOT NULL default '', 
135    type char(80) NOT NULL default '', 
136    PRIMARY KEY  (code), 
137    KEY freelib (freelib), 
138    KEY stdlib (stdlib), 
139    KEY type (type) 
140  ) TYPE=MyISAM; 
141