[Switch] UML modeling data modeling (Data Model Diagram)

  An introduction to the database model

2. Data Modeling Elements

1. Table ( Table )

2. Table Index _

3. Table Trigger _

4. Table Constraint _

5. View ( View )

6. Stored Procedure _

3. Data Modeling Examples

4. Summary

 

An introduction to data modeling

Data modeling can not only model the attributes of objects (such as ER diagram), but also model the behavior of data (such as trigger Trigger , stored procedure Stored Procedure ) . When designing a database, the following concepts are designed:

Schema , Primary key  Primary , Foreign key Foreign key , Relationship , Constraint constraint , Index Index , Trigger Trigger , Stored Procedure Stored Procedure , View View .        

2. Data Modeling Elements

1. Table ( Table )

A table is the most basic model structure of a relational database. As shown below

 

 

Primary key of the table: InventoryID

The foreign key of the table: WarehouseId , the primary key associated to the table Warehouse

You can set the database type of Table , as shown below

 

 

You can also set the tablespace, as shown below

 

 

 

2. Table Index _

Refers to the logical order of creating records according to a key field or expression in the table file. It is a list of a series of record numbers that provides quick access to the data. Indexes do not change the physical order of records in the table

3. Table Trigger _

当对某一表进行诸如UPDATE INSERT DELETE 这些操作时,SQL Server 就会自动执行触发器所定义的SQL 语句,从而确保对数据的处理必须符合由这些SQL 语句所定义的规则。 
    
触发器的主要作用就是其能够实现由主键和外键所不能保证的复杂的参照完整性和数据的一致性

4、表约束(Table Constraint

通过对列的约束,保证数据的有效性。

 

 

 

5、视图(View

视图是从一个或多个表或视图中导出的表,其结构和数据是建立在对表的查询基础上的。如下图

 

 

6、存储过程(Stored Procedure

将常用的或很复杂的工作,预先用SQL语句写好并用一个指定的名称存储起来, 那么以后要叫数据库提供与已定义好的存储过程的功能相同的服务时,只需调用execute,即可自动完成命令。

 

 

 

 

三、数据建模实例

 

 

 

1、表有仓库Warehouse、库存Inventory以及书Book

2、主键分别为WarehouseIDInventoryID,ISBN

3、外键,表Iinventory的外键是WarehouseID,同时也是Warehouse的主键

   Book的外键是InventoryID,同时也是Inventory的主键

4、关系,表Warehouse与表Inventory是一对多的关系

   Inventory与表Book是一对多的关系。

四、总结

本文主要介绍了数据库建模所涉及建模元素,主要包括模式 Schema、主键 Primary、外键 Foreign key、关系 Relationship、约束 constraint、索引Index、触发器 Trigger、存储过程 Stored Procedure、视图 View等等,并配以实例加以说明。

本篇文章比较简单,也是《UML建模-面向对象技术》系列文章的最后一篇建模文章。对此系列文章,后期抽个时间再写个总结,使的UML建模系列文章知识性更连贯,内容更加清晰。

 

 

 

版权

作者:灵动生活

出处:http://www.cnblogs.com/ywqu

如果你认为此文章有用,请点击底端的【推荐】让其他人也了解此文章,

你也可以加我的新浪微博,以便实时了解我的动态:http://weibo.com/ywqu

WOWO英语(英语培训学校):http://www.wowomandarin.cn   上海电子商务解决方案:http://www.hello36.com 
上海闪酷系列解决方案: 
电子商务解决方案   移动电商APP软件   培训学校管理系统   购物分享社区系统   移动开发解决方案   在线问卷调查系统   

本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326685825&siteId=291194637