|
Структура БД MySQL
#34846033
Ссылка:
Ссылка на сообщение:
Ссылка с названием темы:
|
|
|
|
1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42. 43. 44. 45. 46. 47. 48. 49. 50. 51. 52. 53. 54. 55. 56. 57. 58. 59. 60. 61. 62. 63. 64. 65. 66. 67. 68. 69. 70. 71. 72. 73. 74. 75. 76. 77. 78. 79. 80. 81. 82. 83. 84. 85. 86. 87. 88. 89. 90. 91. 92. 93. 94. 95. 96. 97. 98. 99. 100. 101. 102.
/*==============================================================*/
/* DBMS name: MySQL 4.0 */
/* Created on: 04.10.2007 11:12:42 */
/*==============================================================*/
/*==============================================================*/
/* Table: Boxses */
/*==============================================================*/
create table Boxses
(
Box_ID int not null,
KiJa_ID int,
Name Varchar( 128 ),
Comment varchar( 255 ),
Type_ID int not null,
Other char( 10 ),
primary key (Box_ID)
)
type = InnoDB;
/*==============================================================*/
/* Index: "Reference_2_FK" */
/*==============================================================*/
create index Reference_2_FK
(
KiJa_ID
);
/*==============================================================*/
/* Table: KiJas */
/*==============================================================*/
create table KiJas
(
KiJa_ID int not null,
RSh_ID int not null,
Name varchar( 128 ),
Comment varchar( 255 ),
Other char( 10 ),
primary key (KiJa_ID)
)
comment = "Таблица описывает КЯ"
type = InnoDB;
/*==============================================================*/
/* Index: "Reference_1_FK" */
/*==============================================================*/
create index Reference_1_FK
(
RSh_ID
);
/*==============================================================*/
/* Table: Links */
/*==============================================================*/
create table Links
(
InBox_ID int not null,
OutBox_ID int not null,
primary key (InBox_ID, OutBox_ID)
)
type = InnoDB;
/*==============================================================*/
/* Index: "Reference_3_FK" */
/*==============================================================*/
create index Reference_3_FK
(
InBox_ID
);
/*==============================================================*/
/* Index: "Reference_4_FK" */
/*==============================================================*/
create index Reference_4_FK
(
OutBox_ID
);
/*==============================================================*/
/* Table: RShs */
/*==============================================================*/
create table RShs
(
RSh_ID int not null,
Name varchar( 128 ),
Comment varchar( 255 ),
Other char( 10 ),
primary key (RSh_ID)
)
comment = "Таблица описывает РШ№1..."
type = InnoDB;
alter table Boxses add constraint FK_Reference_2 foreign key (KiJa_ID)
references KiJas (KiJa_ID) on delete restrict on update restrict;
alter table KiJas add constraint FK_Reference_1 foreign key (RSh_ID)
references RShs (RSh_ID) on delete restrict on update restrict;
alter table Links add constraint FK_Reference_3 foreign key (InBox_ID)
references Boxses (Box_ID) on delete restrict on update restrict;
alter table Links add constraint FK_Reference_4 foreign key (OutBox_ID)
references Boxses (Box_ID) on delete restrict on update restrict;
Собственно, если бы в одну распредкоробку было бы не больше одного входа, то таблица Links не нужна
|
|
|