Board index » delphi » Master-Detail Question

Master-Detail Question

I have two dBase tables (A & B) in a Master-Detail relationship where A is
the Master, and B the Detail.  Is there any way to sort the Detail records
in Table B using an index other than that used to link the two tables?

If I try changing the Index Name property, the Master-Detail link is
broken.

I ask because I've a DBGrid displaying Table B that would be a lot easier
to use if I could alphabetize it.

br...@creative.net

 

Re:Master-Detail Question


Quote
> I have two dBase tables (A & B) in a Master-Detail relationship where A is
> the Master, and B the Detail.  Is there any way to sort the Detail records
> in Table B using an index other than that used to link the two tables?

> If I try changing the Index Name property, the Master-Detail link is
> broken.

> I ask because I've a DBGrid displaying Table B that would be a lot easier
> to use if I could alphabetize it.

> br...@creative.net

I believe using the Database Desktop, you could define a secondary index that
will work with TWO fields.  A Primary sort field, and a secondary sort field
all wrapped up up in one index.  If you define the primary field in that newly
created index as the field that you need to maintain the Master/Detail
relationship, and the secondary field as your second choice for sort order,
that might do it..

----
RKR

****************************************
E-Mail:  r...@primenet.com
****************************************

Re:Master-Detail Question


"Brian Todd Donaldson" <br...@creative.net> wrote:

Quote
>I have two dBase tables (A & B) in a Master-Detail relationship where A is
>the Master, and B the Detail.  Is there any way to sort the Detail records
>in Table B using an index other than that used to link the two tables?

You can use SQL to specify the relationship and get whatever sort
order you want on the detail table. I don't think you can do this
using the indexed access methods, though. At least, I haven't found a
way. I don't know what impact SQL has on performance either. It's
bound to be slower, but I don't know how much.

--
Jerry

Re:Master-Detail Question


Quote
r...@primenet.com wrote:

> > I have two dBase tables (A & B) in a Master-Detail relationship where A is
> > the Master, and B the Detail.  Is there any way to sort the Detail records
> > in Table B using an index other than that used to link the two tables?

> > If I try changing the Index Name property, the Master-Detail link is
> > broken.

> > I ask because I've a DBGrid displaying Table B that would be a lot easier
> > to use if I could alphabetize it.

> > br...@creative.net

> I believe using the Database Desktop, you could define a secondary index that
> will work with TWO fields.  A Primary sort field, and a secondary sort field
> all wrapped up up in one index.  If you define the primary field in that newly
> created index as the field that you need to maintain the Master/Detail
> relationship, and the secondary field as your second choice for sort order,
> that might do it..

> ----
> RKR

> ****************************************
> E-Mail:  r...@primenet.com
> ****************************************

Delphi 1.0 No you only can view the order in which the master index is
set to.  I had the same problem and ended up writing a new DBGRID that
that would sort it in the right order.  You can get a DBGrid Sort
component from the internet.  Try using that.

Mark
Sheppard Consulting

Re:Master-Detail Question


Quote
Brian Todd Donaldson wrote:

> I have two dBase tables (A & B) in a Master-Detail relationship where A is
> the Master, and B the Detail.  Is there any way to sort the Detail records
> in Table B using an index other than that used to link the two tables?

> If I try changing the Index Name property, the Master-Detail link is
> broken.

> I ask because I've a DBGrid displaying Table B that would be a lot easier
> to use if I could alphabetize it.

> br...@creative.net

   The thing to do is to make compound indexes for the detail table.
Suppose you have a detail table of Orders, linked in a detail relationship
to the customer table.  You might create one index on the detail table
that is
         Customer , Date, Salesperson, OrderNo

or another that is

         Customer, SalesPerson, Date, OrderNo

or another that is

         Customer, OrderNo

All three indexes can be used to link to the customer table, but they
will provide different sorts within the detail grid.

--
Paul Schopf                          
Coupled Climate Dynamics Group/971    
NASA Goddard Space Flight Center              
Greenbelt, MD 20771

Other Threads