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


Hi all
I have a file for teacher comments about school subjects, one record per subject/student/semester. The file is used for semester reports to parents.
If there are 10 students in the school, 6 subject matters and 12 semesters for the whole school period, then the table will have 720 records.

The table looks like this:

#subj_notes.dbf structure#

ID (autoinc)
semester (int)
subject_id (int, relates to subjects.dbf)
student_id (int, relates to students.dbf)
comments (memo)
*below, indexes*
ID
#edited after posting: corrected composite index, I made a mistake#
wrong -> subj_stud (expression: STR(subject_id)+STR(student_id)
subj_stud (expression: STR(subject_id)+STR(student_id)+STR(semester)
subject_id && I not sure if this one is necessary...
student_id && I not sure if this one is necessary...
#end of subj_notes.dbf structure#


Q: Can I make the composed index the primary key? It makes sense to me, but I want to ask first to make sure it's not against some rule I wouldn't know.
The records will always be accessed by that key. A seek() on "student_id" alone would not bring any meaningful result, since the user needs to know subject & semester too.

Regards
Samir

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