Jump to content

Creating new table structure for extended user class


dgruetter

Recommended Posts

Hi. I am trying to restructure my PHP code into oop structure and now have developed an extended class called "vendor_user" from a base class "user."

 

The basic attributes in "User" will be id, email, password.

 

The extended class "vendor_user" will have vendor_id, info, phone_num, tagline, etc..

 

I was going to create two tables, one called "user" and one called "user_vendor."

 

Eventually I plan on adding another extended class "guest_user" with different attributes...

 

The way I was planning on entering vendors would be to first enter the vendor as a user and the take the id of the user table and do another insert into vendor_user using the "id" from user as a foreign key.

 

I have a few questions.

 

First, Would this be the best way to do this? My logic is all vendor_users would be users but not all users would be vendor_users.

 

Second, should I create a primary key on user_vendors (another id attribute perhaps) or should I just index the forign key vendor_id?

 

Any insights would be greatly appreciated.

 

Link to comment
Share on other sites

Thanks for the reply. I was actually going to include a type column, I forgot to add that. It makes sense. My question still remains on whether I should store the attributes unique to vendor in another table using the user id as a foreign key. Currently I have a foreign key in the vendor table called vendor_id (to be used for joins later in the game). But... I also have a field simply called id. This id field is the vendor tables primary id field. I was wonder if this was even needed or if I should just use the foreign key for indexing and sorting. I guess it doesn't hurt to have that extra primary key. I really need to brush up on my MYSQL skills. :)

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.