Jump to content

Recommended Posts

I am having problems with an addressbook table in my php/mysql application.

 

The problem I am having is that users with mysql 5 seem to be getting an foreign key constraint fails error but no one else does.

 

The table layout is as follows:

id   int(11) No 

user  int(11) No 0 

entered_by  int(11) No 0 

updated  timestamp No CURRENT_TIMESTAMP 

address  varchar(50) Yes NULL 

city  varchar(50) Yes NULL 

state  varchar(50) Yes NULL 

zip  varchar(10) Yes NULL 

home  varchar(20) Yes NULL 

work  varchar(20) Yes NULL 

cell  varchar(20) Yes NULL

 

I wanted user and entered_by to both be foreign keys that point to table members.userid.  It's been too long since my DB design classes, but I assume this isn't the right way to do this.  The user field would be used for the user that the address belongs to and entered_by would be used to show what member entered that address, because I want to allow members to enter addresses for other members or non-members.

 

Is there a better way to accomplish what I want?

 

Thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/107441-addressbook-table-design/
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.