Jump to content

[SOLVED] I messed up in the design of my DB...now I need a work-around


Recommended Posts

I have a table that is:

 

row_number - int 5 - primary - auto increment

team_name - varchar 200

week - int 2

miles - decimal 10,2

 

 

I didn't really need the row_number column...but figured that it couldn't hurt.  Now, I have teams entering miles multiple times for the same week.  I should have combined the team name and week into one column and made that the primary key.  Oh well...too late now.

 

Is there anyway to limit a team to entering miles walked just once each week in this db setup?

 

Maybe a php solution where if data exists for a week, it removes that week from the drop box?  That would work, but I have no idea how to write that (figure out which weeks exists--1 through 13--) and then echo the drop box accordingly.

 

If this doesn't make sense, let me know...I'll try to explain better.

 

Thanks!

phpmyadmin threw an error on unique for week...this is what the table could look like

 

team_name      week      miles

 

team xyz          1          112.21

team abc          1          77.6

team xyz          2          100.57

team abc          2          98

 

 

 

Hi

 

Had a play and it worked fine.

 

On the structure page for you table under indexes, put a 2 in the number of columns to add an index and click go. Type in an index name, change the drop down to "UNIQUE", and select the 2 columns from the drop down lists.

 

All the best

 

Keith

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.