| 1 | /* |
|---|
| 2 | create_db.sql |
|---|
| 3 | |
|---|
| 4 | A SQL script for creating the database tables. |
|---|
| 5 | |
|---|
| 6 | (c) 2002 Harri Kaimio |
|---|
| 7 | |
|---|
| 8 | Version: $Id: create_db.sql,v 1.10 2003/03/05 19:57:15 kaimio Exp $ |
|---|
| 9 | */ |
|---|
| 10 | |
|---|
| 11 | /* Create the photos table */ |
|---|
| 12 | create table photos ( |
|---|
| 13 | photo_id INT not null, |
|---|
| 14 | shoot_time datetime, |
|---|
| 15 | time_accuracy float default 0, |
|---|
| 16 | shooting_place varchar(30), |
|---|
| 17 | photographer varchar(30), |
|---|
| 18 | f_stop float, |
|---|
| 19 | focal_length float, |
|---|
| 20 | shutter_speed float, |
|---|
| 21 | camera varchar(30), |
|---|
| 22 | lens varchar(30), |
|---|
| 23 | film varchar(30), |
|---|
| 24 | film_speed float, |
|---|
| 25 | pref_rotation float, |
|---|
| 26 | orig_fname varchar(30), |
|---|
| 27 | description text, |
|---|
| 28 | photo_quality INT, |
|---|
| 29 | last_modified datetime, |
|---|
| 30 | tech_notes text, |
|---|
| 31 | |
|---|
| 32 | PRIMARY KEY( photo_id ), |
|---|
| 33 | FULLTEXT( shooting_place, description ) |
|---|
| 34 | ) ENGINE = MyISAM; |
|---|
| 35 | |
|---|
| 36 | |
|---|
| 37 | create table volumes ( |
|---|
| 38 | volume_id varchar(30) NOT NULL, |
|---|
| 39 | root_path varchar(255) NOT NULL, |
|---|
| 40 | |
|---|
| 41 | PRIMARY KEY( volume_id ) |
|---|
| 42 | ) ENGINE = MyISAM; |
|---|
| 43 | |
|---|
| 44 | create table image_instances ( |
|---|
| 45 | volume_id varchar(30) NOT NULL /* REFERENCES volumes( volume_id ) */, |
|---|
| 46 | fname varchar(255) NOT NULL, |
|---|
| 47 | photo_id integer NOT NULL REFERENCES photos( photo_id ), |
|---|
| 48 | width integer, |
|---|
| 49 | height integer, |
|---|
| 50 | rotated float, |
|---|
| 51 | instance_type ENUM ( "original", "modified", "thumbnail" ) NOT NULL, |
|---|
| 52 | PRIMARY KEY( volume_id, fname ) |
|---|
| 53 | ) ENGINE = MyISAM; |
|---|
| 54 | |
|---|
| 55 | |
|---|
| 56 | /* |
|---|
| 57 | Create collection table |
|---|
| 58 | */ |
|---|
| 59 | |
|---|
| 60 | create table photo_collections ( |
|---|
| 61 | collection_id INTEGER NOT NULL, |
|---|
| 62 | parent INTEGER, |
|---|
| 63 | collection_name VARCHAR(30) NOT NULL, |
|---|
| 64 | collection_desc TEXT, |
|---|
| 65 | create_time DATETIME, |
|---|
| 66 | last_modified DATETIME, |
|---|
| 67 | PRIMARY KEY( collection_id ), |
|---|
| 68 | FULLTEXT( collection_desc ) |
|---|
| 69 | ) ENGINE = MyISAM; |
|---|
| 70 | |
|---|
| 71 | insert into photo_collections values (1, 0, "Root", "Root folder", NULL, NULL ); |
|---|
| 72 | |
|---|
| 73 | /* |
|---|
| 74 | Create the collection_photos table |
|---|
| 75 | */ |
|---|
| 76 | create table collection_photos ( |
|---|
| 77 | collection_id INTEGER NOT NULL, |
|---|
| 78 | photo_id INTEGER NOT NULL, |
|---|
| 79 | PRIMARY KEY (collection_id, photo_id) |
|---|
| 80 | ) ENGINE = MyISAM; |
|---|