From: Frank Brehm Date: Wed, 10 Dec 2008 11:22:30 +0000 (+0000) Subject: Datenbankstruktur erfasst X-Git-Url: https://git.uhu-banane.org/?a=commitdiff_plain;h=b3166be92b2c08bdcf86a7eb0b33800b8ad5ca25;p=books.git Datenbankstruktur erfasst --- diff --git a/db/dump.sh b/db/dump.sh new file mode 100755 index 0000000..375d6e8 --- /dev/null +++ b/db/dump.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +# $Id$ +# $URL$ + +mysqldump --add-drop-database \ + --add-drop-table \ + --add-locks \ + --allow-keywords \ + -i \ + --complete-insert \ + --create-options \ + --debug-info \ + --skip-opt \ + --quick \ + --quote-names \ + --routines \ + --triggers \ + --verbose \ + $@ \ + --databases books + diff --git a/db/structure.sql b/db/structure.sql new file mode 100644 index 0000000..9deeb6b --- /dev/null +++ b/db/structure.sql @@ -0,0 +1,356 @@ +-- MySQL dump 10.11 +-- +-- Host: localhost Database: books +-- ------------------------------------------------------ +-- Server version 5.0.70 +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; + +-- +-- Current Database: `books` +-- + +/*!40000 DROP DATABASE IF EXISTS `books`*/; + +CREATE DATABASE /*!32312 IF NOT EXISTS*/ `books` /*!40100 DEFAULT CHARACTER SET utf8 */; + +USE `books`; + +-- +-- Table structure for table `autor2buch` +-- + +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +CREATE TABLE `autor2buch` ( + `id` int(10) unsigned NOT NULL, + `buch_id` int(10) unsigned NOT NULL, + `autor_id` int(10) unsigned NOT NULL, + `ord_num` int(10) unsigned NOT NULL default '0', + PRIMARY KEY (`id`), + UNIQUE KEY `buch_id` (`buch_id`,`autor_id`), + KEY `autor_id` (`autor_id`), + CONSTRAINT `autor2buch_ibfk_1` FOREIGN KEY (`buch_id`) REFERENCES `buecher` (`id`), + CONSTRAINT `autor2buch_ibfk_2` FOREIGN KEY (`autor_id`) REFERENCES `autoren` (`id`) +); +SET character_set_client = @saved_cs_client; + +-- +-- Table structure for table `autoren` +-- + +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +CREATE TABLE `autoren` ( + `id` int(10) unsigned NOT NULL, + `titel` varchar(100) default NULL, + `vorname` varchar(150) default NULL, + `mittelname` varchar(150) default NULL, + `nachname` varchar(150) NOT NULL, + `name_suffix` varchar(100) default NULL, + `autor_descr` text NOT NULL, + PRIMARY KEY (`id`), + KEY `nachname` (`nachname`,`vorname`,`mittelname`) +); +SET character_set_client = @saved_cs_client; + +-- +-- Table structure for table `bindungsarten` +-- + +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +CREATE TABLE `bindungsarten` ( + `id` int(10) unsigned NOT NULL, + `art_name` varchar(250) NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `art_name` (`art_name`) +); +SET character_set_client = @saved_cs_client; + +-- +-- Dumping data for table `bindungsarten` +-- + +INSERT INTO `bindungsarten` (`id`, `art_name`) VALUES (1,'Hartcover'); +INSERT INTO `bindungsarten` (`id`, `art_name`) VALUES (2,'Hartcover mit Schutzhülle'); +INSERT INTO `bindungsarten` (`id`, `art_name`) VALUES (5,'Hartcover, flexibel'); +INSERT INTO `bindungsarten` (`id`, `art_name`) VALUES (3,'Softcover'); +INSERT INTO `bindungsarten` (`id`, `art_name`) VALUES (4,'Softcover (Taschenbuch)'); + +-- +-- Table structure for table `buch2kategorie` +-- + +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +CREATE TABLE `buch2kategorie` ( + `id` int(10) unsigned NOT NULL, + `buch_id` int(10) unsigned NOT NULL, + `kategorie_id` int(10) unsigned NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `buch_id` (`buch_id`,`kategorie_id`), + KEY `kategorie_id` (`kategorie_id`), + CONSTRAINT `buch2kategorie_ibfk_1` FOREIGN KEY (`buch_id`) REFERENCES `buecher` (`id`), + CONSTRAINT `buch2kategorie_ibfk_2` FOREIGN KEY (`kategorie_id`) REFERENCES `kategorien` (`id`) +); +SET character_set_client = @saved_cs_client; + +-- +-- Table structure for table `buch2serie` +-- + +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +CREATE TABLE `buch2serie` ( + `id` int(10) unsigned NOT NULL, + `buch_id` int(10) unsigned NOT NULL, + `serien_id` int(10) unsigned NOT NULL, + `ord_num` int(10) unsigned NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `buch_id` (`buch_id`,`serien_id`), + KEY `serien_id` (`serien_id`), + CONSTRAINT `buch2serie_ibfk_1` FOREIGN KEY (`buch_id`) REFERENCES `buecher` (`id`), + CONSTRAINT `buch2serie_ibfk_2` FOREIGN KEY (`serien_id`) REFERENCES `serien` (`id`) +); +SET character_set_client = @saved_cs_client; + +-- +-- Table structure for table `buecher` +-- + +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +CREATE TABLE `buecher` ( + `id` int(10) unsigned NOT NULL, + `title` varchar(250) NOT NULL, + `title_original` varchar(250) default NULL COMMENT 'Der Original-Titel, wenn übersetzt', + `untertitel` varchar(250) default NULL, + `verlags_id` int(10) unsigned NOT NULL, + `orts_id` int(10) unsigned default NULL COMMENT 'Verknüpfung mit orte', + `bindungsart_id` int(10) unsigned default NULL, + `isbn` varchar(20) default NULL, + `buch_nr` varchar(100) default NULL COMMENT 'Verlagseigene Buchnummer', + `ausgabejahr` mediumint(8) unsigned default NULL COMMENT 'Erscheinungsjahr der Originalausgabe', + `druckjahr` mediumint(8) unsigned default NULL COMMENT 'Das Jahr, in dem das konkrete Buch gedruckt wurde', + `seiten` int(10) unsigned default NULL, + `preis` float unsigned default NULL, + `waehrungs_id` int(10) unsigned default NULL, + PRIMARY KEY (`id`), + KEY `title` (`title`), + KEY `verlags_id` (`verlags_id`), + KEY `isbn` (`isbn`), + KEY `bindungsart_id` (`bindungsart_id`), + KEY `orts_id` (`orts_id`), + KEY `waehrungs_id` (`waehrungs_id`), + CONSTRAINT `buecher_ibfk_1` FOREIGN KEY (`verlags_id`) REFERENCES `verlage` (`id`), + CONSTRAINT `buecher_ibfk_2` FOREIGN KEY (`orts_id`) REFERENCES `orte` (`id`), + CONSTRAINT `buecher_ibfk_3` FOREIGN KEY (`bindungsart_id`) REFERENCES `bindungsarten` (`id`), + CONSTRAINT `buecher_ibfk_4` FOREIGN KEY (`waehrungs_id`) REFERENCES `waehrungen` (`id`) +); +SET character_set_client = @saved_cs_client; + +-- +-- Table structure for table `kategorien` +-- + +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +CREATE TABLE `kategorien` ( + `id` int(10) unsigned NOT NULL, + `kategorie_name` varchar(100) NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `kategorie_name` (`kategorie_name`) +); +SET character_set_client = @saved_cs_client; + +-- +-- Table structure for table `orte` +-- + +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +CREATE TABLE `orte` ( + `id` int(10) unsigned NOT NULL, + `name` varchar(100) NOT NULL, + `descr` text NOT NULL, + `statisch` enum('n','y') NOT NULL default 'n', + PRIMARY KEY (`id`), + UNIQUE KEY `name` (`name`) +); +SET character_set_client = @saved_cs_client; + +-- +-- Table structure for table `serien` +-- + +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +CREATE TABLE `serien` ( + `id` int(10) unsigned NOT NULL, + `serien_name` varchar(100) NOT NULL, + `descr` text NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `serien_name` (`serien_name`) +); +SET character_set_client = @saved_cs_client; + +-- +-- Table structure for table `session` +-- + +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +CREATE TABLE `session` ( + `id` varchar(72) NOT NULL COMMENT 'Session-Id', + `session_data` text NOT NULL COMMENT 'Sitzungsdaten', + `expires` int(10) unsigned NOT NULL COMMENT 'UNIX-Timestamp für Ungültigkeit', + PRIMARY KEY (`id`) +); +SET character_set_client = @saved_cs_client; + +-- +-- Table structure for table `users` +-- + +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +CREATE TABLE `users` ( + `user_id` int(10) unsigned NOT NULL, + `login` varchar(50) NOT NULL COMMENT 'Login-Name', + `vorname` varchar(100) NOT NULL, + `nachname` varchar(100) NOT NULL, + `password` varchar(250) NOT NULL, + `date_created` datetime NOT NULL, + `date_changed` datetime NOT NULL, + `email` varchar(250) NOT NULL, + `deleted` enum('n','y') NOT NULL default 'n', + `enabled` enum('y','n') NOT NULL default 'y', + `admin_status` enum('n','y') NOT NULL default 'n', + `comments` text NOT NULL, + PRIMARY KEY (`user_id`), + UNIQUE KEY `login` (`login`), + KEY `nachname` (`nachname`), + FULLTEXT KEY `comments` (`comments`), + FULLTEXT KEY `nachname_fulltext` (`nachname`) +); +SET character_set_client = @saved_cs_client; + +-- +-- Temporary table structure for view `v_autor_buecher` +-- + +/*!50001 CREATE TABLE `v_autor_buecher` ( + `autor2buch_id` int(10) unsigned, + `buch_id` int(10) unsigned, + `title` varchar(250), + `title_original` varchar(250), + `untertitel` varchar(250), + `autor_id` int(10) unsigned, + `autor_name` longtext, + `autor_ord_num` int(10) unsigned, + `autor_titel` varchar(100), + `autor_vorname` varchar(150), + `autor_mittelname` varchar(150), + `autor_nachname` varchar(150), + `autor_name_suffix` varchar(100), + `autor_descr` text +) ENGINE=MyISAM */; + +-- +-- Temporary table structure for view `v_autoren` +-- + +/*!50001 CREATE TABLE `v_autoren` ( + `id` int(10) unsigned, + `name` longtext, + `titel` varchar(100), + `vorname` varchar(150), + `mittelname` varchar(150), + `nachname` varchar(150), + `name_suffix` varchar(100), + `autor_descr` text +) ENGINE=MyISAM */; + +-- +-- Table structure for table `verlage` +-- + +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +CREATE TABLE `verlage` ( + `id` int(10) unsigned NOT NULL, + `name_short` varchar(50) NOT NULL COMMENT 'Kurzname des Verlags', + `name_long` varchar(250) NOT NULL COMMENT 'Kompletter Name des Verlags', + PRIMARY KEY (`id`), + UNIQUE KEY `name_short` (`name_short`) +); +SET character_set_client = @saved_cs_client; + +-- +-- Table structure for table `waehrungen` +-- + +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +CREATE TABLE `waehrungen` ( + `id` int(10) unsigned NOT NULL, + `waehrungs_kuerzel` varchar(10) NOT NULL, + `waehrungs_name` varchar(100) NOT NULL, + `umrechnung_in_euro` float unsigned default NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `wahrungs_kuerzel` (`waehrungs_kuerzel`) +); +SET character_set_client = @saved_cs_client; + +-- +-- Dumping data for table `waehrungen` +-- + +INSERT INTO `waehrungen` (`id`, `waehrungs_kuerzel`, `waehrungs_name`, `umrechnung_in_euro`) VALUES (1,'€','Euro',1); +INSERT INTO `waehrungen` (`id`, `waehrungs_kuerzel`, `waehrungs_name`, `umrechnung_in_euro`) VALUES (2,'DM','Deutsche Mark',0.511292); +INSERT INTO `waehrungen` (`id`, `waehrungs_kuerzel`, `waehrungs_name`, `umrechnung_in_euro`) VALUES (3,'ATS','Östereichische Schilling',0.0726728); +INSERT INTO `waehrungen` (`id`, `waehrungs_kuerzel`, `waehrungs_name`, `umrechnung_in_euro`) VALUES (4,'$','US-Dollar',0.66225); +INSERT INTO `waehrungen` (`id`, `waehrungs_kuerzel`, `waehrungs_name`, `umrechnung_in_euro`) VALUES (5,'DDR-M','Mark der DDR',NULL); + +-- +-- Dumping routines for database 'books' +-- +DELIMITER ;; +DELIMITER ; + +-- +-- Current Database: `books` +-- + +USE `books`; + +-- +-- Final view structure for view `v_autor_buecher` +-- + +/*!50001 DROP TABLE `v_autor_buecher`*/; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50001 VIEW `v_autor_buecher` AS select `ab`.`id` AS `autor2buch_id`,`ab`.`buch_id` AS `buch_id`,`b`.`title` AS `title`,`b`.`title_original` AS `title_original`,`b`.`untertitel` AS `untertitel`,`ab`.`autor_id` AS `autor_id`,concat(ifnull(`a`.`titel`,_utf8''),if(isnull(`a`.`titel`),_utf8'',_utf8' '),ifnull(`a`.`vorname`,_utf8''),if(isnull(`a`.`vorname`),_utf8'',_utf8' '),ifnull(`a`.`mittelname`,_utf8''),if(isnull(`a`.`mittelname`),_utf8'',_utf8' '),`a`.`nachname`,if(isnull(`a`.`name_suffix`),_utf8'',_utf8' '),ifnull(`a`.`name_suffix`,_utf8'')) AS `autor_name`,`ab`.`ord_num` AS `autor_ord_num`,`a`.`titel` AS `autor_titel`,`a`.`vorname` AS `autor_vorname`,`a`.`mittelname` AS `autor_mittelname`,`a`.`nachname` AS `autor_nachname`,`a`.`name_suffix` AS `autor_name_suffix`,`a`.`autor_descr` AS `autor_descr` from (`buecher` `b` left join (`autor2buch` `ab` left join `autoren` `a` on((`ab`.`autor_id` = `a`.`id`))) on((`ab`.`buch_id` = `b`.`id`))) order by `b`.`title`,`ab`.`buch_id`,`ab`.`ord_num` */; + +-- +-- Final view structure for view `v_autoren` +-- + +/*!50001 DROP TABLE `v_autoren`*/; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50001 VIEW `v_autoren` AS select `autoren`.`id` AS `id`,concat(ifnull(`autoren`.`titel`,_utf8''),if(isnull(`autoren`.`titel`),_utf8'',_utf8' '),ifnull(`autoren`.`vorname`,_utf8''),if(isnull(`autoren`.`vorname`),_utf8'',_utf8' '),ifnull(`autoren`.`mittelname`,_utf8''),if(isnull(`autoren`.`mittelname`),_utf8'',_utf8' '),`autoren`.`nachname`,if(isnull(`autoren`.`name_suffix`),_utf8'',_utf8' '),ifnull(`autoren`.`name_suffix`,_utf8'')) AS `name`,`autoren`.`titel` AS `titel`,`autoren`.`vorname` AS `vorname`,`autoren`.`mittelname` AS `mittelname`,`autoren`.`nachname` AS `nachname`,`autoren`.`name_suffix` AS `name_suffix`,`autoren`.`autor_descr` AS `autor_descr` from `autoren` order by `autoren`.`nachname`,`autoren`.`vorname`,`autoren`.`mittelname`,`autoren`.`name_suffix` */; +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + +-- Dump completed on 2008-12-10 11:16:40