An unfinished system to manage all your paper documentation in an easy way.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

пре 5 година
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. DROP TABLE IF EXISTS `documents`;
  2. CREATE TABLE `documents` (
  3. `id` char(36) NOT NULL,
  4. `owner` varchar(45) DEFAULT NULL,
  5. `name` varchar(45) DEFAULT NULL,
  6. `created` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  7. `status` enum('nodata','inprogress','deleted','ok') NOT NULL DEFAULT 'nodata',
  8. PRIMARY KEY (`id`)
  9. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  10. DROP TABLE IF EXISTS `documents_page`;
  11. CREATE TABLE `documents_page` (
  12. `documentId` char(36) NOT NULL,
  13. `pageId` char(36) NOT NULL,
  14. PRIMARY KEY (`documentId`,`pageId`),
  15. KEY `fk_docpage_pageid_idx` (`pageId`),
  16. CONSTRAINT `fk_docpage_docid` FOREIGN KEY (`documentId`) REFERENCES `documents` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION,
  17. CONSTRAINT `fk_docpage_pageid` FOREIGN KEY (`pageId`) REFERENCES `pages` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION
  18. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  19. DROP TABLE IF EXISTS `documents_tags`;
  20. CREATE TABLE `documents_tags` (
  21. `documentId` char(36) NOT NULL,
  22. `tagId` char(36) NOT NULL,
  23. PRIMARY KEY (`documentId`,`tagId`),
  24. KEY `fk_tags_id_idx` (`tagId`),
  25. CONSTRAINT `fk_doctags_docid` FOREIGN KEY (`documentId`) REFERENCES `documents` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION,
  26. CONSTRAINT `fk_doctags_tagid` FOREIGN KEY (`tagId`) REFERENCES `tags` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION
  27. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  28. DROP TABLE IF EXISTS `lang`;
  29. CREATE TABLE `lang` (
  30. `id` char(36) NOT NULL,
  31. `short` char(2) DEFAULT NULL,
  32. `name` varchar(45) DEFAULT NULL,
  33. PRIMARY KEY (`id`),
  34. UNIQUE KEY `short_UNIQUE` (`short`)
  35. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  36. DROP TABLE IF EXISTS `pages`;
  37. CREATE TABLE `pages` (
  38. `id` char(36) NOT NULL,
  39. `owner` varchar(45) DEFAULT NULL,
  40. `documentId` int(11) unsigned NOT NULL,
  41. `name` varchar(45) DEFAULT NULL,
  42. `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  43. `status` enum('nodata','inprogress','deleted','ok') DEFAULT 'nodata',
  44. `contenttype` varchar(45) DEFAULT NULL,
  45. PRIMARY KEY (`id`)
  46. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  47. DROP TABLE IF EXISTS `pages_words`;
  48. CREATE TABLE `pages_words` (
  49. `pageId` char(36) NOT NULL,
  50. `wordId` char(36) NOT NULL DEFAULT 'en',
  51. PRIMARY KEY (`pageId`,`wordId`),
  52. KEY `fk_pagword_wordid_idx` (`wordId`),
  53. CONSTRAINT `fk_pagword_pageid` FOREIGN KEY (`pageId`) REFERENCES `pages` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION,
  54. CONSTRAINT `fk_pagword_wordid` FOREIGN KEY (`wordId`) REFERENCES `words` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION
  55. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  56. DROP TABLE IF EXISTS `tags`;
  57. CREATE TABLE `tags` (
  58. `id` char(36) NOT NULL,
  59. `tag` varchar(45) DEFAULT NULL,
  60. PRIMARY KEY (`id`),
  61. UNIQUE KEY `tag_UNIQUE` (`tag`)
  62. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  63. DROP TABLE IF EXISTS `users`;
  64. CREATE TABLE `users` (
  65. `username` varchar(255) NOT NULL,
  66. `passwd` varchar(255) DEFAULT NULL,
  67. `groups` varchar(255) DEFAULT NULL,
  68. PRIMARY KEY (`username`)
  69. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  70. DROP TABLE IF EXISTS `words`;
  71. CREATE TABLE `words` (
  72. `id` char(36) NOT NULL,
  73. `word` varchar(45) DEFAULT NULL,
  74. PRIMARY KEY (`id`),
  75. UNIQUE KEY `word_UNIQUE` (`word`)
  76. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  77. DROP TABLE IF EXISTS `words_lang`;
  78. CREATE TABLE `words_lang` (
  79. `wordId` char(36) NOT NULL,
  80. `langId` char(36) NOT NULL,
  81. PRIMARY KEY (`wordId`,`langId`),
  82. KEY `fk_worlan_langid_idx` (`langId`),
  83. CONSTRAINT `fk_worlan_langid` FOREIGN KEY (`langId`) REFERENCES `lang` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION,
  84. CONSTRAINT `fk_worlan_wordid` FOREIGN KEY (`wordId`) REFERENCES `words` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION
  85. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;