HELP Need to know how to structure MYSQL databases for CONTACT SIGNUP LOGIN HELP
Don't know too much about MySQL but I have managed to create a SIGN UP form and was able to save the input to a database.
NOW, I need to know how I should add the databases for the CONTACT FORM and LOGIN FORM.
Should I use the same database for all the forms and just add tables?
Should I create a separate database for all even though the sign up form and the login form use a few of the same fields? (email, password).
use same database if you are going to implement those forms in same project. just create different tables. also there can be atleast one same field so you can identify users. for example their email address
So use the same email field in all three tables?? Like the contact table will have a table named email, the login table will have a field named email, etc..
yes, you will find it easy at this level
There probably is not a one-to-one correlation between forms and DB tables. You probably want a "user" table with the info necessary to define a user, including login name and/or email address (should be unique), possibly an auto-incremented user_id to use as the primary key, then columns with any other user-specific data.
Then your various forms that deal with user info in any manner will access that single table (read it for login authorization, insert into it to add a new login account, update to change whether or not the user wants to receive email news, etc.).
Do you guys use PHPMyAdmin? How do you duplicate a table so I can just delete/modify/add some of the fields instead of recreating the entire table from scratch again??
I don't have phpMyAdmin at work (we use PostgreSQL), but you should be able to run the following from a SQL window (whatever phpMyAdmin calls it):
If you then want to copy all its data, to:
CREATE TABLE new_database.users LIKE old_database.users;
INSERT new_database.users SELECT * FROM old_database.users;
Wow thanks, that worked like a charm!
So is PostgreSQL used more in the industry? Also, how come every time I go to an interview they ask if I can do a table join? What exactly does this mean? The jobs I applied for were for entry level PHP coders.
PostgreSQL and MySQL are not all that different, in general. I'm not sure why PG was specifically selected where I work, though I understand there are some subtle licensing differences that may have played a part.
Table joins are an integral part of using a relational database. They allow you to query across multiple tables (even across multiple databases). As a simple(?) example, let's say you have "user" and "post" tables:
Now you want to display the latest post, along with the author's name:
user_id (int, primary key, auto-increment)
post_id (int, primary key, auto-increment)
user_id (int) -- indicates who did the posting
If that does not make sense, then it's time to start googling for tutorials and such on relational database design and normalization.
SELECT user.first_name, user.last_name, post.title, post.post_text
INNER JOIN user USING(user_id)
ORDER BY post.post_timestamp DESC
I'll have to read a tutorial..
By the way, is there an easy way for me to send the contact info stored in one of my databases to be emailed to me upon a user submitting it??
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)