The third table is commonly called a Junction Table. It resolves the Many-Many relationship into two 1-Many relationships.
I tend to think of this in 2 directions. You may only need to use one of these directions. It depends on you use case(s).
Use Case #1: For a given blog get an editable list of Categories.
Blogs is a root BO and contains a child collection of BlogCategories. Each child BO in BlogCatgories is a Category object. You should have a factory method on the Blog which takes a PK named ID_Blog and retrieves all the data about the Blog from the Blog table. This root BO then fetches its child collection of categories based on ID_Blog. The SQL statement does a join between the Junction table and the Category table and SELECTs data based on ID_Blog.
Use Case #2: For a given Category get an editable list of Blogs.
(Reverse the terms above.)
You may not need use case #2. But if you do, you will be building different objects for Blog. One is a root and the other is a child. You may decide to use a switchable object but that is a maintenance headache and you will be better off using different names for them.
Joe
You are going to have 2 Editable Root Objects, Blog and Category.
If a Blog can be in more than one Category you will have a Child Collection (BlogCategories) of Editable Child Objects (BlogCategory).
You will have similar objects for Category; CategoryBlogs, and CategoryBlog.
Look at the Project and Resource objects in the Project Tracker example app.
E
Samurai:If I use Use Case 1#, how should I generate Category object.
Regards!
===================================================================
Use Case #1:
BOs for an editable screen:
1. Root BO = Blog
2. Editable Child Collection = BlogCategories
3. Child BO = Category
===================================================================
BOs for a Read Only screen:
1. Root BO = Blog
2. Read Only Collection = BlogCategoriesROC
Nested in the ROC is a class named CategoryInfo.
===================================================================
Joe
I would think the "junctions" would be a "child" collection (BusinessListBase) of the object being edited. When the object is saved, it saves the child list of junctions.
Copyright (c) Marimer LLC