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: 268930 # Views: 32 # Ratings: 0
Version: Visual FoxPro 9 Category: Databases, Tables and SQL Server
Date: Thursday, July 15, 2010 2:19:09 PM         
   


> I made a mistake and corrected it my original post. Here a copy:
>

> #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
> #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#

>
> > subj_stud (expression: bintoc(subject_id)+bintoc(student_id)) && I am not sure you ever need this
> Q1: Does this still apply? I mean your notes "I am not sure you ever need this"
>
> > with 720 records I am not even sure that you need any indexes-a dream school:)
> Unfortunately not a dream school. 70 Subj/competencies * xStudents * 12 semesters. Still not a huge amount, but it needs indexes.
>
> >
> > Can you make? Yes you can.
> > Should you make? No you shouldn't.
> >
> > That would create another debate thread:)
> >
> > Everyone on its own but general best practices (well not written explicitly somewhere I think) tell that you should use a surrogate key as a primary key. It is there for you 'the developer' to uniquely identify a row in a table. It shouldn't be something that could be altered by end users. You have an autoinc column there generated on table and have no enduser interaction. Use it as a primary key (though my preference is a GUID on a canned local solution integer keys perfectly make sense).
> > You can create another index either regular or candidate (if you would like it to have unique values enforced as in a primary key) for your composite key. Then maybe something like this:
> >
> > *below, indexes*
> > ID
> > subj_stud (expression: bintoc(subject_id)+bintoc(student_id)) && I am not sure you ever need this
> > subject_id
> > student_id
> >
> > with 720 records I am not even sure that you need any indexes-a dream school:)
> >
> > Cetin Basoz
> >
> > .Net has got better.Think about moving - check my blog:
> > Blog (main)
> > Blog (mirror)
>
>
>
> Regards
> Samir

Then correct my reply too:)
subj_stud (expression: bintoc(subject_id)+bintoc(student_id)+bintoc(semester)) && I am not sure you ever need this


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