First of all, I will explain the situation. Please read it carefully.
I am creating an java phonebook software. I created a database with fields Name, address, mobile1, mobile2, landPh1, landPh2, etc. After 90% completed, I decided to expand it functionalties. As a result of that, I started working with VCards, now that program can read VCards and add them to the DB. Then I decided to write VCards using the data stored in the database. Here, problem occurs!!
VCards don’t have field called “Name”, as I have in my software. Instead of that, they have “First Name”, “Last Name” and “Middle Name”. VCards don’t have “Address” as I have in my software too. They have “country”, “city” and “street address”. Now, how can I get these SEPARATE details???? I can get only the name, not the first, last etc. I can get only the address, not the country, city, etc. Now what can I do?????? Below are my suggestions
-
get the complete name. Set it to VCards “first name” field. You will have the complete name there. For address, add the complete address to VCard’s “Street Address” field.
-
Edit the database, alter it and add the missing fields. But then, the DB will look like this
firstName, Address, mobile1, mobile2, landPh1, landPh2, middleName, lastName, country, city
pretty messy, isn’t it?
I am unable to drop the table because lot of stuff has been created based on current format!! Changing it will take lot of time!!
I don’t know whether above suggestions are OK with good software engineering concepts. If you have a better way, I am glad to hear that too. Please help!!
You made a number of mistakes in your original database design. You should correct those mistakes at the earliest possible time as the longer you maintain the system with the design flaws the more difficult it will be to correct them later.
In short you need to:
Ensure that each column contains one and only one piece of information. That means separate columns for the parts of the name, separate columns for the parts of the address, etc.
You need to ensure that you are not storing multiple instances of the same item in a single record. That means creating a separate table for the phone numbers. Most likely this table will have three columns, an ID to point back to the contact person, a column for the phone number, and a description.
You will never be able to accurately “decode” 100% of the possible addresses and names.
You can read more about the rules for good database design by googling
database normalization.Don’t worry about the order of the columns in a table, or the records in the table. SQL does not contain a concept of default ordering, instead you order the columns and records as you want on retrieval.