Jump to content

Recommended Posts

I've found a potential future problem with my code. at present i have a teachers table and a lesson table. I have a teacher unique id which is their login id. for the lessons i just have it set to integer auto-increment. I was planning on letting the table automatically assign id's for the lesson upon adding a new row. however, ive thought of a potential problem which could be corrected using a prefix to the lesson id of the username. So far example

 

user = bob

 

  ID        Lesson            Teacher

bob1  =  english    =    Bob Smith

bob2  =  maths      =    Bob Smith

bob3  =  french    =    Bob Smith

 

user = Joe

 

  ID        Lesson          Teacher

joe1  =  english    =    joe Smith

joe2  =  maths      =    joe Smith

joe3  =  french    =    joe Smith

 

 

Rather than...

 

  ID    Lesson          Teacher

1  =  english    =    Bob Smith

2  =  maths      =    Bob Smith

3  =  french    =    Bob Smith

4  =  english    =    joe Smith

5  =  maths      =    joe Smith

6  =  french    =    joe Smith

 

 

How would i make this happen? As i mentioned above im currently using an auto-incrementing integer field for the ID.

Well, i've read that, and i do understand it. I've got my tables broken down in my opinion perfectly. The information i gave above is just a very basic stripped down example. I just need help on creating an id that consists of...

 

username(1)

username(2)

username(3)

.

.

.

.

.

.

username(9865056486)

 

etc...

 

 

It is, the example i gave (probably poorly explained) is just a hypothetical scenario and nothing to do with my actual site or database structure... It was just easier explaining it that way than 30 pages of writing to explain the real scenario... lol

yeah pretty much. the problem is that i am running a message table. the message can correspond to records on 1 of 5 different tables. each one of the 5 tables runs a primary id with the structure of auto-incrementing integer... however the message needs to display some of the information from the record. Now say for example we have got table A, B, C, D, E. Each table will have 10 rows so each will have existing primary ID's of 1-10. If a teacher receives a message and the message needs to contain information about record 3 from table E then there is nothing to distinguish that. If i run a search query to select all records where ID = 3 FROM tables A B C D E (i know this is not the correct syntax) then there are 5 records with the same primary id... do you get me? Although that primary ID might be unique to that table it won't be unique accross my database. where if i had the ID as A1, A2, A3, etc... or similar then it would be unique within my database.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.