A semantic search engine for source code https://bitshift.benkurtovic.com/
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.

schema.sql 3.1 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. CREATE DATABASE `bitshift` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
  2. USE `bitshift`;
  3. CREATE TABLE `origins` (
  4. `origin_id` TINYINT UNSIGNED NOT NULL AUTO_INCREMENT,
  5. `origin_name` VARCHAR(64) NOT NULL,
  6. `origin_url` VARCHAR(512) NOT NULL,
  7. `origin_url_base` VARCHAR(512) NOT NULL,
  8. `origin_image` BLOB DEFAULT NULL,
  9. PRIMARY KEY (`origin_id`)
  10. ) ENGINE=InnoDB;
  11. CREATE TABLE `code` (
  12. `code_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
  13. `code_hash` BIGINT NOT NULL,
  14. `code_code` MEDIUMTEXT NOT NULL,
  15. PRIMARY KEY (`code_id`),
  16. KEY (`code_hash`),
  17. FULLTEXT KEY (`code_code`)
  18. ) ENGINE=InnoDB;
  19. CREATE TABLE `codelets` (
  20. `codelet_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
  21. `codelet_name` VARCHAR(300) NOT NULL,
  22. `codelet_code_id` BIGINT UNSIGNED NOT NULL,
  23. `codelet_lang` SMALLINT UNSIGNED DEFAULT NULL,
  24. `codelet_origin` TINYINT UNSIGNED NOT NULL,
  25. `codelet_url` VARCHAR(512) NOT NULL,
  26. `codelet_rank` FLOAT NOT NULL,
  27. `codelet_date_created` DATETIME DEFAULT NULL,
  28. `codelet_date_modified` DATETIME DEFAULT NULL,
  29. PRIMARY KEY (`codelet_id`),
  30. FULLTEXT KEY (`codelet_name`),
  31. KEY (`codelet_rank`),
  32. KEY (`codelet_date_created`),
  33. KEY (`codelet_date_modified`),
  34. FOREIGN KEY (`codelet_code_id`)
  35. REFERENCES `code` (`code_id`)
  36. ON DELETE RESTRICT ON UPDATE CASCADE,
  37. FOREIGN KEY (`codelet_origin`)
  38. REFERENCES `origins` (`origin_id`)
  39. ON DELETE RESTRICT ON UPDATE CASCADE
  40. ) ENGINE=InnoDB;
  41. CREATE TABLE `authors` (
  42. `author_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
  43. `author_codelet` BIGINT UNSIGNED NOT NULL,
  44. `author_name` VARCHAR(128) NOT NULL,
  45. `author_url` VARCHAR(512) DEFAULT NULL,
  46. PRIMARY KEY (`author_id`),
  47. FULLTEXT KEY (`author_name`),
  48. FOREIGN KEY (`author_codelet`)
  49. REFERENCES `codelets` (`codelet_id`)
  50. ON DELETE CASCADE ON UPDATE CASCADE
  51. ) ENGINE=InnoDB;
  52. CREATE TABLE `symbols` (
  53. `symbol_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
  54. `symbol_codelet` BIGINT UNSIGNED NOT NULL,
  55. `symbol_type` TINYINT UNSIGNED NOT NULL,
  56. `symbol_name` VARCHAR(512) NOT NULL,
  57. `symbol_row` INT UNSIGNED NOT NULL,
  58. `symbol_col` INT UNSIGNED NOT NULL,
  59. PRIMARY KEY (`symbol_id`),
  60. KEY (`symbol_type`, `symbol_name`(32)),
  61. FOREIGN KEY (`symbol_codelet`)
  62. REFERENCES `codelets` (`codelet_id`)
  63. ON DELETE CASCADE ON UPDATE CASCADE
  64. ) ENGINE=InnoDB;
  65. CREATE TABLE `cache` (
  66. `cache_id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
  67. `cache_hash` BIGINT NOT NULL,
  68. `cache_count_mnt` TINYINT UNSIGNED NOT NULL,
  69. `cache_count_exp` TINYINT UNSIGNED NOT NULL,
  70. `cache_created` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  71. `cache_last_used` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  72. PRIMARY KEY (`cache_id`)
  73. ) ENGINE=InnoDB;
  74. CREATE TABLE `cache_data` (
  75. `cdata_cache` INT UNSIGNED NOT NULL,
  76. `cdata_codelet` BIGINT UNSIGNED NOT NULL,
  77. FOREIGN KEY (`cdata_cache`)
  78. REFERENCES `cache` (`cache_id`)
  79. ON DELETE CASCADE ON UPDATE CASCADE,
  80. FOREIGN KEY (`cdata_codelet`)
  81. REFERENCES `codelets` (`codelet_id`)
  82. ON DELETE CASCADE ON UPDATE CASCADE
  83. ) ENGINE=InnoDB;