I have a scenario about a customer purchasing a stock from a company and calculating branch sales. So I made a class diagram of customer, purchase and branch sales but I am not sure what to put in the branch sales entity as this branch sales should indicate total sales done for each branch.
Here my diagram:
Should the branch sales includes purch_totalprice, purch_stock, and purch_stockquantity too, like in purchase entity?
The diagram looks more like an entity/relationship diagram for database tables than like an UML class diagram:
In an UML class diagram, you would not use a dotted line to separate the unique identifier form the other properties, but you would use a separator to show operations (i.e. methods or functions).
In an ER diagram, this practice is less unusual althoug not common either.
This being said, whatever the modelling language, this diagram:
doesn't show what the Customer is purchasing. stock is too ambiguous: is it a material that you have in an inventory? Is this a stock-exchange stock (a share in a company)? Whatever the answer, it would be nice to show this as an own class/entity (I'll use Product hereafter).
doesn't show any class/entity that is identified with a branch_id. I'd suggest to add an entity called Branch
doesn't show the associations/relations. You should have at least Customer--Purchase, Purchase--Product, and Purchase---Branch, nor their multiplicity/cardinality.
If you have all these information in your model, the "branch sales" are in fact a data extract of Purchase and not a distinct entity: the purchase of the customer being the sales for the branch. For your diagram:
If you're on a class model, you'd add a getSalesDetails() function: this function would return the list of all the relevant Purchase objects for that branch. You could also add a getTotalSales() that would make do a total of the relevant sales. Perhap's taking into account a date of the purchase?
If you're in an ER model, you would know how to find this data thanks to the association between branch and purchase (you can make it clear by labelling the relation Branch--Purchase as makes sales. But you could also show a separate table with the relevant data duplicated, if you want to document your physical model and intend to implement this in your database (either with redundant data ,not recommended, or with a view)
Last important remark regarding classes:
If your diagram should be an UML class diagram, but you want to show the details of your database model, you may put «table» above every entity.
But if you do not intend to document classes, i.e. the classes would stay without operations (i.e. class behavior) there's really something missing - it's like an anemic domain model (not forbident, but far from ideal).
Related
Hi, I have recently started to learn system analysis and design and am having some trouble understanding domain model class diagram (DMCD) association class.
As per image, when drawing the DMCD, I'd like to understand if an association class is allowed to contain attributes of the classes it derives from. The Invoice needs to contain the attributes apptNo and svcName.
Association class inquiry image:
Do I include the attributes as shown in the image?
Or do I assume that the Invoice would already have these attributes because it is derived from Appointment and Service and that it is not necessary to include them as they can be referred back to the keys apptNo and svcID?
I am confused about the concept. How should I present the association class?
Can someone please provide some guidance?
Thank you.
As already pointed out by Geert Bellekens in his comment above, you don't repeat any of the attributes of the classes involved in an association class in the association class. You only include attributes that specifically characterize the links classified by the association class.
In your example, you should only include attributes that are specific for Invoice links, such as invNo, invDate and totalPrice.
This rule holds independently of the kind of class diagram (domain/design/implementation model).
However, your model is only good for invoices refering to one appointment and one service. It does not account for invoices concerning one appointment, no matter how many services it includes. In a model for this business logic, Invoice would no longer be an association class, but an ordinary class associated with Appointment. This would allow it to access each service included in an appointment and turn it into an invoice line.
To make it short:
is (sort of; please read the comments below) an alternative notation for
which means that Class3 already has associations to both Class1 and Class2. So there's no point in adding attributes of the latter in the association class. If you're on a DB level you eventually introduce redundancy for performance reason at the cost of violating the principle of single source of truth. But that's another story.
It depends.
A domain model class diagram models the concepts found in the domain, i.e. the part of the real world relevant for your project. In the classes, you only include attributes that are indicated by domain experts or by other sources describing the domain.
I will assume that a domain expert knows what an appointment number and a service name are. If these were just technical data, they should not be attributes of Appointment and Service in the first place. To determine whether these attributes should also be included in Invoice, you need to ask domain experts what they think. Does an invoice always include an appointment number and a service name? Only if the domain expert says "Yes", I would model them as attributes of Invoice.
(To double check, you could ask "Is it also valid to say that the appointment number is not part of the invoice, but that the invoice is somehow associated with an appointment having a particular appointment number?")
Maybe the domain expert says an invoice does not contain the appointment number or the service name, because the corresponding Appointment and Service are always associated to the Invoice as attachments or hyperlinks or otherwise. In that case, the fact that Invoice is an association class on the association between Appointment and Service is enough. You don't have to include attributes of these classes in Invoice. These will probably be added later, when the domain model class diagram is turned into a system model class diagram or database model class diagram.
The diagram below is based on these facts:
A citizen may make a claim / reclamation on pollutions
An administrator will send the reclamation by type to the appropriate agency / organization, and it will respond with a diagnostic report
This report will be sent by the administrator, to another organization, for the estimation of the solution (costs, etc.).
My problem is to how can I show that Admin will send the claim to an agency? Do I have to make an association between Organization and Reclamation?
If your requirements include that the communication between the Admin and the Organization is to be documented, then you need to take care of this in your class diagram. And, in fact, you already have an item for this: the NotifyOrganization association class. Notice, however, that it's not a good idea to use the questionable UML concept of an association class, which does not have a clear semantics and is confusing. This seems to be confirmed by your flawed modeling of the multiplicities of the NotifyOrganization association, which must not be one-to-one (or 1 to 0..1), but rather many-to-many (* to *).
So, better replace the NotifyOrganization association class with an ordinary class (possibly with an improved name such as Notification) and attach it to Admin and Organization with two many-to-one associations such that each notification is linked to exactly one admin and one Organization.
Notice that a notification represents a (communication/message) event, so Notification represents an event type. It*s quite common in business information models to have both object types and event types, both as classes in a UML class diagram.
...how can I show that Admin will send the claim to an agency?
UML Class Diagram is not show-everything document. In order to document that admin will send claim to agency you can document it effectively using UML Sequence Diagram or some other behavior diagram
...do I have to make an association between Organization and Reclamation?
No, if the agency does not need to care about who exactly delivered the claim or what's the person's role (e.g. "admin"), then you don' have to add it to the class model (and show some association) at all
...diagram...based on these facts...
In order to describe the overall process in a one-page style picture, you (and your business partners) can find very useful the Business Process Model and Notation (BPMN) graphical language in addition to UML
If models in Master Data Services are representations of subject areas (such as customer, product, etc.), is it possible to have a domain-based attribute that uses a different model as it's source?
For example, if creating a customer model and defining an entity called Customers, this entity will have address information for the customer. City, State/Province, Country, etc.
But rather than creating an entity for CustomerCountry, can I use a Geography model that contains a Country entity and link to that? Then I can also use the Geography.Country entity for Vendors and Employees.
No, you cannot cross model boundaries - the primary reason is that a model is the unit of versioning. There are two workarounds:
Duplicate the entities in question - i.e. copy the geography entities into your customer model
Reference an entity by code - i.e. add a CITY_CODE to your customer entity
Neither of these are great options 1) is unwieldy and 2) doesn't maintain automatic integrity.
Personally I use option 2) where I can with some additional logic/business rules outside of MDS to ensure that codes match. This is easier with codes that are global and do not change such as country and city codes.
This seems quite old but this is now possible in 2016 and is accomplished though Entity Synch. The idea is you can synch your entity across models. There are two ways to run the synch, either on demand or automatically.
See https://learn.microsoft.com/en-us/sql/master-data-services/entity-sync-relationship-master-data-services for more details
I have a couple of Core Data entities... Student and Exam.
Now, the Exams is initially just one object per exam - Maths Exam 3, English Exam 2 etc.
There is a relationship between Students and Exams in my data model (a student can have several exams). But initially, the Exams are just floating free, and not attached to any students.
How would I make a copy of one of the exams and attach it to a student?
If I do something like:
[student addExamsObject:examObject];
...then I think it simply references the original exam to the student, rather than making a copy.
I need a copy because the Exam has a boolean 'hasTaken', which is YES when the student has taken the exam. But if I set that now, it will make it seem like all the students with that exam have taken it.
Clarification: I would rather not restructure my model. The data is taken from a couple of xml files, one each for Students and Exams, which are parsed into the Core Data store. For instance, an Exam object might look like this:
name:Maths 5
class-id:12
year-id:4
student-id:0
..with a Student object looking like
name: Dave
class-id:12
year=id:4
student-id:222
Various rules are meant to guide which exams get attached to which students... for instance if all the Exam's ids are 0 then all students take the exam. If class-id and year-id match, and student-id is 0, then the Exam gets added to students with the same class and year. If the student-ids match, then just that student takes the Exam. etc etc.
I cannot change the way the xml is outputted from the server.
Another issue is that Exam has too-many relationship to a Question entity... in other words, the questions in the Exam. And I have to store answers to the questions that each student gives in an exam.
Edit: I wish people would try to answer my question rather than tell me to restructure my whole program. There are reasons why the data model has been structured like it is.
Edit2: Maybe I will have restructure....
Exam shouldn't have a hasTaken property. Think about it in the real world. An Exam would not know about who has taken it because many people could have taken it. The instance of taking an exam, then, should be a first-class concept in your model.
Consider this:
Exam has many TakenExams, TakenExams belongs to Student http://yuml.me/6627495d
Now the concept of taking an exam is a real object, you can then model assocation metadata as well, such as dateTaken, score, and so on.
Also remember that Core Data expects you to have all of your inverse associations set up as well.
You don't usually copy an entity. (I'm not sure what happens if you call copy on an NSManagedObject... it's not explained in the documentation, as far as I know. Experts can correct me. )
Just create another entity, or write a method which does just that.
I think another way is to make many-to-many relationships between Exam and Student:
create relationships in Exam called studentsToTakeThisExam and studentsWhoTookThisExam.
create relationships in Student called examsToTake and examsAlreadyTaken.
and set up the inverse relationships accordingly.
I would not argue (as You requested) if your modeling is correct or not. The procedure to copy an entity is, in general, quite complex, owing to the fact that, besides attributes, you also need to deal with the entity's relationships and copy them. I can not post here a huge amount of source code showing how to accomplish this, however, I can point you to a book where this issue is described in detail, with all of the source code you need. The book is the one from Marcus Zarra, "Core Data Apple’s API for Persisting Data on Mac OS X" by "The Pragmatic Programmers".
You really don't want to copy an Exam in this situation. You'd end up with lots of identically named Exams which didn't have a relationship with each other, and then you'd be forced to group them together (if you wanted to) by their name.
I'd recommend a new entity (perhaps "ExamSitting"?) which represents a Student sitting an Exam. You could then a to-many from Student to ExamSitting, and a to-many from Exam to ExamSitting. This enables you to have as many attributes on the ExamSitting as you like then (hasTaken, grade and so on).
Edit
Okay, given your clarification, I have a point or two to add (although they may not be what you're looking for). I understand that you're loading from files with a particular structure, but that doesn't necessarily have to dictate your structure.
With the XML files laid out as you now describe, I would still use an Exam - Student - ExamSitting model. If I were to implement it, I'd load all the Students, and then, for each record in the Exams file, I'd create one Exam object, and then a number of ExamSitting objects, one for each Student that fits the criteria defined in the record. As I mention above, this enables you to store more information about each event, such as mark, takenDate and so on.
If you're sure there's no requirement to be able to store additional information at this granularity, you could just create a to-many relationship studentsTakingExam. This could be populated as you load each exam record by querying the loaded Student entities.
I am trying to draw a domain model or class diagram in UML for car dealership. I am stuck with how to present test drive in the model. One way is to have appointment class and then test-drive as sub class. A dealer also offers after-sale vehicle service so i could have appointment/booking class as super class and then vehicle service and test-drive as two sub classes.
Another way is to have the customer class have a direct relationship with test drive class and vehicle service class under appointment class.
A dealer also sells new and used cars and their parts.
A dealer also offers finance for car sale.
Would testdrive class have relationship with vehicle class or there is separate class for display and testdrive class?
Another question is how do I show potential customers and their inquiries about sale and service in the model. A dealer wants to save details of potential customers if they allow for marketing purposes. Shall I have two classes: one for customers and one for potential customers or it can be achieved just by using an attribute in customer class?
You can really only distinguish the right decision by having a good set of use cases or expected behaviors of the model.
This will inform whether a particular sub-classing is really accurate.
I can see that an appointment might contain several test-drives, which are themselves linked to individual vehicles, So a test-drive itself is nothing more than a link from a customer to a vehicle which are linked to an appointment.
test-drive would contain the information relevant only to the test-drive:
reference to the customer - even this might be debatable to include
reference to the vehicle
length of test drive
location (perhaps the vehicle was driven at a different location than could be determined from the owning appointment)
customer temperature (hot or cold - i.e. did the customer seem enthusiastic)
comments
etc.
But what is not in the test-drive object is anything related to the appointment - since it is always contained in a collection - possibly as part of an appointment or some other event container. Now if the containers which can contain test-drives always include customer information, I might not even include the customer reference in the test-drive object - after all, it will be redundant.
It depends if test-drives can occur in non-appointment scenarios - perhaps at a "sales event" or an "open house" or something where appointments are not actually created in the use cases - or if test-drives for multiple customers will occur within a container.
The second part of your question has been forgotten (easily done when you ask two questions in one):
Another question is how do I show potential customers and their inquiries about sale and service in the model. A dealer wants to save details of potential customers if they allow for marketing purposes. Shall I have two classes: one for customers and one for potential customers or it can be achieved just by using an attribute in customer class?
I think your use case there is "A dealer wants to save details of potential customers if they allow for marketing purposes." and the simplest solution is to have a Mailing List collection which holds name and address of each potential customer.
I think you miss the point. The aim of the domain model is make famliiar you with the domain:
-- What kind of entities you have in yor domain?
-- If they are important for your system under desing,
what kind of properties they have, how they behave?
-- What kind of business rules they obey?
The rest is details. Think like a map maker. Record what there is.Create a simple map so you can not lost your way in that domain. Not try to invent.Abstract what exist in the domain: Not run behind the "fancy abstractions" you created yourself.
Domain model can be used as a source
for object oriented analysis/design.
But their aim is not to represent
software abstractions.