MySQL Database Setup
We have our user table set up but there is an issue with one of the columns. Can you guess what it is? It’s the username. With the user_id being the primary key we will always get a new unique row helped by the Auto_Increment option we set to it. However this does not take into account the username – at the present time the database will allow for multiple identical usernames.
You may think this would be checked by MySQL when a new user is registered but it doesn’t work like that (unfortunately). MySQL will only do as it is told based on the information you give it and we haven’t told it to do anything with the username (technically MySQL doesn’t do much more than store the data. To manipulate it we will be using PHP to tell MySQL what we want done.) so we want to change a setting in phpMyAdmin for the username. To do this, in the Structure tab click ‘More’ on the username row and select ‘Unique’
A confirmation will appear similar to figure 1.1. Just click Ok and you will see a little grey key icon appear next to the word ‘username’.
Now we will continue by setting up the other tables: photo, keyword, and photo_keyword.
Click on picaday in the window on the left column. You will notice the user table is showing, and under that a ‘Create new table’ area. In the table name enter photo, and the number of columns we require is 8. Now a window will be shown which is almost identical to the one we had for the user table (but with the extra rows!).
« Creating a Website – Part 8Coming soon…