Jump to content

how to struture my MYSQL database


pagegen

Recommended Posts

Hi guys

 

I am making a mysql (most uptodate version), php (v5) web application

 

I am making a system which allows multiple user types to login so we will have admin, user, affliates, and customers

 

I can create a table called members and enter all the records in there and have a field which determins what the user type is. The issue is some members i.e customers will have other fields like age, date of birth etc so they will be extra fields for admin, users and affliates

 

can someone please advice me on how they would do this

 

Link to comment
Share on other sites

To save a lot of work later use one table to list the people on your server. Have a auto increment column for user_id, then columns for their name(s), user name(?), password, status(admin, user, affliates, and customers) ... more.....  Also make columns for the extra info needed for the different statuses and make them able to be NULL. Then an admin does not need info in those columns. When someone logs in it's easy to checked their name and pass and then get all other info needed for the site.

Link to comment
Share on other sites

I was thinking one table named 'members' which stores fields like username, password, name and a 2nd table which extends members and has all the fields I need like age, etc which will not be needed in members then I can do an INNER JOIN

 

so somet like this

 

members:

id | name | username | password | user_type_id

 

members_customers:

member_id | age | sex | address

 

what do you guys think

Link to comment
Share on other sites

No problem pagegen. I also didn't mean to come across as use mine or else. I was just looking for some recognition, I guess and thought one query was better then two, but your don't need to use two. 

 

Using an inner join with your set up will work just as good as mine and will also be one command. If that structure makes more sense to you then use it.

Link to comment
Share on other sites

I was thinking one table named 'members' which stores fields like username, password, name and a 2nd table which extends members and has all the fields I need like age, etc which will not be needed in members then I can do an INNER JOIN

 

so somet like this

 

members:

id | name | username | password | user_type_id

 

members_customers:

member_id | age | sex | address

 

what do you guys think

 

That you are missing a few tables ;) No need though to separate age and sex from other member info.

 

members (member_id, group_id, member_firstname, member_lastname, member_username, member_password, member_age, member_sex)

addresses (member_id, address_id, address_type_id, address_street, address_number, ..)

address_types (address_type_id, address_type_name)

groups (group_id, group_name)

Link to comment
Share on other sites

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.