tags:

views:

104

answers:

10
+1  A: 

Well, I might start by renaming "Id" and "type" - those aren't very descriptive. How about "ContactInfoID" and "ContactInfoType". The final field could then be reasonably titled "ContactInformation".

You're right that you shouldn't use a silly name like "emailOrPhoneOr...", because that prohibits you from storing additional types of contact information in the future.

Also consider that a tinyint is likely more than large enough for your "type" field, provided that your rdbms supports tinyints.

Aaron Alton
I'm using Id and ContactId because I'm using DTOs and LINQ which already name what it is (class name) and ContactInfo.ContactInfoId would then duplicate it. ContactInfo.Id is better.Regarding tinyint you're right, I'm actually using tinyint but didn't wnat to clutter up the example as it wouldn't be relevant to the question. Thanks anyways! Now I just need an answer on how to name THAT field that I asked about :)
Alex
Right, so are you OK with calling it "ContactInformation"? It's very descriptive, and clearly indicates what the field contains. I tend to be opposed to generic column names like "Value" or "Detail" and the like - they don't exactly explain what kind of value or detail you're looking at, and one could wrongly imply that the "Value" in this table relates to the "Value" in another table - which almost certainly would not be the case.
Aaron Alton
+3  A: 

I had a similar problem with a table at the sysytem I'm currently developing.

So we named the table ContactComplements and the field simply Value.

Paulo Santos
+1 I'd go with 'Value', plain, simple and serves the purpose.
Rashmi Pandit
+1  A: 

In the context of a Contacts table you can consider Detail for the field.

jerryjvl
A: 

I would just name it Contact. It's generic enough that it could apply regardless of the actual type of information contained therein but also implies that it's used for contacting someone.

Michael Todd
A: 

As you are maintaining key/value pairs that are associated with your CONTACT table, you could name it CONTACT_PROPERTIES. 'Value' would be as good a name as any for the field in question.

akf
+1  A: 

Ideally, when designing relational databases, you should avoid storing different types of information in the same field when possible.

One thing to consider, there are times where it makes sense to denormalize your data, you should may want to consider that in this situation. (see http://en.wikipedia.org/wiki/Denormalization)

At a minimum, I think it would make sense to use at least 2 tables, one for Email/IM and one for phone. For the email/IM table, add flags indicating if the address was Email or IM (or both if both flags set), as yahoo and others use email as the IM ID.

mikeh
+1  A: 
--table-per-class strategy:

--baseclass
table ContactItem
    column Id --pkey

--subclass
table ContactItemEmail
    column Id --pkey, fkey ContactItem.Id
    column Email

--subclass
table ContactItemPhone
    column Id --pkey, fkey ContactItem.Id
    column Phone
Justice
+1 this way you don't need to have an arbitrary limit on the length (e.g. 12 for the phone number, 255(?) for email, etc) and can even implement different validation constraints for each table, plus you no longer need a Type discriminator; only problem might be it would be tricky to enforce the fact that ContactItem must have exactly one ContactItemEmail or ContactItemPhone.
Jeffrey Kemp
+1  A: 

I'd name the table ContactDetails and the field ContactString.

Alex Martelli
A: 

MainContact

bobobobo
A: 

Presumably this is a free text element with no associated domain value validation i.e. user could type anything in here and it would be an acceptable value. In our data dictionary we tend to call these 'notes'.

onedaywhen