数据库建模步骤

数据库建模步骤数据库建模工具 powerdesigne 确定产品需求建立对应概念模型 CDM 建立逻辑模型 LDM 建立物理模型 PDM 优化和确定最终物理模型 并导出 sql 脚本

数据库建模

工具:powerdesigner

  1. 确定产品需求
  2. 建立对应概念模型(CDM)
  3. 建立逻辑模型(LDM)
  4. 建立物理模型(PDM)
  5. 优化和确定最终物理模型,并导出sql脚本

示例

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

同理blog(文章)实体也可以如图建立在这里插入图片描述

注意,在建立概念模型是只关心实体本身的属性,暂且不要考虑与其他任何实体的联系

概念模型完成后,转换为逻辑模型,工具->Generate Logical Data Model

在这里插入图片描述
生成后如图

我们看到,多对多的关系PD自动生成了一个新实体,那么,针对网站的功能,我们还需要知道的一些信息比如,关注时间,评论的时间/内容等等,所以只需要在相应的关系实体上添加属性即可
如:评论时间,评论内容,关注时间等等

在这里插入图片描述

最后根据实际的业务需要调整一些属性,比如用户量大小等…

/*==============================================================*/ /* DBMS name: MySQL 5.0 */ /* Created on: 2019/8/19 11:39:57 */ /*==============================================================*/ drop table if exists blog; drop table if exists diss; drop table if exists user; drop table if exists 关注; drop table if exists 点赞; drop table if exists 评论; /*==============================================================*/ /* Table: blog */ /*==============================================================*/ create table blog ( blog_id bigint not null auto_increment, author_uid bigint, title varchar(100), content longtext, post_time datetime, total_zan int, total_diss int, total_read int, total_comment int, primary key (blog_id) ); /*==============================================================*/ /* Table: diss */ /*==============================================================*/ create table diss ( blog_id bigint not null, uid bigint not null, diss_time datetime, primary key (blog_id, uid) ); /*==============================================================*/ /* Table: user */ /*==============================================================*/ create table user ( uid bigint not null auto_increment, email varchar(255), phone_num varchar(20), login_name varchar(20), nick_name varchar(50), password varchar(255), reg_time datetime, head_photo varchar(500), fans_num int, follow_num int, primary key (uid) ); /*==============================================================*/ /* Table: 关注 */ /*==============================================================*/ create table 关注 ( user1_id bigint not null, user2_id bigint not null, follow_time datetime, primary key (user1_id, user2_id) ); /*==============================================================*/ /* Table: 点赞 */ /*==============================================================*/ create table 点赞 ( uid bigint not null, blog_id bigint not null, dz_time datetime, primary key (blog_id, uid) ); /*==============================================================*/ /* Table: 评论 */ /*==============================================================*/ create table 评论 ( cmt_id bigint not null auto_increment, uid bigint, blog_id bigint, cmt_time datetime, cmt_content text, primary key (cmt_id) ); /* alter table blog add constraint FK_发表 foreign key (author_uid) references user (uid) on delete restrict on update restrict; alter table diss add constraint FK_diss foreign key (blog_id) references blog (blog_id) on delete restrict on update restrict; alter table diss add constraint FK_diss2 foreign key (uid) references user (uid) on delete restrict on update restrict; alter table 关注 add constraint FK_关注 foreign key (user1_id) references user (uid) on delete restrict on update restrict; alter table 关注 add constraint FK_关注2 foreign key (user2_id) references user (uid) on delete restrict on update restrict; alter table 点赞 add constraint FK_点赞 foreign key (blog_id) references blog (blog_id) on delete restrict on update restrict; alter table 点赞 add constraint FK_点赞2 foreign key (uid) references user (uid) on delete restrict on update restrict; alter table 评论 add constraint FK_评论 foreign key (blog_id) references blog (blog_id) on delete restrict on update restrict; alter table 评论 add constraint FK_评论2 foreign key (uid) references user (uid) on delete restrict on update restrict; */ 
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/201976.html原文链接:https://javaforall.net

(0)
上一篇 2026年3月20日 上午8:10
下一篇 2026年3月20日 上午8:10


相关推荐

  • 【机器学习】F1分数(F1 Score)详解及tensorflow、numpy实现

    【机器学习】F1分数(F1 Score)详解及tensorflow、numpy实现F1-Score相关概念F1分数(F1Score),是统计学中用来衡量二分类(或多任务二分类)模型精确度的一种指标。它同时兼顾了分类模型的准确率和召回率。F1分数可以看作是模型准确率和召回率的一种加权平均,它的最大值是1,最小值是0。真实1真实0预测1TruePositive(TP)真阳性FalsePositive(FP)假阳性预测0Fals…

    2022年10月14日
    6
  • SVM支持向量机原理详解

    SVM支持向量机原理详解支持向量机 SVM SupportVecto 1 解决问题思路展开 要解决的问题 什么样的决策边界才是最好的 特征数据本身如果就很难分 该怎么办 计算负责度怎么样 能否实际应用 gt 目标 基于上述问题对 SVM 进行推导 1 1 决策边界右图中的决策边界更具容忍度 更加可靠 1 2 通过距离获得决策边界 求取点到面的距离 通过平面上两点可以得到平面的法向量 进而获得与法相量平行的单位方向向量 通过平面外一点 X 到平面上一点 x 的距离 D 在单位方向向量的投影可以求出距离 d

    2026年3月26日
    2
  • JS中动态删除对象中的某个属性[通俗易懂]

    letdog={name:”,age:""};console.log(dog);//{name:"",age:""}//删除当前dog对象中的age属性deletedog.age;console.log(do…

    2022年4月11日
    98
  • 存算一体——后摩尔时代的AI芯片架构[通俗易懂]

    存算一体——后摩尔时代的AI芯片架构[通俗易懂]存算一体,或存内计算,是指将传统冯诺依曼架构中以计算为中心的设计,转变为以数据存储为中心的设计,也就是利用存储器对数据进行运算,从而避免数据搬运产生的“存储墙”和“功耗墙”,极大提高数据的并行度和能量效率。这种架构特别适用于要求大算力、低功耗的终端设备,如可穿戴设备、移动设备、智能家居等。1.冯诺依曼架构的局限首先是性能。经典的冯诺依曼架构下,数据的存储和计算是分开的,处理器CPU存储器之间通过数据总线进行数据交换。但由于处理器和存储器的内部结构、工艺和封装不同,二者的性能也存在很大的差.

    2025年9月26日
    21
  • mac pycharm 设置_pycharm配置conda环境

    mac pycharm 设置_pycharm配置conda环境MAC环境下pycharm调试Python代码@TOC安装从官网下载,社区版和专业版。和安装其他软件一样,不详细讲。需要配置解释器1.如图,打开配置页面2.如图,右边的框是解释器的位置,这个可以设置。因为项目的不同,经常会有使用不同的库的情况,不同版本放在一起很容易出问题,因此为避免此类问题,往往把不同的库装在不同的虚拟环境中。这样对于依赖于同样的库的项目就可以通过一个虚拟环境运行。安装包的时候最好在终端安装,pycharm直接安装容易出错。下图右面的框就是解释器的位置。3.点击右面的

    2022年8月28日
    7
  • DeepSeek文献综述保姆级教程:从文献检索到成文全流程解析(附指令)

    DeepSeek文献综述保姆级教程:从文献检索到成文全流程解析(附指令)

    2026年3月16日
    1

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号