Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Cetin Basoz
  Where is Cetin Basoz?
 Izmir
 Turkey
 Cetin Basoz
 To: Samir H.
  Where is Samir H.?
 Yogyakarta
 Indonesia
 Samir H.
 Tags
Subject: RE: Composed Index as primary key?
Thread ID: 268913 Message ID: 268934 # Views: 29 # Ratings: 0
Version: Visual FoxPro 9 Category: Databases, Tables and SQL Server
Date: Thursday, July 15, 2010 2:35:00 PM         
   


> It is recently that I discovered composite indexes (very useful). I used to do LOCATE and SCAN REST etc...
> > subj_stud (expression: bintoc(subject_id)+bintoc(student_id)+bintoc(semester))
> VFP help file says:
> "You can use BINTOC( ) to reduce the size of indexes for numeric fields containing integer data by passing a numeric eFlags..."
> I just created this new table and would like to make it correctly from the start. Could you tell me what eFlag I should put in bintoc() ?
> I read a bit about bintoc(), and want to have a closer look later. But in the meantime I'm ready to follow your or other experts advice without knowing too much about it.

Composite indexes' usefulness in VFP is debatable. In specific cases yes they are useful but for the case you presented I don't see a usefulness especially if you create the key with that subject+student+semester order. Probably to benefit from it you would have combinations like student+subject+semester, student+semester+subject ... ending in 6 different indexes maybe.

What does help mean there is you could reduce the size of integer used. An integer is an 32 bits/4 bytes value. If say your student ID would be a maximum of 32767 then it fits into 2 bytes you can use 2 as size flag (bintoc(studentID,'2RS')). Or subject with a maximum of 127 would fit to a 1 byte and you could use bintoc(subjectID,'1S'). R and S are not of much important here, but note that VFP only uses unsigned portion (single byte is up to 127 not 255, it is actually -128 to 127). But before doing such space savings think twice. You may be good with 127 subjects today but if you need the 128th then you are in trouble (reminds me space saving for year 2000).

Cetin Basoz

.Net has got better.Think about moving - check my blog:
Blog (main)
Blog (mirror)

ENTIRE THREAD

Composed Index as primary key? Posted by Samir H. @ 7/15/2010 11:26:26 AM
RE: Composed Index as primary key? Posted by Cetin Basoz @ 7/15/2010 12:34:34 PM
RE: Composed Index as primary key? Posted by Samir H. @ 7/15/2010 1:21:52 PM
RE: Composed Index as primary key? Posted by Cetin Basoz @ 7/15/2010 2:19:09 PM
RE: Composed Index as primary key? Posted by Samir H. @ 7/15/2010 2:40:10 PM
RE: Composed Index as primary key? Posted by Samir H. @ 7/15/2010 2:03:14 PM
RE: Composed Index as primary key? Posted by tushar @ 7/15/2010 2:16:13 PM
RE: Composed Index as primary key? Posted by Samir H. @ 7/15/2010 2:38:39 PM
RE: Composed Index as primary key? Posted by tushar @ 7/15/2010 3:44:03 PM
RE: Composed Index as primary key? Posted by Cetin Basoz @ 7/15/2010 2:35:00 PM
RE: Composed Index as primary key? Posted by Samir H. @ 7/15/2010 2:49:40 PM
RE: Composed Index as primary key? Posted by Cetin Basoz @ 7/15/2010 3:45:23 PM
RE: Composed Index as primary key? Posted by Samir H. @ 7/15/2010 4:01:37 PM
RE: Composed Index as primary key? Posted by Mike Yearwood @ 7/15/2010 8:21:47 PM
RE: Composed Index as primary key? Posted by Samir H. @ 7/16/2010 4:48:41 AM
RE: Composed Index as primary key? Posted by Mike Yearwood @ 7/16/2010 6:07:24 AM
RE: Composed Index as primary key? Posted by Samir H. @ 7/16/2010 6:16:14 AM
RE: Composed Index as primary key? Posted by Cetin Basoz @ 7/16/2010 1:12:42 PM
RE: Composed Index as primary key? Posted by Samir H. @ 7/16/2010 1:23:51 PM
RE: Composed Index as primary key? Posted by Samir H. @ 7/16/2010 1:46:54 PM
RE: Composed Index as primary key? Posted by tushar @ 7/15/2010 4:02:29 PM
RE: Composed Index as primary key? Posted by Samir H. @ 7/15/2010 4:12:41 PM
RE: Composed Index as primary key? Posted by Anders Altberg @ 7/16/2010 1:20:32 PM
RE: Composed Index as primary key? Posted by Samir H. @ 7/16/2010 1:31:56 PM