Lets say I have 3 entities: A, B and C.
A and B are both aggregate roots and reference C
C does not reference anything
Does this mean by DDD that C is also an aggregate root because it is referenced by more than one entity? (Or else it could be part of that only referencing entities aggregate).
Thanks
Yes. In this case C is an entity, and not an aggregate root.
Related
I have many collections in MongoDB which I have added to the same index, the collections have a type attribute which actually contains the name of the collection.
I added a type attribute so that I could give custom ranking to results from different collections. But I couldn't figure out how to do it.
Collections: a, b, c, d, e
Each collection has a type attribute which contains name of the collection.
I want to give searching preference to records in the order d,c,e,b,a so if a keyword exists in both c & a then result of c should be shown first.
The solution was pretty easy, I added an attribute 'priority' of type integer to my collections and used that for custom ranking as it is a number so asc|desc worked for it.
Is it possible by default to merge more than two contacts in Dynamic CRM 2011?
If it is not, what is the workaround needed to make it happen?
I don't think so.
Workaround: You have three contacts, A, B & C.
Merge A and B (A + B = AB).
Merge A and C (AB + C = ABC).
I would also suggest to create an entity that stores the old 1:N relationship as you merge records. For example if you have two contacts A and B and both of them have orders each say X and Y. When you merge A and B the child records (both X and Y) will now be attached to the primary record let's say A. This means you will not be able to ever relate deactivated record B with order Y. Having this stored in custom entity will save you time if you ever need to investigate data.
I'm new to core data.
I have a data model, in which there are two tables and a 1-N relationship between them.
The application downloads all data from a service and saves the data in each table.
In addition, the tables are related and therefore want to do this:
a) Obtain all elements of the table2, which satisfies certain conditions.
b) For each element in table2, the identifier look table1 / save the table1´s id.
c) I get the item in Table 1 which meets the requirements ID.
d) I relate to Table 2 with 1.
I'm not capable for doing this. :(
I do not know if this method for make a relation between tables in this way is good or no.
This is sort of difficult to answer. If you think about Core Data as an SQL table you'll just get yourself into difficulty.
Core data isn't about joining and searching tables, it's about an object graph. An object has relationships to another object which has an inverse relationship to the other object. Essentially, what you should be looking to do is:
This is a fetch request of the entity which you are storing in table 2 subject to a predicate which defines your conditions.
You don't actually deal with ids directly in Core Data. You hardly ever deal with the keys directly.
Step 1 returned a collection of objects, and you can run a further predicate on this to filter it.
That is what the inverse relationship is for.
I know this doesn't answer your actual question. I'm trying to get you to think of your Core Data store as a collection of objects related to each other rather than as a bunch of linked tables.
What is the best approach to design a data model based on a generalization relationship. For example imagine there is a based class A and two derived class B and C that inherit class A. Now I want design data model. I have three choices
1) Create Table A and having a type column for specifying B and C data.
2) Create Table A, B and C Just like my class diagram and relate B and C to A.
3) Create Table A, B and C but don't relate B and C to A.
Any clue would be appreciated
Check out this article. Although it is written for JPA, it tells you the pros and cons of each of the strategies you mentioned.
I have Person class which is root of its aggregate, this aggregate also contains country and state province as vo.
{Person, Country, StateProvince} - > Person is root aggregate.
//
Public Person(string name, string country, state province,{other params}){}
// But now i am facing problem in UI, how will i populate Dropdown for Country and Stateprovince, through person because it is root aggregate, but i don't want any person's assigned Country or Stateprovince but i want list of all countries and their Stateprovince, so that user choose one from them
Do i manually create table for country and stateprovince and fill them with all values manually.If yes, then how will i get values from those tables in ddd .
Your model is trying to tell you something.
Country and StateProvince are probably not part of the Person Aggregate.
Remember the very handy "delete test" for an aggregate, ask if I delete this person do I also delete their country and StateProvince? I live in Canada, and you remove me from your system are you also going to delete the country Canada from your system as well?
No, you would not. You have two separate aggregates here Person and Location which would contain the Aggregate of {Country, StateProvince} If you delete a country you would very likely also delete all the states or provinces contained within it as well.
Just because Person references a class or has-a class doesn't make all the references part of that aggregate. Location is very common aggregate in many systems and regularly stands on it's own.
You should have a Person Repository that utilizes a LocationRepository and have the UI directly call the LocationRepository to obtain Location Aggregates.
You would populate your country and state province from different tables. You would then fill the drop downs from these tables. When working with a specific Person entity which has already got Country and StateProvince assigned you would bind them with master tables through id.
Hope that helps.