views:

51

answers:

1

In Google Contacts, it seems that it allows you to many as many Email Address', Telephone numbers, Address', etc as you wish. You can simply keep clicking the add link to make as many fields as you want.

This makes me curious on how this is made in a schema?

A: 

There is a table that is named custom_fields (profileid,moduleid,fieldid,fieldlabel) there you define the fields eg: phone, dob, dogs, children then in another table custom_fields_values(contactid,fieldid,value) you set the values for each client/custom field.

custom_fields
-------------
user1,contacts,1000,Dogs
user1,contacts,1001,Children
user2,contacts,1002,Car Colour

custom_fields_values
-------------
120,1000,4
120,1001,0
121,1000,0
121,1001,0
122,1002,Red
123,1002,Transparent :)
124,1002,Green
Pentium10
How do these two tables link together, by using the ids?Then for the table contact, they store the custom field ids?
Mith
Contact table doesn't store any new ids or additional columns. These two tables link together by `fieldid`. Profileid means username, moduleid means the id of the module eg: contacts (as you can use these tables to store data for other tables too)
Pentium10