Subject Re: [firebird-support] Possible to have an index across 2 tables?
Author tjelvar eriksson
Hi Maya,

>I need some advice on how to structure my table for speed, but without
>creating a redundant field hopefully.

I figure your databas looks like:

customers -1:n- incidents -1:n- comments,

guess a aggreagated view is as fast as it gets without triggers,
of course with indexed keys, but I recall I had just the same need a
few years ago and the performance was a horror.

>I need to see the latest communication for a customer. Problem is, the
>customer ID is not in the communications table, but is instead linked
>via an incidents table.

I'd recommend a "lastCommentDate" or something in the incidents-table,
updated by trigger upon new or altered record in the comments-table.

Good luck,
//t
4 nov 2008 kl. 08.53 skrev Maya Opperman:

>
> Hi Set,
>
> >I don't quite grasp your structure, so it is difficult to give sound
> advice. How is COMMUNICATIONS and INCIDENT defined, what is their
> >relationship and approximately how many records are there within each
> table and for each customer?
> Just answered in reply to Helen's mail, but in short:
>
>


> customers -1:n- incidents -1:n- comments
>

> Table Records
> Customers 15000 PK ID
> Incidents 150000 PK ID, CustomerID references Customers.ID
> Comms 1500000 PK ID, IncidentID references Incidents.ID
>
> Need to extract max date in Comms per Customer
>
>



[Non-text portions of this message have been removed]