November 11, 2005 at 2:59 pm
hi there,
i am new to sql server database.i am doing small projects right now using asp.net and sql to create webpages (very basic webpages)
My problem is:
Problem :
i have two tables .....table 1 and table 2.
Table 1 has following fields: studentid,student name,student address.
Table 2 has following fields:studentid and course .
table1 student id is the primary key refrencing table 2 student id.
Now i delete a record in table 1 which will in turn also get deleted in table 2 . so for eg if i have three records 1 ,2 and 3 ....then i delete 2 in table 1 ...i will have 1 and 3 in both table 1 and table 2....now i want 3 to become 2 in both table 1 and table 2...so that i dont have empty space between two student id's 1 and 3. so this is my problem....if any one can help me out with suggestions please do.
thank you........
ahmed_ind
November 11, 2005 at 4:19 pm
WHy is there an issue with having gaps in your student id?
You are creating a ton of additional logic and time keeping the numbers contiguous.
Note: Sql server does not "care" if the numbers are not contiguous. Sql does not lose efficiency, or this does not cause any problems.
If your numbers MUST be contiguous because of some deranged business reason than I would suggest you do not use this number as your Primary key value in the database. create an additional field on table 1 indicating StudentID, and keep it in only one place.
November 14, 2005 at 3:28 am
Ray is correct, a student ID should refer to one student only and forever.
In the real world, if someone dies, should I get a new social security number?
November 14, 2005 at 3:10 pm
hi,
i understand what mistake i am making....thank u for ur suggestion's ...it will be of great help for me.
--> ahmed
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply