From: olivier Date: Tue, 17 Jun 2008 14:43:42 +0000 (+0000) Subject: tagging crem SQL structure 0.1 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=b216d14b7986d7ec6c0efd5a84de0211d5652311;p=telemeta-data.git tagging crem SQL structure 0.1 git-svn-id: http://svn.parisson.org/svn/crem@41 3bf09e05-f825-4182-b9bc-eedd7160adf0 --- diff --git a/tags/crem-0.1.sql b/tags/crem-0.1.sql new file mode 100644 index 0000000..4f60c51 --- /dev/null +++ b/tags/crem-0.1.sql @@ -0,0 +1,378 @@ +-- +-- Copyright Samalyse SARL, 2008 +-- Auteur: Olivier Guilyardi +-- +-- Structure de la nouvelle base du CREM +-- +-- Ce logiciel est régi par la licence CeCILL soumise au droit français et +-- respectant les principes de diffusion des logiciels libres. Vous pouvez +-- utiliser, modifier et/ou redistribuer ce programme sous les conditions +-- de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA +-- sur le site "http://www.cecill.info". +-- +-- En contrepartie de l'accessibilité au code source et des droits de copie, +-- de modification et de redistribution accordés par cette licence, il n'est +-- offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, +-- seule une responsabilité restreinte pèse sur l'auteur du programme, le +-- titulaire des droits patrimoniaux et les concédants successifs. +-- +-- A cet égard l'attention de l'utilisateur est attirée sur les risques +-- associés au chargement, à l'utilisation, à la modification et/ou au +-- développement et à la reproduction du logiciel par l'utilisateur étant +-- donné sa spécificité de logiciel libre, qui peut le rendre complexe à +-- manipuler et qui le réserve donc à des développeurs et des professionnels +-- avertis possédant des connaissances informatiques approfondies. Les +-- utilisateurs sont donc invités à charger et tester l'adéquation du +-- logiciel à leurs besoins dans des conditions permettant d'assurer la +-- sécurité de leurs systèmes et ou de leurs données et, plus généralement, +-- à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. +-- +-- Le fait que vous puissiez accéder à cet en-tête signifie que vous avez +-- pris connaissance de la licence CeCILL, et que vous en avez accepté les +-- termes. +-- +-- SVN:$Id$ +-- + +-- +-- Enumérations simples +-- + +CREATE TABLE physical_formats ( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + value VARCHAR(250) NOT NULL +); + +CREATE TABLE publishing_status ( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + value VARCHAR(250) NOT NULL +); + +CREATE TABLE acquisition_modes ( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + value VARCHAR(250) NOT NULL +); + +CREATE TABLE metadata_authors ( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + value VARCHAR(250) NOT NULL +); + +CREATE TABLE metadata_writers ( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + value VARCHAR(250) NOT NULL +); + +CREATE TABLE legal_rights ( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + value VARCHAR(250) NOT NULL +); + +CREATE TABLE recording_contexts ( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + value VARCHAR(250) NOT NULL +); + +CREATE TABLE ad_conversions ( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + value VARCHAR(250) NOT NULL +); + +CREATE TABLE vernacular_styles ( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + value VARCHAR(250) NOT NULL +); + +CREATE TABLE generic_styles ( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + value VARCHAR(250) NOT NULL +); + +-- +-- Editeurs et collections +-- + +CREATE TABLE publishers ( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + value VARCHAR(250) NOT NULL +); + +CREATE TABLE publisher_collections ( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + publisher_id INTEGER NOT NULL, + value VARCHAR(250) NOT NULL, + + FOREIGN KEY(publisher_id) REFERENCES publishers (id) +); + +-- +-- Thésaurus géographique +-- + +CREATE TABLE location_types ( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + type VARCHAR(250) NOT NULL +); + +CREATE TABLE locations ( + name VARCHAR(250) NOT NULL PRIMARY KEY, + type ENUM('country', 'continent', 'other'), + complete_type_id INTEGER NOT NULL, + current_name VARCHAR(250), + is_authoritative BOOLEAN NOT NULL, + + FOREIGN KEY(current_name) REFERENCES locations (name), + FOREIGN KEY(complete_type_id) REFERENCES location_types (id) +); + +CREATE TABLE location_aliases ( + location_name VARCHAR(250) NOT NULL, + alias VARCHAR(250) NOT NULL, + is_authoritative BOOLEAN NOT NULL, + + PRIMARY KEY(location_name, alias), + FOREIGN KEY(location_name) REFERENCES locations (name) +); + +CREATE TABLE location_relations ( + location_name VARCHAR(250) NOT NULL, + parent_location_name VARCHAR(250) NOT NULL, + + PRIMARY KEY(location_name, parent_location_name), + FOREIGN KEY(location_name) REFERENCES locations (name), + FOREIGN KEY(parent_location_name) REFERENCES locations (name) +); + +-- +-- Ethnies +-- + +CREATE TABLE ethnic_groups ( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + name VARCHAR(250) NOT NULL +); + +CREATE TABLE ethnic_group_aliases ( + ethnic_group_id INTEGER NOT NULL, + name VARCHAR(250) NOT NULL, + + FOREIGN KEY(ethnic_group_id) REFERENCES ethnic_groups (id) +); + +-- +-- Collections +-- + +CREATE TABLE media_collections ( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + reference VARCHAR(250) NOT NULL UNIQUE, + physical_format_id INTEGER NOT NULL, + old_code VARCHAR(250) NOT NULL UNIQUE, + code VARCHAR(250) NOT NULL UNIQUE, + title VARCHAR(250) NOT NULL, + alt_title VARCHAR(250) NOT NULL, + physical_items_num INTEGER NOT NULL, + publishing_status_id INTEGER NOT NULL, + creator VARCHAR(250) NOT NULL, + booklet_author VARCHAR(250) NOT NULL, + booklet_description TEXT NOT NULL, + collector VARCHAR(250) NOT NULL, + collector_is_creator BOOLEAN NOT NULL, + publisher_id INTEGER NOT NULL, + year_published INTEGER NOT NULL, + publisher_collection_id INTEGER NOT NULL, + publisher_serial VARCHAR(250) NOT NULL, + external_references TEXT NOT NULL, + acquisition_mode_id INTEGER NOT NULL, + comment TEXT NOT NULL, + metadata_author_id INTEGER NOT NULL, + metadata_writer_id INTEGER NOT NULL, + legal_rights_id INTEGER NOT NULL, + alt_ids VARCHAR(250) NOT NULL, + recorded_from_year INTEGER NOT NULL, + recorded_to_year INTEGER NOT NULL, + recording_context_id INTEGER NOT NULL, + approx_duration TIME NOT NULL, + doctype_code INTEGER NOT NULL, + travail VARCHAR(250) NOT NULL, + state VARCHAR(250) NOT NULL, + cnrs_contributor VARCHAR(250) NOT NULL, + items_done VARCHAR(250) NOT NULL, + a_informer_07_03 VARCHAR(250) NOT NULL, + ad_conversion_id INTEGER NOT NULL, + public_access ENUM('none', 'metadata', 'full') NOT NULL, + + FOREIGN KEY(ad_conversion_id) REFERENCES ad_conversions (id), + FOREIGN KEY(publisher_collection_id) REFERENCES publisher_collections (id), + FOREIGN KEY(recording_context_id) REFERENCES recording_contexts (id), + FOREIGN KEY(publisher_id) REFERENCES publishers (id), + FOREIGN KEY(metadata_author_id) REFERENCES metadata_authors (id), + FOREIGN KEY(physical_format_id) REFERENCES physical_formats (id), + FOREIGN KEY(metadata_writer_id) REFERENCES metadata_writers (id), + FOREIGN KEY(legal_rights_id) REFERENCES legal_rights (id), + FOREIGN KEY(acquisition_mode_id) REFERENCES acquisition_modes (id), + FOREIGN KEY(publishing_status_id) REFERENCES publishing_status (id) +); + +-- +-- Items +-- + +CREATE TABLE media_items ( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + collection_id INTEGER NOT NULL, + track VARCHAR(250) NOT NULL, + code VARCHAR(250) NOT NULL, + approx_duration TIME NOT NULL, + recorded_from_date DATE NOT NULL, + recorded_to_date DATE NOT NULL, + location_name VARCHAR(250) NOT NULL, + location_comment VARCHAR(250) NOT NULL, + ethnic_group_id INTEGER NOT NULL, + title VARCHAR(250) NOT NULL, + alt_title VARCHAR(250) NOT NULL, + author VARCHAR(250) NOT NULL, + vernacular_style_id INTEGER NOT NULL, + context_comment TEXT NOT NULL, + external_references VARCHAR(250) NOT NULL, + moda_execut VARCHAR(250) NOT NULL, + copied_from_item_id INTEGER, + collector VARCHAR(250) NOT NULL, + cultural_area VARCHAR(250) NOT NULL, + generic_style_id INTEGER NOT NULL, + collector_selection VARCHAR(250) NOT NULL, + creator_reference VARCHAR(250) NOT NULL, + filename VARCHAR(250) NOT NULL, + public_access ENUM('none', 'metadata', 'full') NOT NULL, + + FOREIGN KEY(ethnic_group_id) REFERENCES ethnic_groups (id), + FOREIGN KEY(collection_id) REFERENCES media_collections (id), + FOREIGN KEY(vernacular_style_id) REFERENCES vernacular_styles (id), + FOREIGN KEY(location_name) REFERENCES locations (name), + FOREIGN KEY(copied_from_item_id) REFERENCES media_items (id), + FOREIGN KEY(generic_style_id) REFERENCES generic_styles (id) +); + +-- +-- Parties d'item/marqueurs +-- + +CREATE TABLE media_parts ( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + item_id INTEGER NOT NULL, + title VARCHAR(250) NOT NULL, + start FLOAT NOT NULL, + end FLOAT NOT NULL, + + FOREIGN KEY(item_id) REFERENCES media_items (id) +); + +-- +-- Instruments et formations +-- + +CREATE TABLE instruments ( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + name VARCHAR(250) NOT NULL +); + +CREATE TABLE instrument_relations ( + instrument_id INTEGER NOT NULL, + parent_instrument_id INTEGER NOT NULL, + + FOREIGN KEY(instrument_id) REFERENCES instruments (id), + FOREIGN KEY(parent_instrument_id) REFERENCES instruments (id) +); + +CREATE TABLE instrument_aliases ( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + name VARCHAR(250) NOT NULL +); + +CREATE TABLE instrument_alias_relations ( + alias_id INTEGER NOT NULL, + instrument_id INTEGER NOT NULL, + + FOREIGN KEY(alias_id) REFERENCES instrument_aliases (id), + FOREIGN KEY(instrument_id) REFERENCES instruments (id) +); + +CREATE TABLE media_item_performances ( + media_item_id INTEGER NOT NULL, + instrument_id INTEGER NOT NULL, + alias_id INTEGER NOT NULL, + instruments_num VARCHAR(250) NOT NULL, + musicians VARCHAR(250) NOT NULL, + + FOREIGN KEY(media_item_id) REFERENCES media_items (id), + FOREIGN KEY(instrument_id) REFERENCES instruments (id), + FOREIGN KEY(alias_id) REFERENCES instrument_aliases (id) +); + +-- +-- Contexte ethnographique +-- + +CREATE TABLE context_keywords ( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + value VARCHAR(250) NOT NULL +); + +CREATE TABLE media_item_keywords ( + item_id INTEGER NOT NULL, + keyword_id INTEGER NOT NULL, + + PRIMARY KEY(item_id, keyword_id), + FOREIGN KEY(item_id) REFERENCES media_items (id), + FOREIGN KEY(keyword_id) REFERENCES context_keywords (id) +); + +-- +-- Utilisateurs +-- + +CREATE TABLE users ( + username VARCHAR(64) NOT NULL PRIMARY KEY, + level ENUM ('user', 'maintainer', 'admin') NOT NULL, + first_name VARCHAR(250) NOT NULL, + last_name VARCHAR(250) NOT NULL, + phone VARCHAR(250) NOT NULL, + email VARCHAR(250) NOT NULL +); + +-- +-- Séléctions +-- + +CREATE TABLE playlists ( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + owner_username VARCHAR(250) NOT NULL, + name VARCHAR(250) NOT NULL, + + FOREIGN KEY(owner_username) REFERENCES users (username) +); + +CREATE TABLE playlist_resources ( + playlist_id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + resource_type ENUM('item', 'collection') NOT NULL, + resource_id INTEGER NOT NULL, + + FOREIGN KEY(playlist_id) REFERENCES playlists (id) +); + + +-- +-- Historique des modifications +-- + +CREATE TABLE revisions ( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + element_type VARCHAR(32) NOT NULL, + element_id INTEGER NOT NULL, + change_type ENUM('create', 'update', 'delete') NOT NULL, + time DATETIME NOT NULL, + username VARCHAR(64) NOT NULL, + + FOREIGN KEY(username) REFERENCES users (username) +); +