DBDesigner使用笔记
表格之间的关系
DD总共有 6个绘制表间关系的图标
从上到下依次是
Create new 1:n Non identifying Relation.Tool (Shift+R)
创建一个新的 1:n 非识别关系 的工具
Create new 1:1 Non identifying Relation.Tool (Shift+R)
创建一个新的 1:n 非识别关系 的工具
Create new n:m Relation (Click on one table,then on the other table to link these two table by a n:mrelation)
创建一个新的 n:m 关系
Create New 1:1 Generalisation Tool (A 1:1 relation which has its own graphical representation)
创建一个新的1:1 主从 的工具
Create New 1:1 Relation (Click on one table,then on the other table to link these two tables by a 1:1 relation )
创建一个新的1:1 关系的工具
Create New 1:n Relation (Click on one table,then on the other table to link these two tables by a 1:n relation )
创建一个新的1:n 关系的工具
1当我不给表建立主键的时候建立连接并不会影响表中字段名
但是当我给两个表都建立了主键的时候 使用创建新的1:n非识别关系工具连接两个表 DD为
我在从表中自动创建了一个指向主表的外键并使用 双色菱形表示了表间的1:n关系
同时还建立一个索引
2当创建1:1非识别关系的时候,DD为我在从表中自动创建了一个指向主表的外键并使用单色菱形表示
1:1关系,并在从表中创建了一个外键的索引
3 当创建n:m关系时 DD为我自动创建了一个关系表 这个关系表中含有指向主和从表的外键并且同时创建了索引
4 创建主从关系时 DD创建了和 1:1关系表类似的外键和索引 两者区别在于 关系种类是 派生对象
注意 箭头指向父亲表 子表为派生关系。
5 ,6 基本和1 和2 一样 只是 表间关系中不是非识别的关系
问题:
非识别是什么意思?
需要尝试一下非识别和没有非识别的区别。
总结:
被自动创建的外键都不能修改名字
表间关系被删除的时候关联外键也会被删除
主表中主键被更改的时候从表中外建会被删除但是如果再次创建关系就会从新建立,并且没有索引
注意菱形图示 黑色表示多条 白色表示一条 箭头指向表示父亲 灰线表示非识别 黑线相反
总结表间关系大类有两种 1:1 1:n
n:m 关系需要中间有 一个和两个表都是 1:n的关系表出现 估计
1)CakePHP中模型的表间关系如何和DD中的图示对应
CakePHP中的 hasAndBelongsToMany 关系也就是对这样表示的支持
hasOne 1:1 定义在主表中外键在从表中
belongsTo 1:1 定义在从表中外键在从表中
hasMany 1:n 定义在主表中外键在从表中
hasAndBelongsToMany ??
思考:
思考一下如何使用 DD来间关系型表。
尝试
1)尝试使用DD创建Mysql数据库中的关系表。
创建试验项目列车时刻表数据库
数据
列车名称 地点名称 到站时间 到站顺序 列车到站状态
数据实体
列车 地点
需要尝试一下非识别和没有非识别的区别。
尝试使用DD来创建CakePHP的模型
注意DD自动创建的主键是 "id表名" 格式
而CP则希望使用id来做每一个标的主键
Keyboard Shortcuts 快捷键
Navigation
| Key |
Function |
Info |
| F1 |
Help |
Calls the context sensitive Help. |
| Space |
Panning |
Holding down the Space-Key activates the panning function till the key is released. |
| Ctrl + Space |
Zoom in |
Holding down the Space-Key and the Ctrl-Key activates zoom-in function till the key is released. |
| Alt + Space |
Zoom out |
Holding down the Space-Key and the Alt-Key activates zoom-out function till the key is released. You can press Space + Ctrl + Alt, too. |
| Ctrl + Tab |
Switch Workmode |
Changes the Workmode from Design to Query and vice versa. |
| Ctrl + Shift + Tab |
Switch Palettes |
Press once to hide all palettes and again to show the palettes again. |
| Ctrl + Shift + 1..0 |
Store Position Markers |
Press Ctrl + Shift + 1,2, .. 0 to store a Position Marker. |
| Ctrl + 1..0 |
Recall Position Markers |
To recall a Position Marker press Ctrl + 1,2, .. 0. The position and zoom factor of the stored marker will be restored. |
Design Mode
| Key |
Function |
Info |
| Ctrl + Q |
Select Object(s) |
Activates the Pointer cursor. In Design-Mode objects can also be moved with this cursor. |
| Ctrl + W |
Move Object(s) |
Activates the Move cursor. Needed to move objects in Query-Mode. |
| Ctrl + E |
Scale Object |
Activates the Scale cursor. Only used for Regions and Image objects. |
 |
| Ctrl + T |
New Table |
Switches the mouse cursor to New Table Mode. |
| Ctrl + Shift + R |
New 1:n Relation |
Switches the mouse cursor to New 1:n Relation Mode. |
| Ctrl + R |
New 1:n Relation (non identifying) |
Switches the mouse cursor to New 1:n non-identifying Relation Mode. |
| Ctrl + Shift + Alt R |
New 1:1 Relation |
Switches the mouse cursor to New 1:1 Relation Mode. |
 |
| Ctrl + A |
Select All |
Selects all objects |
| Ctrl + Del |
Delete Selected |
Deletes all selected objects. |
| Ctrl + Shift + C |
Copy Highlighted Name |
Copies the Highlighted Name to the Clipboard. |
| Ctrl + Z |
Undo last Action |
Undos the last Action |
| Ctrl + Shift + Z |
Redo last Undo Action |
Redoes the last Undo Action |
 |
| Ctrl + O |
Open model |
Opens an existing model. |
| Ctrl + S |
Save model |
Saves the current model. The model can also be saved by clicking on the disk icon in the status bar. |
Query Mode
| Key |
Function |
Info |
| F9 |
Execute SQL statement |
Executes the current SQL statement. |
| Ctrl + Q |
Select Object(s) |
Activates the Pointer cursor. In Design-Mode objects can also be moved with this cursor. |
| Ctrl + S |
Add Column to SELECT |
Mouse Cursor to add Columns to the SELECT part of a SQL Command. |
| Ctrl + F |
Add Column to FROM |
Mouse Cursor to add Columns to the FROM part of a SQL Command. |
| Ctrl + W |
Add Column to WHERE |
Mouse Cursor to add Columns to the WHERE part of a SQL Command. |
| Ctrl + G |
Add Column to GROUP BY |
Mouse Cursor to add Columns to the GROUP BY part of a SQL Command. |
| Ctrl + H |
Add Column to HAVING |
Mouse Cursor to add Columns to the HAVING part of a SQL Command. |
| Ctrl + O |
Add Column to ORDER BY |
Mouse Cursor to add Columns to the ORDER BY part of a SQL Command. |
| Ctrl + E |
Add Column to SET |
Mouse Cursor to add Columns to the SET part of a SQL Command. |
 |
| Ctrl + Shift + A |
Copy SQL to Clipboard |
Copies the current SQL Command to the Clipboard, formated for ASP. |
| Ctrl + Shift + D |
Copy SQL to Clipboard |
Copies the current SQL Command to the Clipboard, formated for Delphi/Kylix. |
| Ctrl + Shift + P |
Copy SQL to Clipboard |
Copies the current SQL Command to the Clipboard, formated for PHP. |