如何使用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 ...
随机推荐
- odoo之model参数属性1
1.基础文件及目录结构 在认识odoo ORM框架前,先介绍一下odoo中模块目录结构. data:存放模块预制数据 i18n:存放国际化文件 models:存放模型等py代码 security: ...
- centos6.7环境下kvm虚拟机之virt-install和virsh及virt-manager工具的使用
virt-install工具的使用: virt-install是一个命令行工具,它能够为KVM.Xen或其它支持libvrit API的hypervisor创建虚拟机并完成GuestOS安装:此外,它 ...
- http响应头设置
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletExcep ...
- CentOS----kdump failed
启动提示:Starting kdump [failed] kdump 是一种先进的基于 kexec 的内核崩溃转储机制.当系统崩溃时,kdump 使用 kexec 启动到第二个内核.第二个内核通常叫做 ...
- 单例模式(懒汉、饿汉、同步锁、static、枚举)实现
使用前提: 需要频繁的进行创建和销毁的对象,创建对象时耗时过多或耗费资源过多 三要素: 1.构造方法私有化: 2.实例化的变量引用私有化: 3.获取实例的方法共有. 1.饿汉式单例 弊端:在类装载的时 ...
- Jmeter接口测试参数化实例图文示例
在实际测试中,不可能查询值测试一个输入值,还有其他测试数据,故引入参数化的概念,让一条用例循环执行,直到所有测试数据均测试完成,如下示例: Jmeter参数化有4种方法,本例仅介绍最普遍及简单的1个方 ...
- TestNG配置注解
以下是TestNG支持的注释列表: 注解 描述 @BeforeSuite 在该套件的所有测试都运行在注释的方法之前,仅运行一次. @AfterSuite 在该套件的所有测试都运行在注释方法之后,仅运行 ...
- PHP 获取时间
1.获取系统当前时间 echo "date('Y-m-d',time())"; 2.获取系统前一天时间 echo "date("Y-m-d",strt ...
- PHP数组序列化和反序列化
PHP序列化在我们实际项目运行过程中是一种非常常见的操作.比如当我们想要将数组值存储到数据库时,就可以对数组进行序列化操作,然后将序列化后的值存储到数据库中.其实PHP序列化数组就是将复杂的数组数据类 ...
- hdu4768二分答案
/* 如果发的传单是偶数,那么所有人都收到双数张. 仅考虑发了单数张传单,二分答案x,如果x左边是偶数,那么答案在右侧,如果x左边是奇数,那么答案在左侧 */ #include<iostream ...