Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Contacts Address Book Schema - How to have 1 to many fields for data?

Tags:

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?

like image 366
Mith Avatar asked Jan 31 '10 12:01

Mith


1 Answers

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
like image 78
Pentium10 Avatar answered Nov 15 '22 06:11

Pentium10