context Country
inv: self.partOfPersonCode.size()=2context Employee
inv: self.age=Date::now - self.birthday
Employee
firstName : StringlastName : String
address[0..1] : AddresscountryCode{R1} : String
personalCode{I1}{EU1} : StringpassportNo[0..1]{D1} : String
socialSecurityNo[0..1]{D1} : Stringsex : Sex
birthday : Date/age : Integer
<<enumeration>>
Sex
MF
<<DataType>>
AddressStreet : StringCity : StringZipCode : String
Figure 4. Example of notation of integrity constraints on attributes in UML class diagram
Every object must have one primary identifier, for alternative identification identifier constraint is used. The object may have several identifiers; each of them may consist of several identifying attributes, and identifying attribute may be part of more than one identifier. In UML class diagram the tagged value {In} is used for every identifying attribute (group of attri-butes) to denote an identifier. For example class Emp-loyee besides primary identifier has and identifying attribute personalCode (Figure 4). For alternative identifier constraint, OCL expression is the same as for primary identifier because these constraints have the same meaning but different purpose.
Referential constraint on attribute (group of attri-butes) identifies that attribute is the identifier of one or more associated objects 0, 0. 0 suggested using the tag for the referential attribute constraint with {Rn}, where Rn is the name of the corresponding
association. For example, the attribute Employ-ee.countryCode refers to the primary identifier of Country through the association named R1 (Figure 4). OCL expression for referential constraint of object type A that has mandatory relationship with object type B (and referential attribute c1 referencing to primary identifier of B – d1):
context A
inv: self.B Æ exists(b:B|b.A=self and self.c1=b.d1 and b.d1.oclIsKindOf (PrimaryIdentifier))
Mandatory constraint on attribute is used to indi-cate that attribute must have value 0, 0, 0. In UML all class attributes are mandatory by default. Appending [0..1] after attribute name means that attribute is optional 0. In Figure 4, class Employee has optional attributes: passportNo, socialSecurityNo and Address, the rest attributes are mandatory. Mandatory constraint
Abstract. Integrity constraints are incident part of conceptual models, including part of semantics of problem domain. Analysis of the most important methods of conceptual modelling has revealed that none of them analyze the complete set of integrity const
Representation of Integrity Constraints in Conceptual Models
on attribute can be expressed graphically therefore we don’t need OCL expressions.
Disjunctive mandatory constraint indicates that disjunction of class attributes is mandatory. It means that in all allowable states of information system at least one of class attributes constrained by disjunctive mandatory constraint must have value 0, 0, 0. UML does not have graphical notation for disjunctive mandatory constraint so this kind of constraint needs to be expressed textually in an attached note 0, 0 or in OCL. OCL expression for disjunctive mandatory constraint on attributes a1,…,ai,…,an of object type A:
context A
inv:not(self.a1 isUndefined()) … or not(self.ai isUndefined()… or not(self.an isUndefined())
Employee. In general case, external uniqueness constraint on attribute c1 of object A and attribute c2 of related object B:
context A
inv: self Æ exists (a1,a2:A|
a1.B.c1=a2.B.c1 and a1.c2=a2.c2 and c1=c2 and c1.oclIsKindOf
(ExternalUniqueness) implies a1=a2)
In order to capture this constraint graphically we need to extend UML notation adding tagged value like {Dn} where in the case of class having several attri-bute groups constrained with disjunctive mandatory constraint, index n indicates the number of attribute group constrained by this type of constraint. For example, in Figure 4 class Employee has one attribute group {passportNo and socialSecurityNo} constrained by disjunctive mandatory constraint (the number equal to one may be omitted).
Internal uniqueness constraint indicates that the value of one or more attributes of any two instances of class is different from the set of all other instances of that class 0, 0, 0. UML does not have special graphical notation for uniqueness constraint. Hainaut 0 suggested to bold unique attributes, but such solution is not appropriate for unique attribute groups, because one class could have several groups. Halpin 0 has introduced {Un} notation to append as textual constraints to the constrained attributes. The index indicates a group of attributes having unique values for all instances of class. Figure 4 illustrates example of unique attribute for class Country. OCL expression for uniqueness constraint on attributes c1,…,cn of object type A:
context A
inv: self Æ exists
百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说医药卫生Data Mining and Semantic Web services(4)在线全文阅读。
相关推荐: