![img_2876f76a73e7ca18ee9b074196a50485.jpe](https://i-blog.csdnimg.cn/blog_migrate/f129dbc9d2d93796907eab5700534ad4.jpeg)
Association
相信有很多同学都有使用过Hibernate框架的开发经验,尽管现在开发人员对Hibernate的褒贬不一,我们暂且不谈这个话题。
图中的三个注解,正好解析了表与表之间的关联关系。我也就不这这方面进行过多的赘述了。所以...
今天的主题是:我想在不涉及表与表之间的关联关系的情况下对表进行关联。
换成对应的表的意思就是,不设外键,实现多对多关联。话不多说 先上一张我自己的设计手稿:
![img_9bebe716b78970bf19e1a1ee2c74ebb7.jpe](https://i-blog.csdnimg.cn/blog_migrate/a38451800ce4414adaa3101404cfcf00.jpeg)
手稿
数据库:(数据库的编码(utf8)与数据库引擎(InnonDB)已经设置好了)
CREATE table t_user(
uid int(10) NOT NULL PRIMARY KEY AUTO_INCREMENT,
username VARCHAR(100) not null,
password VARCHAR(100) not null,
createtime date not null
)default CHARSET=utf8;
-- 创建角色表
CREATE TABLE t_role(
rid int(10) not null PRIMARY KEY AUTO_INCREMENT,
rname VARCHAR(100) not null
)
-- 权限表db_auth
CREATE TABLE t_authority(
aid int(10) not null PRIMARY KEY AUTO_INCREMENT,
aname VARCHAR(100) not NULL,
url VARCHAR(100) not NULL
)
-- 意义上的中间表
CREATE TABLE t_role_authority(
rid int(10) not null,
aid int(10) not NULL,
KEY index_rid(rid),
KEY index_aid(aid)
)
CREATE TABLE t_user_role(
uid int(10) not null,
rid int(10) not null,
KEY index_uid(uid),
KEY index_rid(rid)
)
![img_a055ac723c5ef7aaa04d98f3866746ea.png](https://i-blog.csdnimg.cn/blog_migrate/e44639948bddc7c2b0130a5db8f02f5f.png)
没有任何关联关系的5张表
项目框架选型我用的是SpringBoot+MyBatis