如何使用PowerDesigner设计数据库关系模式












/*==============================================================*/
/* DBMS name: Microsoft SQL Server 2012 */
/* Created on: 2018/11/25 13:42:24 */
/*==============================================================*/
use "zuoye"
from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
where r.fkeyid = object_id('借书者') and o.name = 'FK_借书者_FK_2_借书记录')
alter table 借书者
drop constraint FK_借书者_FK_2_借书记录
go
from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
where r.fkeyid = object_id('图书') and o.name = 'FK_图书_FK_1_借书记录')
alter table 图书
drop constraint FK_图书_FK_1_借书记录
go
from sysobjects
where id = object_id('借书者')
and type = 'U')
drop table 借书者
go
from sysobjects
where id = object_id('借书记录')
and type = 'U')
drop table 借书记录
go
from sysobjects
where id = object_id('图书')
and type = 'U')
drop table 图书
go
/*==============================================================*/
/* Table: 借书者 */
/*==============================================================*/
create table 借书者 (
借书者编号 int not null,
图书编号 int null,
借书者姓名 ) not null,
借书数量 int null,
constraint PK_借书者 primary key (借书者编号)
)
go
/*==============================================================*/
/* Table: 借书记录 */
/*==============================================================*/
create table 借书记录 (
图书编号 int not null,
借书者编号 int null,
期望归还时间 datetime null,
借书时间 datetime null,
还书时间 datetime null,
constraint PK_借书记录 primary key (图书编号)
)
go
/*==============================================================*/
/* Table: 图书 */
/*==============================================================*/
create table 图书 (
图书编号 int not null,
书名 ) null,
作者 ) null,
出版社 ) null,
出版日期 datetime null,
库存 int null,
价格 money null,
constraint PK_图书 primary key (图书编号)
)
go
alter table 借书者
add constraint FK_借书者_FK_2_借书记录 foreign key (图书编号)
references 借书记录 (图书编号)
go
alter table 图书
add constraint FK_图书_FK_1_借书记录 foreign key (图书编号)
references 借书记录 (图书编号)
go
/*==============================================================*/
/* DBMS name: Microsoft SQL Server 2012 */
/* Created on: 2018/11/26 7:17:16 */
/*==============================================================*/
from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
where r.fkeyid = object_id('交易记录') and o.name = 'FK_交易记录_REFERENCE_商品')
alter table 交易记录
drop constraint FK_交易记录_REFERENCE_商品
go
from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
where r.fkeyid = object_id('购物者') and o.name = 'FK_购物者_REFERENCE_交易记录')
alter table 购物者
drop constraint FK_购物者_REFERENCE_交易记录
go
from sysobjects
where id = object_id('交易记录')
and type = 'U')
drop table 交易记录
go
from sysobjects
where id = object_id('商品')
and type = 'U')
drop table 商品
go
from sysobjects
where id = object_id('购物者')
and type = 'U')
drop table 购物者
go
/*==============================================================*/
/* Table: 交易记录 */
/*==============================================================*/
create table 交易记录 (
交易记录ID int not null,
交易物品ID ) not null,
交易物品数量 int not null,
交易商家ID ) not null,
constraint PK_交易记录 primary key (交易记录ID)
)
go
/*==============================================================*/
/* Table: 商品 */
/*==============================================================*/
create table 商品 (
交易物品ID ) not null,
交易物品名称 ) not null,
库存 int not null,
单价 money not null,
constraint PK_商品 primary key (交易物品ID)
)
go
/*==============================================================*/
/* Table: 购物者 */
/*==============================================================*/
create table 购物者 (
账户ID ) not null,
用户名 ) not null,
交易记录ID int not null,
交易时间 datetime not null,
constraint PK_购物者 primary key (账户ID)
)
go
alter table 交易记录
add constraint FK_交易记录_REFERENCE_商品 foreign key (交易物品ID)
references 商品 (交易物品ID)
go
alter table 购物者
add constraint FK_购物者_REFERENCE_交易记录 foreign key (交易记录ID)
references 交易记录 (交易记录ID)
go
如何使用PowerDesigner设计数据库关系模式的更多相关文章
- 采用PowerDesigner 设计数据库
PowerDesigner设计数据库的教程网上都有,最好的是我一位同学写的,地址: 点击这里 我的大致流程如下: 首先要以管理员的身份打开PowerDesigner,如果没这么做,将导致后面无法创建S ...
- PowerDesigner 设计数据库中常用脚本
PowerDesigner 设计数据库中常用脚本 数据库设计 物理模型设置 Name转Comment脚本 '********************************************** ...
- 新手学习数据库(一)用Powerdesigner设计数据库
说明: 一.学会用开发语言进行数据库编程,其关键是在于学会sql语言,开发语言只不过给程序员提供了一个操作数据库的接口罢了. 二. 本人也是初学者,采用的数据库设计软件是powerdesigner.利 ...
- ER 和 数据库关系模式
http://lianghuanyue123.blog.163.com/blog/static/130423244201162011850600/ 我们眼下所接触的数据库基本上是关系数据库,关系数据库 ...
- 使用POWERDESIGNER设计数据库的20条技巧(转)
1.PowerDesigner使用MySQL的auto_increment ◇问题描述: PD怎样能使主键id使用MySQL的auto_increment呢? ◇解决方法: 打开table prope ...
- 利用PowerDesigner设计数据库
PowerDesigner非常强大, 可以利用它完成数据库的设计. 1.下载地址:http://pan.baidu.com/s/1DsLrg 2.表设计: 建立概念数据模型(Conceptual Da ...
- 使用PowerDesigner设计数据库
1.快捷键CTRL+N 创建 New Model 选择如下图,并设置 Model name 单击OK 2.使用工具添加实体 双击Entity_1,填上如下图信息 切换选项卡,添加属性信息 其中 M ...
- SQL2008R2 不支持用该后端版本设计数据库关系图或表
向下不兼容. 要么安装SQL2012,要么把SQL2012数据库通过脚本转成2008
- PowerDesigner设计Name和Comment 替换
这两天在用powerdesigner设计数据库.一直以为name就是注释名字来着.后来生成sql语句 怎么就没有注释信息那. 后来看了半天才知道自己范2了. 通过各种信息查找.大多都是改databas ...
随机推荐
- WebRTC服务器——Licode 环境搭建
WebRTC服务器--Licode 环境搭建 系统配置 阿里云服务器 Ubuntu 14.04.5 LTS Docker 环境搭建 在一台空的机器上搭建docker环境,先要安装docker,执行下面 ...
- mybatis二级缓存应用及与ehcache整合
mybaits的二级缓存是mapper范围级别,除了在SqlMapConfig.xml设置二级缓存的总开关,还要在具体的mapper.xml中开启二级缓存. 1.开启mybatis的二级缓存 在核心配 ...
- MyEclipse中如何配置默认jsp为UTF-8格式
- Android开发之多Fragment切换优化
问题分析 一直在简书里看别人的技术贴,今天我也来写点自己的心得!最近在写一个项目用到大量的Fragment后的总结! 我想刚刚接触安卓的同学或许会这么写: FragmentManager fragme ...
- Js中带有小数的值相加产生的问题
项目中遇到的问题,0.1+0.2为0.30000000000000004,与想象中不一样, 解决办法: function addNum (num1, num2) { var sq1,sq2,m; tr ...
- Laravel Cache 的缓存文件在到期后是否会自动删除
验证缓存文件是否会自动删除的目的是,防止产生大量的缓存文件,占满磁盘.因为,我最近越来越多的使用 cache 来缓存各类 token. 使用的是 file 作为 CACHE_DRIVER CACHE_ ...
- hdu5289 ST表+二分
用裸的St表+暴力枚举查询时稳TLE的,可以枚举每个区间的起点+二分满足条件的区间右端,这样复杂度是O(nlogn) #include<iostream> #include<cstr ...
- 集合Arraylist的方法的使用和打印
package chapter090; import java.util.ArrayList;import java.util.List; public class TestList01 { publ ...
- 使用RabbitMQ实现延迟任务
场景一:物联网系统经常会遇到向终端下发命令,如果命令一段时间没有应答,就需要设置成超时. 场景二:订单下单之后30分钟后,如果用户没有付钱,则系统自动取消订单. 上述类似的需求是我们经常会遇见的问题. ...
- 删除一个存在的RabbitMQ队列
import sys # pip install kafka-python sys.path.append("/usr/local/software/ELK") from Util ...