Suggestions needed on structure

Codes here !

Moderators: egami, macek, gesf

Post Reply
Verbal
New php-forum User
New php-forum User
Posts: 1
Joined: Sat Nov 11, 2017 5:05 pm

Sat Nov 11, 2017 5:16 pm

I am getting back into coding after a 15 year absence.

I have about 50 users. Each user has about 60 vendor accounts. Each vendor has unique login and pw for each user. I want to create a list that each user can access the vendor list and show their unique login/pw for each vendor. Admin will be able to see user list.

EXAMPLE:
User01: Vendor 01 (login/pw), Vendor02 (login/pw), Vendor03 (login/pw)
Each vendor has global info such as phone number, website, etc. that do no change per user. Only the user login/pw changes per user.

Should I create a table for each of the users login/pw and a unique id that links to each vendor? I was thinking if I create one master table for login/pw it may slow it down? Thoughts?

User Table
UserID, FName, LName, PW, Email, Phone

Vendor Table
VendorID, Website, Phone, Contact, Email

PW Table UserX
UserID, VendorID, Login, PW

Is there a better way to do this?

User avatar
benanamen
New php-forum User
New php-forum User
Posts: 22
Joined: Mon Oct 16, 2017 1:06 pm

Sat Nov 18, 2017 9:56 am

The last table you call PW should not have Login and PW. You would use a join to get the info you want. There should be no reason to even get the password since you should not be storing it in plain text which I assume you are. You need to use password_hash and password_verify.

In this case, EVERYONE is a user, just some are vendors. You would need a is_vendor column in the users table.

You need to learn about Database Normalization. If you are repeating the same types of data across tables, your DB design is wrong.
The XY Problem
The XY problem is asking about your attempted solution (X) rather than your actual problem (Y). This leads to enormous amounts of wasted time and energy, both on the part of people asking for help, and on the part of those providing help.

Post Reply