Focal Point
FOC file - multiple indexes?

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/9851009331

October 10, 2005, 08:45 PM
<Unfocused>
FOC file - multiple indexes?
Can a FOC file have more than one index?
I'd like to do something like-:

TABLE FILE CAR
PRINT *
ON TABLE HOLD AS CARIX FORMAT FOCUS INDEX MANUFACTURER INDEX2 MODEL
END

Is the only way to do this by having two hold files, one for INDEX MANUFACTURER and one for INDEX MODEL?

thanks
October 10, 2005, 08:59 PM
TerryW
Yes, a 'FORMAT FOCUS' file can have up to 4 fields indexed this way. At least with the versions of FOCUS I have worked with.

Later versions may be more, but I wouldn't expect less.
October 10, 2005, 09:08 PM
drew billingslea
just list the fields you want after the word INDEX, there is no INDEX2 kwyword.

i.e.

INDEX MANUFACTURER MODEL

hth, drew
October 11, 2005, 02:00 AM
susannah
Un, short answer: yes indeed, focus files can have a bunch of indices;
i believe index fields must be key fields. At least i've always thought so. (ps: but not so, see Noreen's cool example below)
yet all key fields do not have to have indices
TABLE FILE CAR
SUM SEATS WEIGHT REVENUE
BY CAR BY COUNTRY BY MODEL BY WHATEVER
ON TABLE HOLD AS MYCAR FORMAT FOCUS
INDEX CAR COUNTRY MODEL WHATEVER
END
..the index names referenced in the INDEX statement don't seem to have to be in any specific order. and they don't have to be all in one segment. they can be from any segment.
i've got files with 8 indices, working fine.
just ordinary focus files, not even xfocus.
October 11, 2005, 03:23 AM
j.gross
Non-key fields can be indexed.

The total number of segments and index structures in a FOCUS file is limited (by the structure of the FDT) to 64. XFOCUS limits are higher.
October 11, 2005, 02:43 PM
Noreen Redden
OK, to recap.
You can have specify multiple indexes in a HOLD FORMAT FOCUS file, and they need not be keys. In older releases (pre 708) in FOCUS, the number of indexes + number of segments must be less than 1024, but the number of segments is still limited to 64. It is important that you can put an index on a non-key field, as I sometimes use COMPUTE to create a multi-field index so that I can JOIN on multiple fields. ie TABLE FILE CAR SUM COMPUTE INDX/A24 = COUNTRY | CAR; SALES BY COUNTRY NOPRINT BY CAR NOPRINT ON TABLE HOLD AS ABC FORMAT FOCUS INDEX INDX
October 20, 2005, 11:33 AM
<Unfocused>
Thanks using FORMAT FOCUS worked.
October 20, 2005, 02:42 PM
Lloyd
Sorry for the interuption, but I am a bit confused. Coming from a strict SQL background, maybe the concept of indexes(sp?) is different. In SQL, multiple Indexes means more than one index with various feilds making up index.

I.e.
Create Index INDex1 as f1, f2, f3;
Create Index INDex2 as f4, f5, f6;

Is the meaning different for Focus? From the answers above it seems that way. To me it looks like you are referring to multiple FIELD indexes. could someone clarify for me?
October 20, 2005, 04:41 PM
Noreen Redden
You are right LLoyd, we are taking at least two different things.
1) Single field indexes on multiple fields.
that you create by HOLD FORMAT FOCUS INDEX field1 field2 field3. You will then have separate indexes for field1, field2, and field3.

2) Multi-field index. Now, for WEBFOCUS that is supported with MDI (multimensional index), or you can do this via a COMPUTE to create a new single field that contains the values of all fields to be put into the index. For instance, in the CAR file, I want to index the concatenation of COUNTRY, CAR and BODYTYPE to improve either a JOIN, or selection. In that case, I would have:
TABLE FILE CAR PRINT RCOST DCOST
COMPUTE INDX/A38 = COUNTRY | CAR | BODYTYPE;
BY COUNTRY BY CAR BY BODYTYPE
ON TABLE HOLD FORMAT FOCUS INDEX INDX
END
You can them from another file, JOIN COUNTRY AND CAR AND BODY IN FILE2 TO INDX IN HOLD

Hope that clears it up.