Design Question: Parent/Child Distribution
Hi,
I have what I think is a straightforward design question. I tried
searching this forum for the answer, but struggled with what keywords
to use in the searches. (I also struggled with what to put on the
subject line for this post!)
Anyhow, here is my question: Given:
public class Pet {...}
public class Dog extends Pet {...}
public class Cat extends Pet {...}
public class Pig extends Pet {...}
Which is the better design?
DESIGN A:
public abstract class PetOwner {
private Pet pet;
PetOwner(Pet pet) {
this.pet = pet;
public Pet getPet() { return this.pet; }
public class DogOwner extends PetOwner {
public DogOwner(Dog dog) {
super(dog);
public class CatOwner extends PetOwner {
public CatOwner(Cat cat) {
super(cat);
public class PigOwner extends PetOwner {
public PigOwner(Pig pig) {
super(pig);
===============================================
or DESIGN B:
public abstract class PetOwner {
PetOwner() {
public class DogOwner extends PetOwner {
private Dog dog;
public DogOwner(Dog dog) {
super();
this.dog = dog;
public class CatOwner extends PetOwner {
private Cat cat;
public CatOwner(Cat cat) {
super();
this.cat = cat;
public class PigOwner extends PetOwner {
private Pig pig;
public PigOwner(Pig pig) {
super();
this.pig = pig;
This is a somewhat contrived example, so don't take it too literally.
My question is where should I put the field that holds a Pet object?
All pet owners own a pet, so should I put it in the parent class
(Design A)? Note the constructors for the child classes (e.g.
DogOwner) are designed so that the correct type of pet is checked
for. Or should each child class hold its own type of pet (Design B)?
If the answer is "it depends" (as I suspect it is), then what are
the questions I should be asking myself in order to decide?
Thanks very much, in advance!!
Chris
eg,
import java.util.*;
class Pet {
private String name = null;
public Pet( String n ) {
this.name = n;
public String toString() {
return name;
class Dog extends Pet {
public Dog( String n ) {
super( n );
class Pig extends Pet {
public Pig( String n ) {
super( n );
class Cat extends Pet {
public Cat( String n ) {
super( n );
class PetOwner {
private Vector pets = new Vector();
private int dogs = 0;
private int cats = 0;
private int pigs = 0;
public void add( Dog d ) {
pets.add( d );
dogs++;
public void add( Cat c ) {
pets.add( c );
cats++;
public void add( Pig p ) {
pets.add( p );
pigs++;
public boolean isCatOwner() {
return cats > 0;
public boolean isDogOwner() {
return dogs > 0;
public boolean isPigOwner() {
return pigs > 0;
public int numberOfPets() {
return pets.size();
public String toString() {
String s = "";
Enumeration en = pets.elements();
while( en.hasMoreElements() ) {
Pet pp = (Pet) en.nextElement();
s += pp.toString() + "\n";
return s;
public class Pets {
private PetOwner po = new PetOwner();
public Pets() {
po.add( new Dog( "doggy" ) );
po.add( new Cat( "catty" ) );
public String toString() {
String s = "";
s += po.toString();
s += po.isDogOwner() + "\n";
s += po.isPigOwner() + "\n";
s += po.isCatOwner() + "\n";
s += po.numberOfPets();
return s;
public static void main( String[] args ) {
Pets p = new Pets();
System.out.println( p );
}
Similar Messages
-
Bts2006 r2 loop question (parent/child)
I need a resultxml that loops over a childrecord and if there is no childrecord there over the parentrecord/
Can this be done using the mapper or do i need to use XSLT?
Sourcesample
<BOMLine>
<BOMQty>48.0000</BOMQty>
<ItemId>Item1</ItemId>
<BOMReference>
<Qty>23.0000</Qty>
<Reference>Ref1</Reference>
</BOMReference>
<BOMReference>
<Qty>25.0000</Qty>
<Reference>ref2</Reference>
</BOMReference>
</BOMLine>
<BOMLine>
<BOMQty>48.0000</BOMQty>
<ItemId>Item2</ItemId>
</BOMLine>
<BOMLine>
<BOMQty>24.0000</BOMQty>
<ItemId>Item3</ItemId>
<BOMReference>
<Qty>24.0000</Qty>
<Reference>ref3</Reference>
</BOMReference>
</BOMLine>
Desired result
<ResultBOM>
<Qty>23</Qty>
<ItemId>Item1</ItemId>
<Reference>Ref1</Reference>
</ResultBOM>
<ResultBOM>
<Qty>25</Qty>
<ItemId>Item1</ItemId>
<Reference>Ref2</Reference>
</ResultBOM>
<ResultBOM>
<Qty>48</Qty>
<ItemId>Item2</ItemId>
<Reference></Reference>
</ResultBOM>
<ResultBOM>
<Qty>24</Qty>
<ItemId>Item3</ItemId>
<Reference>Ref3</Reference>
</ResultBOM>
Kind regards IsabelledcIf you prefer xslt, I tested below for you and works as you needs:
<Root>
<xsl:for-each select="/Root/BOMLine">
<xsl:variable name="var:itemID" select="ItemId/text()" />
<xsl:if test="not(BOMReference)">
<ResultBOM>
<xsl:variable name="var:qty" select="BOMQty/text()" />
<Qty>
<xsl:value-of select="$var:qty" />
</Qty>
<ItemId>
<xsl:value-of select="$var:itemID" />
</ItemId>
<Reference/>
</ResultBOM>
</xsl:if>
<xsl:if test="BOMReference">
<xsl:for-each select="BOMReference">
<ResultBOM>
<Qty>
<xsl:value-of select="Qty/text()" />
</Qty>
<ItemId>
<xsl:value-of select="$var:itemID" />
</ItemId>
<Reference>
<xsl:value-of select="Reference" />
</Reference>
</ResultBOM>
</xsl:for-each>
</xsl:if>
</xsl:for-each>
</Root>
FYI: I assumed "Root" because your XML above doesn't have a root.
Please mark it as Answer if this answers your question
Thanks.
Mo
The contents I write here is my personal views, not the view of my employer and anyone else. -
Database-Table parent-child design
Hi all,
Which (forum) does this master-detail table design question belongs to or appropriate to post to?
I have 3 basic entities> servers, databases, and apps
example:
servers=server1,server2,server3,etc
database=PROD1,DEV1,TEST1,etc
apps=GL,FA,AP,AR,INV,HR,etc
In every server there are many database type (dev,prod,test,prod1, prod2,etc)
In every apps there are many database type too (dev,prod,test,prod1, prod2,etc)
So databases are children of both servers and apps?
To which parents does this "children" database legally belong?
ThanksHi;
Which (forum) does this master-detail table design question belongs to or appropriate to post to?
I have 3 basic entities> servers, databases, and apps
example:
servers=server1,server2,server3,etc
database=PROD1,DEV1,TEST1,etc
apps=GL,FA,AP,AR,INV,HR,etcFrom your post i got you have EBS. What is your EBS version? By the way its more effecient to close your thread here as answered and move your issue to Forum Home » E-Business Suite » EBS General Discussion
In every server there are many database type (dev,prod,test,prod1, prod2,etc)It possible, i mean on same server you could have EBS's database like dev,prod and also can have oracle database which is not belong any EBS system like sid ORCL
In every apps there are many database type too (dev,prod,test,prod1, prod2,etc)I belive this is wrong, One EBS has one Database but it doesnt mean that database need extra data from other source which is using ETL etc. So your EBS db always parent and get data from child, and also that main db can update information which is exist on child
You could have one PROD and can clone it as CLON so those 2 instance have actualy same data and same proporties, we cant say those dbs has parent-child relation. But we can say CLON ebs produced by PROD instance
Regard
Helios -
Hi All
Fairly new at this and am a bit confused.
I have been given the task of cleaning up certain tables in my DB. I am running into parent / child issues.
I want to remove all entries from Table A. When i try and delete one row it gives me a constraint violation. It tells me there is a child record out there. So i go ahead and disable that constraint, go back to table A and try the delete again. I get a different another violation telling me that there is a child record on a different table. And on and on the story goes.
Now I could keep doing this but the schema i am working on has 1051 tables and just over 6000 constraints. So as you can see this might take me a month to sit here and do that. Not very keen on that.
What I am after is:
1. A program / script that will lay out all the parent child relationships for me. Coming across each one as i try and delete is painful
Would it be possible to get something like:
Table A
-- Table B
-- Table C
Table D
-- Table E
-- Table G
-- Table F
2. All the constraints have been created with a delete rule of 'No Action'. I think the easiest thing to do would be to go to the parent table (or what I think is the parent table) and change this to on delete Cascade. From what it looks like I don't think you can do this. Does anybody know how to? Or if its possible?
3. The third option I am thinking of is:
Disable All the constraints on what I think is the parent table. Remove entries from the child tables. Enable the constraints.
Now my issue here is, how do i know all of the child tables? I guess that goes back to my question 1.
Thanks in advance. Sorry for the story.
The lack of documentation / diagrams here is driving me nuts :)You can use tools like Microsoft Visio to reverse engineer the tables and their relationships.
You can also generate a list of parent-child related tables from user_constraints.
something like:
SQL> SELECT TABLE_NAME,
2 (SELECT TABLE_NAME
3 FROM ALL_CONSTRAINTS R
4 WHERE R.OWNER = U.R_OWNER
5 AND R.CONSTRAINT_NAME = U.R_CONSTRAINT_NAME) PARENT_TABLE
6 FROM USER_CONSTRAINTS U
7 WHERE U.CONSTRAINT_TYPE = 'R'
8 /
TABLE_NAME PARENT_TABLE
EMP DEPT
SQL> -
HI i have some questions which iam unclear please help me
1) in a parent child relationship.. is it always 1-m relation from parent to child?
2) can a parent table be on many side? i.e can a child - parent be 1- m?
3) if i itake employee as child table and department as parent table then dept_id will be the foreigh key in employee table ...
Now if i want to add a new employee who is not assigned to any department can i add it ?
4) In an identifying relationship ... a child table has concatenated primary key (pk of child,pk of parent)
should we still add any other primary key to the table....in addition to this concatenated key?
thanks in advance
rajHi!
1) in a parent child relationship.. is it always 1-m relation from parent to child?
yes unless you create a unique index on the foreign key column
2) can a parent table be on many side? i.e can a child - parent be 1- m?
no, if you need an n-m you will need an intersection table
e.g. employees - emp_dept - departments
in this case the emp_dept table would contain the foreign keys of employees and departments
3) if i itake employee as child table and department as parent table then dept_id will be the foreigh key in employee table ...
Now if i want to add a new employee who is not assigned to any department can i add it ?
no, you will have to insert the master first
Best regards,
PP -
Assuming I introduce a new parent UCCE 8.x system for a new service with a v7.x child system that's already setup to handle calls for existing services can you clarify the following;
Can the child UCCE instance handle some calls from the new service via the parent whilst also handling local calls from existing services? Are there any restrictions?
How does the agent licensing work? Do the agents on the child system also have to be licensed on the parent?
Can the new 'Packaged CCE' be considered for the new parent system as the total number of agents will be less than 200?
Also need to consider question 1 if the child is a CCX system
Many Thanks, Ade.1. Yes, not sure what kind of restrictions you're thinking of, have a look at the overall Parent / Child documentation for limitations etc. though;
3. No, Packaged CCE is a very specific deployment model, the Parent/Child Gateway PG is not supported here;
4. Similar to 1.
Cheers,
Kris -
Dear Networkers,
I have a question concerning the capacity ICM Parent Child deployement :
For one UCCE Parent how many UCCE Child can we deploy ? What is the max capacity for one UCCE Parent to support UCCE Childs ?
Is there a tool that can be used or a document to refer to ?
Thanks a lot in advance.
Best Regards.Hi,
Page of 41 "Cisco Unified Contact Center Enterprise 8.x SRND" tates,
The Unified CCE Gateway PG can connect to a Unified CCE child that is using the Unified CCE System PG or to Unified CCX. If the Unified CCE child has multiple Unified CCE System PGs and peripherals, a separate Unified CCE Gateway PG peripheral must be installed and configured for each one in the Unified ICM parent system. When deployed on a separate server, a Unified CCE Gateway PG can manage multiple child Unified CCE peripherals or multiple child Unified CCX systems (up to five child systems).
Hope it helps,
Anand -
Question about File Content Conversion and parent-child relationships...
Hello!
I have read probably every blog, article and SAP Help document on the topic, but I am stuck on this one. I am trying to convert a General Ledger flat file to an IDoc using the classic file --> IDoc scenario. The setup is done and working, but the IDocs are formatted incorrectly and I believe at least part of the reason is how I am converting the file content.
The root of my problem is that the flat file has a parent-child relationship between the document header and the document item and I want to maintain that since the IDoc type (FIDCCP01) has the same structure in the BKPF and BSEG segments.
Here is the flat (non-XML) file layout that is coming into the file adapter:
FileHeader
DocumentHeader
DocumentItem
DocumentHeader
DocumentItem
and so on (until the number of documents is complete
I would really like the content to be converted so that the line items stay under their parent document headers like this:
<FileHeader></FileHeader>
<DocumentHeader>
<ItemHeader>
</ItemHeader>
</DocumentHeader>
<DocumentHeader>
<ItemHeader>
</ItemHeader>
</DocumentHeader>
But I keep getting this, where it lists the document headers first (one after another), and then all of the line items after the document headers like this:
<FileHeader></FileHeader>
<DocumentHeader></DocumentHeader>
<DocumentHeader></DocumentHeader>
<DocumentHeader></DocumentHeader>
<ItemHeader></ItemHeader>
Is is possible to maintain that parent-child relationship from the flat file and pass it over to the XML?
Thanks,
JohnHi,
Check some links on FCC.
/people/venkat.donela/blog/2005/03/02/introduction-to-simplefile-xi-filescenario-and-complete-walk-through-for-starterspart1
/people/venkat.donela/blog/2005/03/03/introduction-to-simple-file-xi-filescenario-and-complete-walk-through-for-starterspart2
/people/arpit.seth/blog/2005/06/02/file-receiver-with-content-conversion
/people/anish.abraham2/blog/2005/06/08/content-conversion-patternrandom-content-in-input-file
/people/shabarish.vijayakumar/blog/2005/08/17/nab-the-tab-file-adapter
/people/venkat.donela/blog/2005/03/02/introduction-to-simplefile-xi-filescenario-and-complete-walk-through-for-starterspart1
/people/venkat.donela/blog/2005/03/03/introduction-to-simple-file-xi-filescenario-and-complete-walk-through-for-starterspart2
/people/venkat.donela/blog/2005/06/08/how-to-send-a-flat-file-with-various-field-lengths-and-variable-substructures-to-xi-30
/people/anish.abraham2/blog/2005/06/08/content-conversion-patternrandom-content-in-input-file
/people/shabarish.vijayakumar/blog/2005/08/17/nab-the-tab-file-adapter
/people/jeyakumar.muthu2/blog/2005/11/29/file-content-conversion-for-unequal-number-of-columns
/people/shabarish.vijayakumar/blog/2006/02/27/content-conversion-the-key-field-problem
/people/michal.krawczyk2/blog/2004/12/15/how-to-send-a-flat-file-with-fixed-lengths-to-xi-30-using-a-central-file-adapter
/people/arpit.seth/blog/2005/06/02/file-receiver-with-content-conversion
http://help.sap.com/saphelp_nw04/helpdata/en/d2/bab440c97f3716e10000000a155106/content.htm
Regards,
Phani
Reward points if Helpful -
This is very simple question. Parent-Child Relationshiop
Hi~ All.
I think this is not too difficult. But I'm newbie to Flex
I don't understand relationship of Parent-Child, and what's different .addElement, .addChild.
I made some code.
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
width="481" height="442" minWidth="955" minHeight="600" creationComplete="initApp()">
<fx:Script>
<![CDATA[
private var _cam:Camera;
private var _vid:Video;
private function initApp():void{
_cam = Camera.getCamera();
_vid = new Video();
_vid.attachCamera(_cam);
private function createMyVideo():void{
view.addChild(_vid);
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:Button x="36" y="71" label="Create My Video" click="createMyVideo()"/>
<s:VGroup x="192" y="71" width="200" height="200" id="view">
</s:VGroup>
</s:Application>
When I click the button, I wanna show my live video.
But I got a error message.
Error: addChild() is not available in this class. Instead, use addElement() or modify the skin, if you have one.
What's my mistake?
Thanks in advance.
Kevin.
ps. Sorry for my English.This post has a good description of elements vs. children: http://www.billdwhite.com/wordpress/?p=296
-
Parent Child [MSAS cube is not working in BO]
Hi
Does anyone know if the BO is prepared to work with the Parent Child concept? I'm asking that because I've created a universe connected into a MSAS cube and it's not working for hierarchies designed using the parent child concept. When I include the field in the report, it return me a null value, in other words, an error, however if I remove this field the report works fine.
does anyone suffer of the same issue?
ThxHi Rody,
this forum is for the SAP BusinessObjects BI Solution Architecture. I would suggest you post the question into the SAP BusinessObjects product forum for the product that you are trying to use.
regards
Ingo Hilgefort -
I have a parent/child domain structure. The parent domain consists of domain controllers in three different locations (HO1, HO2, HO3). I have set Sites and Services up so that each remote VPN site (Child domain) has a site link to HO1 and HO2 only. When
I attempt to ping the parent domain name from a site server it sometimes resolves to HO3 and times out as there isn't an active VPN tunnel between the 2. My question is why would HO3 be replying when it doesn't have a site link to the remote site and in turn
how can I stop that from being the domain controller that replies?
Thanks for any advice
ChrisHi,
To add, Mr. Ace got a good blog regarding Site and Site links, see if it could help here:
AD Site Design and Auto Site Link Bridging, or Bridge All Site Links (BASL)
http://blogs.msmvps.com/acefekay/2013/02/24/ad-site-design-and-auto-site-link-bridging-or-bridge-all-site-links-basl/
Best regards
Michael
If you have any feedback on our support, please click
here.
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. -
SharePoint 2013 Parent/Child Form
All,
I am completing some audits on accounts with audit names: AuditA, AuditB
I have a SharePoint list 'AuditPopulation' with the following columns:
AccountNumber
AuditName
Then as we are auditing accounts we have audit questions based on the applicable audit. Therefore I have a list called 'AuditQuestions' with the columns:
QuestionID
Question
Answer (Pass/Fail)
AuditName
I am struggling with how to link to the two lists and create a form (most likely in InfoPath) that will display the list of Questions for AuditA when the user clicks the AccountNumber in the 'AuditPopulation' list.
Thank you in advanceYou can use jQuery and Web Service to achieve this task using SharePoint Designer. Refer to the following post for more information
http://sharepoint.stackexchange.com/questions/6493/how-to-automatically-link-parent-in-child-list-new-form
http://go.limeleap.com/community/bid/246651/Creating-Forms-for-SharePoint-Using-SharePoint-Designer-2010
http://www.sharepointdrive.com/blog/how-to-establish-a-parent-child-relationship-in-sharepoint/
--Cheers -
Dimension tables - parent child or hierarchical
The data I m dealing with is structured as follow.
A customer has many stores and each store has a POSSystem.
Customer
Stores
POSSystem
So now when I create Dimensions, will I create as:
TableName Cols
DimCustomer CustKey
DimStores StoreKey, CustKey
DimPOS POSKey, StoreKey, CustKey
Are these Hierarchical or Parent Child?
Now when I will create Fact table, will I have:
TableName Cols
Sample1: DimFactPOS CustKey,POSKey,StoreKey, #trans
OR
Sample2: DimFactPOS POSKey, #trans
If I do sample1, then why do I keep "StoreKey, CustKey" in DimPOS?From your question, I can assume that you have beginners knowledge in Data modeling and Data Warehousing.
Let me elaborate it and dilute your confusion.
You have designed
Star Schema; basic intention for having star schema is to have normalized fact tables and de-normalized dimension tables.
Reason you are creating three dimension (i.e. DimCustomer, DimStores and DimPOS) here because you must have many-to-one referential integrity between each level. You can google about Hierarchies,
Levels and Level relationships to get insight information about it.
Keeping normalize data in dimensions and keeping keys in fact table is a business decision. To which level you want to show the aggregated data? You
need to define granuality level based on business needs.
As in star schema, there is 1 fact table related to different dimensions. If I sub divide your assumption, Sample 1 represents
Data Mart and Sample 2 represents Data Warehouse.
I hope it will help you in understanding basic concepts. -
How to allow Sharepoint users to login from multiple parent-child accounts?
Our client has mutliple AD domains and wants to allow people which have multiple AD accounts in multiple domains to login as THE SAME user:
- only primary account will be visible in search
- there will be only one user profile with all informations gathered from all sub accounts
- permissions for the sub account will be in sync with parent account
- task generated for parent will be visible for child accouns too etc
- ad admin can link the account together in the Active Directory - this link is permament (even if we move users to another OU) and ad admin can define which account is primary and secondary (parent/child)
How we can implement this in Sharepoint 2010 Std Server?Everything in SharePoint keys of the Security Identifier (SID) of a user. Each user in a domain has a unique SID, so there is no way to have multiple users recognized in SharePoint as the same user.
Paul Stork SharePoint Server MVP
Principal Architect: Blue Chip Consulting Group
Blog: http://dontpapanic.com/blog
Twitter: Follow @pstork
Please remember to mark your question as "answered" if this solves your problem. -
How to update a parent child hierarchy in OBIEE
Hello All
Quick question about updating parent child hierarchy in OBIEE.
As we know, OBIEE 11G allows us to create value based hierarchy by generating table creation script and insert script. In the typical example of employee dimension, the parent child relationship table will be created with the following 4 attributes:
MEMBER_KEY, ANCESTOR_KEY, DISTANCE, IS_LEAF
So, what if later in the years some of the employees got promoted, retired or transferred? The value based hierarchy is going to change because person 1 reports to manager 2 now instead of 1. Obviously, the records in employee dimension is going to be updated. When that happens, how to update the parent child relation table with the same information? Do we have to rerun the insert script? How do we keep the history of employee changes and hierarchy changes?
Please advice
Thank youI guess it will update when the structure changes,Let see the response from other gurus.
Thanks,
Maybe you are looking for
-
i need help converting my songs and stuff from my phone to my computer?
-
How to process the reports synchronously...
Hi, We are having a set of reports. When multiple requests are coming into the server, all the requests were maintained in the Queue and processed one after the other. Due to this many requests are starving in the queue. Is there any way to process t
-
When I plug my ipad to my tv it says change device resolution but I don't know how to change screen resolution on ipad 2
-
MuVo N200 Screen Too Small To Re
Hi, I just bought the MuVo N200 (52MB using Win XPHome) and trying to figure it out. Now that I got the software up (w latest the firmware installed), I'm challenged by the tiny screen area. Dunno if I'll rue this purchase therefore! Getting out by s
-
hi all what could be possible reasons for t-code cat2 to throw run time error urgent thanks in advance