简体   繁体   English

对象关系类图

[英]Object Relation Class Diagram

I am designing a Object Relational Database and here is my Class Diagram: 我正在设计一个对象关系数据库,这是我的类图:

http://canning.co.nz/AdvancedDatabase/Class_Diagram.png http://canning.co.nz/AdvancedDatabase/Class_Diagram.png

My Computer Class has a 1-1 relationship with the CurrentUser Class. 我的计算机类与CurrentUser类具有1-1关系。 When creating the Object in code, the Computer Class has a CurrentUser Object as an attribute (CurrentUser_objtyp). 在代码中创建对象时,计算机类将CurrentUser对象作为属性(CurrentUser_objtyp)。

Here is the code: 这是代码:

create type Computer_objtyp as Object (
CompNo          Number,
CompName    Varchar2(20),
CompOS      Varchar2(20),
CompProcessor   Varchar2(20),
CompRAM     Varchar2(20),
CurrentUser_obj     CurrentUser_objtyp,
HardDriveList_var   HardDriveList_Vartyp,
member function getCompName return varchar2)
/

My question is this: 我的问题是这样的:

As the Computer Class has this attribute, does the Computer Class need the attribute listed with the other attributes (CompNo, CompName, CompOS, CompProcessor, CompRAM), or is the relationship link to the CurrentUser Class sufficient? 由于计算机类具有此属性,因此计算机类是否需要与其他属性(CompNo,CompName,CompOS,CompProcessor,CompRAM)一起列出的属性,还是与CurrentUser类的关系链接足够?

It all depends on the exact definitions of computer and currentUser. 这完全取决于计算机和currentUser的确切定义。 A few examples: 一些例子:

If you perceive a computer as the machine, then does it have no current user, because it needs no user at all. 如果您将计算机视为计算机,那么它是否没有当前用户,因为它根本不需要用户。 Users belong to the OS. 用户属于操作系统。

If you see the current user as the person who has hired computer time on this computer, then is it important. 如果您看到当前用户是在这台计算机上租用计算机时间的人,那么这很重要。

If you see the current user as the current owner of the computer, then might it be otherwise and could the computer be a feature belonging to the user. 如果您将当前用户视为计算机的当前所有者,则可能不是这样,并且该计算机可能是属于该用户的功能。

If the current user is an employee of a company and leasing the computer for his work, then is it important to have a link from the computer to the combination company/user, hence could you have a reference to a contract. 如果当前用户是公司的雇员并且正在出租计算机以供其工作,那么从计算机到公司/用户组合的链接很重要,因此您可以参考合同。

You have used a compositional relationship to describe the relationship between the computer and the user. 您已经使用组成关系来描述计算机与用户之间的关系。 That implies that a computer has a currentuser and that the life span of the current user depends on the life span of the computer. 这意味着计算机具有当前用户,并且当前用户的寿命取决于计算机的寿命。 Then should the current user directly or indirectly be part of the list of variables of the computer. 然后,当前用户应直接或间接成为计算机变量列表的一部分。 On the ohter hand have you also a compositional relationship between a peripherical device and the computer. 另一方面,您还需要外围设备和计算机之间的组成关系。 That is hard to understand. 这很难理解。 An association is the most likely relationship between a peripherical device and a computer. 关联是外围设备和计算机之间最可能的关系。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM