entity and attribute in e-r model - attributes

Simple question:
I have e-r model. I have entity Car. Car can be either BMW or Opel. If it is BMW then it must have color. If it is a Opel then it must have attribute - amount of passangers.
How can it be displayed in e-r model? I mean IF clase.
Thanks!

In an ER model this is normally represented as a sub-type.
http://en.wikipedia.org/wiki/Enhanced_entity%E2%80%93relationship_model
Sub-types can be exclusive or non-exclusive, depending on whether more than one of the sub-types should apply simultaneously. For example, a Bank Account entity might have sub-types for Current Account or Savings Account. These would be exclusive sub-types since a bank account cannot be both. Depending on the type of the account, one of the sub-types is used to "extend" the main entity. On the other hand an entity named Sportsman could have sub-types Golfer and Footballer. The Sportsman entity would contain common information such as name, and the sub-types would contain only the additional attributes applicable to the sport (e.g. Golf Handicap). Records only exist in the sub-type entities when the main entity is of the applicable type. These would be non-exclusive sub-types since it is quite possible that someone plays both golf and football.
In IDEF1X notation it is represented like this

Related

I don't understand association class - UML class diagram

I don't yet completely seem to understand how association class works, why the role class attributes can't just be inside the person class?
as example:
Person
name
position
description
Suppose we live in a world where a person must have a role in a company in order to live and a company may exist without persons at all.
If that is all you want to know about the relationship between persons and companies, i.e. only the fact that there are such relationships and nothing more, you model it like this:
Then if you want in addition to capture position and description of the Person's role you use so called AssociationClass (Role in our case):
Each instance of Role has four properties (both an attribute and an end of an association are Properties in UML):
Company
Person
position
description
For example, suppose a person named Scott Tiger has roles in two companies - Food Inc and Water Ltd and each company knows that Scott Tiger has role in it. Then there will be two instances of Role (shown as tuples):
(Food Inc., Scott Tigger, eater, eats here)
(Water Inc., Scott Tigger, drinker, drinks here)
Now, returning to you question, it should be clear that an instance of Person with name, position, description attributes actually "lacks" Company and if you "add" an Company you will get Role, not Person!
So what you proposed in the end of your question is a valid design, if you model Company and Role and a person is just an attribute of Role:
It reads as follows: each instance of Company has zero or more Roles and each instance of Role has only one Company. Both ends of the association are navigable, i.e. Role knows its Company and Company knows its Roles.
UML Specification in clause 9.5.3 gives you the following advice:
A Property may represent an attribute of a Classifier, a memberEnd of an Association, or in some cases both simultaneously.
A useful convention for general modeling scenarios is that a Property whose type is a kind of Class is an Association
end, while a property whose type is a kind of DataType is not. This convention is not enforced by UML.
why the role class attributes can't just be inside the person class?
notice the multiplicity 1..*, if you move position and description into Person you have to manage a collection of them and to associate each to the corresponding Company.
[from your remark]
For a given Person the position and description depends on each associated Compagny, so it is not possible to have the fields you propose except if position and description are both a collection, and to have a way/rule to know which entry in position and description correspond to the right Compagny.
Moving also these information in Person you remove the symmetry, it is also possible to move these information in Compagny, with the same remarks as for Person
An association class is both a class and a relation, when you implement it in a language like C++ or Java etc of course that concept does not exist, so one way is as you propose to move the fields in one of the two classes, or to create a third class having the expected fields more one to a Person and one to Company.
The advantage of the third class is to have all the associated information grouped having the equivalent of :
As example an object diagram can be :
Without the third class you need to know how to associate all the separated information, for instance having all in Person using three vectors to memorize the company and position and description you may use the same index value for all, but this is less clear and when you add/remove a Company for a Person you have to update all these vectors.

How to express counter type entity with UML?

I would need some help with a problem we're facing in a company, trying to model every process and entity.
So far we have used an enhanced conceptual model with entities and attributes with relationships but there are some objects that don't exactly match a dimension or a fact table, and this is an entity that can be called "Shops with sales over X units". There is the entity "sales" and "shop" obviously, that would have it's representation in UML as independent entities and represent at the lower level, each sale and shop.
What we need to indicate in UML is an entity that stores the counter of shops with sales over X units, so this has some kind of behavior or conditions.
If we consider the entity, it would need date-from and date-to, and the value (counter), and creating a connection with the shop entity seems enough, but we miss the behavior that expresses "more than x sales". So the behavior could be for example: Go to the shop entity, take the 1st element and navigate to the sales entity, calculating the sales. If it's over X, then value+1, and so on.
I made a simple version of the problem. Blue boxes represent the entities already created, and the orange one is the counter that should count the shops with some constraints.
Is there any way of using some kind of UML diagram that can help us to solve this problem?
You could realize that with an association class:
ShopSales relates Shop and Sales so you can store the number of sales along with other things you might need in that conjunction. The ShopSalesStats could give you the shops by number of sales.
Another (of many) way(s) would be to just hold the count as public property of Shop and let ShopSalesStates handle the counts on all associated Shops.

Class associations and multiplicity - UML 2.0 - object oriented

I am learning UML and have a practice question I am working on for class diagrams.
I've put together a first version of the diagram but i'm confused about part e. This is the practice question:
and this is what I have so far:
Where it says 'Each customer can store a number of debit/credit cards used for payments' does it mean that the customer then has an association with the debit and credit card subclasses? or is the credit card type stored in the customer class as an attribute?
The proposal of Thomas Kilian is not yet the complete solution. You should rename "CreditCard" to "PaymentCard" and make it a union type by partitioning it into the two disjoint subclasses "CreditCard" and "DebitCard". Give the Customer-PaymentCard association a 1-* multiplicity. Then add a many-to-one association between Payment and PaymentCard.
It's just that you need an attribute inside Customer for a number of credit card numbers. A card number is less than 2^43. So you can take a (64 bit) integer. Or use a String for that.
The dot-notation says that card is an attribute inside Customer and since it has a multiplicity not equal one it's an array (or a collection). Vice versa the CreditCard has a unique owner.

How to represent a descriptive attribute of a relationship in ERwin modeler?

In the modeler, relationship is represented by a line between two entities. It would be no problem if the relationship has no descriptive attributes. But if it has, how can I represent the descriptive attributes? For example, the relationship set advisor, between entity set student and entity set instructor, has a descriptive attribute date to record the data an instructor become the advisor of a student. How I can represent the attribute?
A relationship can be viewed as an assertion. I believe the assertion that represents the relationship here is: An instructor acts as an adviser to a student.
There are 3 nouns in the assertion which implies that there are 3 entities involved in the relation:
Instructor
Student
Adviser
There are 2 fundamental entities (Student and Instructor) upon which the associative entity (Adviser) depends. In other words, an instance of Adviser needs an instance of Instructor and Student to make sense.
The simple answer is to simply make the date an attribute of Adviser. Unfortunately, life is often not that simple.
Are are the following two assertions valid?:
Jim acts as an adviser to Jane from 01/01/2009 to 06/30/2009.
Jim acts as an adviser to Jane from 01/01/2011 to 06/30/2011.
If so, then a new entity (Advisory Period) is required. An Advisory Period the amount of time during which an instructor acts as an adviser to a student.
The Advisory Period entity would be dependent on Adviser (necessitating a dependent 1:m relation between Adviser and Advisory Period) and the start and end dates of the period would be recorded as non-key attributes of the Advisory Period.
Hope this helps

How to represent the instantiation of a type/class to represent a particular entity

Here is an example:
I have the generic type called "Account". I wish to use this account to represent multiple business entities:
1. Customer
2. Client
3. Company
I wish to use the Account type for the above 3 entities (as they are all types of accounts in my system - where the type is an attribute of the Account). How would I represent this relationship?
The only relationship you've described is that 'type' is an attribute of the Account. If Customer, Client, or Company are not strong enough entities on their own to deserve their own box on the Domain diagram, then you are done. In that case, you can include a note box associated with Account and say "Examples of values for the Type field: Customer, Client, Company, etc.".
If that is not strong enough, you may think about creating an AccountType class which have as sub-classes Customer, Client, Company. In that case you would draw an association from Account to AccountType, which replaces the need for the 'Type" attribute.
When I get a chance, I'll draw examples and post links to them.
You can model the template class (Account) and then bind it to create three different classes using the association link and the bind stereotype on the link, as you can see here, under the "Class Template" title.
I believe the diagram I would use to communicate these relationships between diffrent objects is the "Collaboration" diagram, as what the relationships show is how the different objects are instantiated (Account is instantiated as Customer, Client and Company) and how they (the instances) would interact with each other

Resources