Re: Determine which child table a record belongs to

2008-01-29 Thread Craig L Russell
On Jan 29, 2008, at 10:49 AM, MZ_TRICSTA wrote: One last question, guys. What if there is overlapping between the child tables, so that one instance has more than one "Type"? Then you might want to model this as an Entity-Role relationship which allows multiple rows in associated tables

Re: Determine which child table a record belongs to

2008-01-29 Thread Daniel Noll
On Wednesday 30 January 2008 05:28:14 Craig L Russell wrote: > The alternative is to include all possible tables in a query, which is > performance-limiting. Another alternative is to use single table inheritance, where you still have a type column but also put every field from every class into t

Re: Determine which child table a record belongs to

2008-01-29 Thread MZ_TRICSTA
One last question, guys. What if there is overlapping between the child tables, so that one instance has more than one "Type"? Craig L Russell wrote: > > This is a very common pattern in object-relational mapping. The column > that contains the type of crane is commonly referred to as a > d

Re: Determine which child table a record belongs to

2008-01-29 Thread MZ_TRICSTA
Thanks, Craig. Glad to know that this is common practice. I am in the process of implementing the solution as we speak. Craig L Russell wrote: > > This is a very common pattern in object-relational mapping. The column > that contains the type of crane is commonly referred to as a > discrimi

Re: Determine which child table a record belongs to

2008-01-29 Thread Craig L Russell
This is a very common pattern in object-relational mapping. The column that contains the type of crane is commonly referred to as a discriminator column, and is commonly a CHAR, VARCHAR, or NUMERIC type. The value of the discriminator column that identifies which table to look for is referr

RE: Determine which child table a record belongs to

2008-01-29 Thread MZ_TRICSTA
Oh! I see. So I would need to add a "Type" column for all my parent tables. That would definitely make things easier, but I was hoping there was some SQL code that would magically give me the name of the child table. Still, this will work fine. Thanks for all your help. ~Tricsta Brad Moore wrote

RE: Determine which child table a record belongs to

2008-01-29 Thread Brad Moore
2008 10:04:26 -0800 > From: [EMAIL PROTECTED] > To: derby-user@db.apache.org > Subject: RE: Determine which child table a record belongs to > > > Thanks for your help, Brad. You are absolutely right. In this case, it > doesn't make sense to have so many tables. I will

RE: Determine which child table a record belongs to

2008-01-29 Thread MZ_TRICSTA
Thanks for your help, Brad. You are absolutely right. In this case, it doesn't make sense to have so many tables. I will make the changes you suggest. However, there are times when it does make sense to have this kind of hierarchical structure such as when the child tables have different fields, s

RE: Determine which child table a record belongs to

2008-01-29 Thread Brad Moore
Can I suggest changing the "Crane" table to include a CraneType column or something similar? I don't know if there is a reason that's not obvious to me why you need all of the other tables. It looks like you're using the other tables to determine the type of crane, the same thing could be done