How to reflect relationship beween subclasses in XML - xsd

How can i define relationship between subclasses in XML, for example a class researcher has two subclass Paper and author .

Normally you would be using an XML schema to describe relationships in an XML file. But I seriously doubt you should make a model where researcher has subclass paper and author, it seems more like researcher is related to the class Paper in the role of Author. All of this you can describe in XML Schema.

Related

In UML, does composition imply an association class?

In a UML diagram where one class is comprised by another class, is there an implicit association table, or does it need to be shown?
For example, if I have Chapters that are composition of Paragraphs, is this alone enough:
Or does the association class to be explicitly shown like so:
I've never seen it done like that latter example, so I'm assuming it's implied. Or maybe I haven't normalized the data properly (considering chapter both appears in the Chapter class and the Paragraph class).
Simply, there is no implication. If you need an association class, you need to define it. However, UML is not about diagraming, it's about modeling. You can omit your association class in a diagram if you want to. The association class will still exist in your model, though.
No, it is not implied.
The reason why you haven't seen this is that in most cases it simply doesn't make sense. In the association class the class part additionally describes the properties of the association. In your example you create an artificial object that actually brings little or nothing. This kind of approach can be useful for many-to-many relationships which are impossible for composition (each part can have at most one whole). Even if you wanted to show Foreign Key it would simply be on one of the classes. But that's implied by the association itself. According to UML specification an inline attribute is equivalent to an association.
Moreover on UML you can depict many to many relationship simply but applying appropriate multiplicities on association ends. You may want to show the class depicting that only when modelling on the code level.
No, it is not implied.
UML is not about tables, but about classes. The author of the class diagram should tell the audience how a class should be interpreted. Some UML diagrams model the real world, others model a piece of application functionality and yet others depict a physical implementation.
Apparently, reading your question, you are modeling a relational database, where a class is a physical table. In that case, I would expect that every table is explicitly modeled as a UML class.
The UML standard does not demand this.
By the way, the notation (PK) and (FK) is not in accordance with the UML standard.

Relation between attributes in related class

It's possible to model the relation between attributes in associated class with the UML Designer? The objective is choose a source and the target class for describe one interaction between objects(for example describe a message in a sequence diagram) Something like this:
No it is not possible to represent dependencies in UML designer directly from attributes to attributes.

Does association in UML associate objects or classes?

On Wikipedia, I'm reading that an association relationship is an instance level relationship so we are talking about the relationship between the objects of two classes.
When we actually draw a class diagram, why do we use association on the class elements or blocks rather than objects? And there are also class level relationships for which we again use class elements. Since we don't have any way to show if we are talking about objects or classes I find this confusing. For example: I've heard people saying "Associate these two classes" Doesn't that sound wrong?
Links are to Associations as Objects are to Classes.
A Class is an abstraction that describes many specific objects. Similarly, an Association is an abstraction that describes many links between objects.
So your statement
an association relationship is an instance level relationship
isn't strictly correct because it mixes the abstraction (Association Relationship) with the instances it represents.
hth.
In fact, when you associate two or more classes it is done thanks to two or more UML Properties.
These latter are the "ends" of your associations and are "instance" i.e. they are typed by classe.
So an association is created between two classes on a class diagram but between each classes and the association you have a UML property.
Hoping it sounds clear ...
When you are making a class diagram you are defining types. Suppose you have a class User and a class Account, you use an association between User and Account to say: User instances can have link(s) with Account instances at runtime.
So, you use classes and associations at type level (class diagram) to define what can be possible at runtime (instance level).
The object is actually the Class that has been created virtualy. So a class is the "static" version of an Object. So, when we speak of UML, we speak about classes and not object.
But correct me if I'm wrong!

Can I use Eclipse-EMF's internal data structure?

In EMF, a user can draw UML diagram and that UML model can be transformed into Java code. As far as I know EMF has its own internal data structure to capture the UML model user draws. And what I want to do is to make UML model by coding, not by drawing, i.e., by using EMF's internal data structure representing UML metamodel(Class, Package, Attribute, etc). Like,
UmlClass myClass = new UmlClass();
UmlAttribute myAttr = new UmlAttribute();
myClass.addAttribute(myAttr);
Is this possible(not even by EMF)? Anyway, I want to use a robust data structure that exactly reflects OMG's standard UML specification.
Thanks in advance.
EMF is a modelling framework designed to support modelling in general, not just UML.
If it is UML in particular you're after, there is indeed such an implementation built on top of EMF. Check out UML2.
There are no classes exactly reflecting the OMG specification, but EMF ECore is a meta model for models. Therefore you can do what you want using EMF ECore. There is lots of doc at http://www.eclipse.org/modeling/emf/docs/#overviews and an excellent book. The link has a picture and link to the book.
An example:
EcoreFactory ecoreFactory = EcoreFactory.eINSTANCE;
EClass myClass = ecoreFactory.createEClass();
myClass.setName("MyClass");
EAttribute myAttr = ECoreFactory.createEAttribute();
myAttr.setName("myAttr");
myAttr.setEType(EcorePackage.Literals.ESTRING);
myClass.getEStructuralFeatures().add(myAttr);

UML class model how to model many to many relationship

I have read several tutorials on what a UML model should contain and what not. As a developer I always think in terms of a relational data model where you could never have a many to many relationship between tables. Now with a UML class model, I've read that if they don't provide added value, you could just skip the linktables.
However I've also read a tutorial where examples where given using data inside tables and was strongly suggesting to picture each class as a simple table while modeling your class model.
I am confused, what is it now?!
The "relational link table" is an implementation technique for a Many-to-Many relationship.
The relationship exists irrespective of how it's implemented.
In an object model, you have many choices for how to implement many-to-many, which may (or may not) involve an additional persistent table. It could be done lots of different ways.
The point of UML is to be able to describe the essential features of what the model really is.
You can also describe the implementation. They're separate diagrams with separate purposes. You can easily show the relational implementation with the link table. You can also show the essential model without the link table.
Here's the essential relationship
Here's the implementation of the relationship
Both are valid UML. The real question is "what do you need to show other people?" Essential truth or one particular implementation?
Model it as an M:N relationship. Same as in a relationship model there will be an associate class (or link class) of some kind in code. No need to put that on the diagram unless it has attributes on top of the join attributes (much like you would generally omit a join entity from an ERD unless it had attributes that weren't foreign keys in the related entities). The link class is typically drawn as a class connected to the relationship by a dashed line.
The Enrolment join entity is a good example of this in UML 2 Class Diagrams.

Resources