lineage.sql 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  1. /*==============================================================*/
  2. /* DBMS name: MySQL 5.0 */
  3. /* Created on: 2020/9/19 12:42:47 */
  4. /*==============================================================*/
  5. drop table if exists tb_apply;
  6. drop table if exists tb_comment;
  7. drop table if exists tb_family_album;
  8. drop table if exists tb_family_events;
  9. drop table if exists tb_family_garden;
  10. drop table if exists tb_family_honor;
  11. drop table if exists tb_family_photo;
  12. drop table if exists tb_family_member;
  13. drop table if exists tb_goods;
  14. drop table if exists tb_goods_type;
  15. drop table if exists tb_info;
  16. drop table if exists tb_msg;
  17. drop table if exists tb_orders;
  18. drop table if exists tb_person_life;
  19. drop table if exists tb_self_article;
  20. drop table if exists tb_app_user;
  21. drop table if exists tb_family;
  22. drop table if exists tb_template;
  23. drop table if exists tb_friend;
  24. /*==============================================================*/
  25. /* Table: apply 申请家族 */
  26. /*==============================================================*/
  27. create table tb_apply
  28. (
  29. id int not null,
  30. family_id int(11),
  31. app_user_id int,
  32. primary key (id)
  33. );
  34. /*==============================================================*/
  35. /* Table: comment 评论 */
  36. /*==============================================================*/
  37. create table tb_comment
  38. (
  39. id int not null,
  40. article_id int,
  41. app_user_id int,
  42. comment varchar(500),
  43. thumbs int,
  44. primary key (id)
  45. );
  46. /*==============================================================*/
  47. /* Table: family_album 家族相簿 */
  48. /*==============================================================*/
  49. create table tb_family_album
  50. (
  51. id int(11) not null comment 'ID',
  52. family_id int(11),
  53. title varchar(500),
  54. url varchar(20),
  55. primary key (id)
  56. );
  57. /*==============================================================*/
  58. /* Table: family_events 大事记 */
  59. /*==============================================================*/
  60. create table tb_family_events
  61. (
  62. id int(11) not null comment 'ID',
  63. family_id int(11),
  64. title varchar(500),
  65. content varchar(500),
  66. primary key (id)
  67. );
  68. /*==============================================================*/
  69. /* Table: family_garden 家族园地 */
  70. /*==============================================================*/
  71. create table tb_family_garden
  72. (
  73. id int(11) not null comment 'ID',
  74. family_id int(11),
  75. title varchar(500),
  76. content varchar(500),
  77. order int,
  78. primary key (id)
  79. );
  80. /*==============================================================*/
  81. /* Table: family_honor */
  82. /*==============================================================*/
  83. create table tb_family_honor
  84. (
  85. id int(11) not null comment 'ID',
  86. family_id int(11),
  87. title varchar(500),
  88. content varchar(500),
  89. pic_url varchar(50),
  90. primary key (id)
  91. );
  92. /*==============================================================*/
  93. /* Table: family_photo */
  94. /*==============================================================*/
  95. create table tb_family_photo
  96. (
  97. id int(11) not null comment 'ID',
  98. family_id int(11),
  99. album_id int(11),
  100. title varchar(500),
  101. url varchar(20),
  102. primary key (id)
  103. );
  104. /*==============================================================*/
  105. /* Table: family_user */
  106. /*==============================================================*/
  107. create table tb_family_member
  108. (
  109. id int(11) not null auto_increment comment 'ID',
  110. family_id int(11),
  111. parent_f varchar(100),
  112. spouse varchar(100),
  113. primary key (id)
  114. );
  115. /*==============================================================*/
  116. /* Table: goods */
  117. /*==============================================================*/
  118. create table tb_goods
  119. (
  120. id int not null,
  121. typeid int,
  122. title varchar(100),
  123. price float,
  124. goods_date date,
  125. picurl varchar(100),
  126. sell int,
  127. primary key (id)
  128. );
  129. /*==============================================================*/
  130. /* Table: goods_type */
  131. /*==============================================================*/
  132. create table tb_goods_type
  133. (
  134. id int not null,
  135. name varchar(20),
  136. primary key (id)
  137. );
  138. /*==============================================================*/
  139. /* Table: info */
  140. /*==============================================================*/
  141. create table tb_info
  142. (
  143. id int not null,
  144. title varchar(100),
  145. content varchar(1000),
  146. info_date date,
  147. picurl varchar(100),
  148. read int,
  149. primary key (id)
  150. );
  151. /*==============================================================*/
  152. /* Table: msg */
  153. /*==============================================================*/
  154. create table tb_msg
  155. (
  156. id int not null,
  157. life_id int,
  158. msg_name varchar(20),
  159. msg_content varchar(1000),
  160. primary key (id)
  161. );
  162. /*==============================================================*/
  163. /* Table: orders */
  164. /*==============================================================*/
  165. create table tb_orders
  166. (
  167. id int not null,
  168. app_user_id int,
  169. goods_id int,
  170. money float,
  171. status int,
  172. order_num varchar(10),
  173. primary key (id)
  174. );
  175. /*==============================================================*/
  176. /* Table: person_life个人生平 */
  177. /*==============================================================*/
  178. create table tb_person_life
  179. (
  180. id int not null,
  181. app_user_id int,
  182. stakeholder varchar(20),
  183. stakeholder_date date,
  184. life_title varchar(20),
  185. life_cotent varchar(500),
  186. primary key (id)
  187. );
  188. /*==============================================================*/
  189. /* Table: self_article */
  190. /*==============================================================*/
  191. create table tb_self_article
  192. (
  193. page_id int not null,
  194. app_user_ID int,
  195. content varchar(500),
  196. picurl1 varchar(50),
  197. picurl2 varchar(50),
  198. picurl3 varchar(50),
  199. picurl4 varchar(50),
  200. picurl5 varchar(50),
  201. picurl6 varchar(50),
  202. picurl7 varchar(50),
  203. picurl8 varchar(50),
  204. picurl9 varchar(50),
  205. page_date datetime,
  206. messageUser varchar(20),
  207. primary key (id)
  208. );
  209. /*==============================================================*/
  210. /* Table: tb_app_user */
  211. /*==============================================================*/
  212. create table tb_app_user
  213. (
  214. id int not null,
  215. family_id int(11),
  216. member_id int(11),
  217. template_id int,
  218. role varchar(20),
  219. nick_name varchar(100),
  220. head varchar(100),
  221. birthday date,
  222. reg_date date,
  223. qrcode varchar(100),
  224. gender int,
  225. mobile int,
  226. openid varchar(100),
  227. ver_code varchar(4),
  228. app_user_id varchar(10),
  229. name varchar(20),
  230. primary key (id)
  231. );
  232. /*==============================================================*/
  233. /* Table: tb_family */
  234. /*==============================================================*/
  235. create table tb_family
  236. (
  237. id int(11) not null auto_increment comment 'ID',
  238. name varchar(100) default NULL comment '姓名',
  239. address varchar(100) comment '头像',
  240. content varchar(11) comment '电话',
  241. pic_url varchar(100),
  242. creator varchar(100),
  243. creator_id int,
  244. city varchar(20),
  245. familyID varchar(20),
  246. primary key (id)
  247. );
  248. /*==============================================================*/
  249. /* Table: template */
  250. /*==============================================================*/
  251. create table tb_template
  252. (
  253. id int not null,
  254. title varchar(100),
  255. content text,
  256. primary key (id)
  257. );
  258. /*==============================================================*/
  259. /* Table: user_friend */
  260. /*==============================================================*/
  261. create table tb_friends
  262. (
  263. id int not null,
  264. app_user_id int not null,
  265. friends_id int,
  266. status int,
  267. primary key (id)
  268. );
  269. alter table apply add constraint FK_Reference_20 foreign key (family_id)
  270. references tb_family (family_id) on delete restrict on update restrict;
  271. alter table apply add constraint FK_Reference_21 foreign key (appuser_ID)
  272. references tb_app_user (appuser_ID) on delete restrict on update restrict;
  273. alter table comment add constraint FK_Reference_15 foreign key (page_id)
  274. references selfpage (page_id) on delete restrict on update restrict;
  275. alter table comment add constraint FK_Reference_16 foreign key (appuser_ID)
  276. references tb_app_user (appuser_ID) on delete restrict on update restrict;
  277. alter table family_album add constraint FK_Reference_7 foreign key (family_id)
  278. references tb_family (family_id) on delete restrict on update restrict;
  279. alter table family_events add constraint FK_Reference_4 foreign key (family_id)
  280. references tb_family (family_id) on delete restrict on update restrict;
  281. alter table family_garden add constraint FK_Reference_6 foreign key (family_id)
  282. references tb_family (family_id) on delete restrict on update restrict;
  283. alter table family_honor add constraint FK_Reference_5 foreign key (family_id)
  284. references tb_family (family_id) on delete restrict on update restrict;
  285. alter table family_photo add constraint FK_Reference_8 foreign key (family_id)
  286. references tb_family (family_id) on delete restrict on update restrict;
  287. alter table family_photo add constraint FK_Reference_9 foreign key (album_id)
  288. references family_album (album_id) on delete restrict on update restrict;
  289. alter table family_user add constraint FK_Reference_11 foreign key (family_id)
  290. references tb_family (family_id) on delete restrict on update restrict;
  291. alter table goods add constraint FK_Reference_24 foreign key (typeid)
  292. references goods_type (typeid) on delete restrict on update restrict;
  293. alter table msg add constraint FK_Reference_26 foreign key (life_id)
  294. references person_life (life_id) on delete restrict on update restrict;
  295. alter table orders add constraint FK_Reference_22 foreign key (appuser_ID)
  296. references tb_app_user (appuser_ID) on delete restrict on update restrict;
  297. alter table orders add constraint FK_Reference_23 foreign key (goods_id)
  298. references goods (goods_id) on delete restrict on update restrict;
  299. alter table person_life add constraint FK_Reference_18 foreign key (appuser_ID)
  300. references tb_app_user (appuser_ID) on delete restrict on update restrict;
  301. alter table selfpage add constraint FK_Reference_13 foreign key (appuser_ID)
  302. references tb_app_user (appuser_ID) on delete restrict on update restrict;
  303. alter table tb_app_user add constraint FK_Reference_10 foreign key (family_id)
  304. references tb_family (family_id) on delete restrict on update restrict;
  305. alter table tb_app_user add constraint FK_Reference_12 foreign key (user_id)
  306. references family_user (user_id) on delete restrict on update restrict;
  307. alter table tb_app_user add constraint FK_Reference_25 foreign key (template_id)
  308. references template (template_id) on delete restrict on update restrict;
  309. alter table user_friend add constraint FK_Reference_14 foreign key (appuser_ID)
  310. references tb_app_user (appuser_ID) on delete restrict on update restrict;