Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-10-2007, 07:00 PM
Member
 
Join Date: Dec 2007
Posts: 1
varun_33 is on a distinguished road
Database Column vs String Concatenation
Hello freinds.....

Please tell me which out of the 2 solutions is a better solution and why?

PROBLEM
-----------
I need to store 2 values of String type in the database
Value1 - GUID
Value2 - Reference Number

Examples
Record1 : asdasdsadsa12345
Record2 : dggtghknklkll12345

where 12345 is the reference number and the remaining part of the value is the GUID.

Solution 1
-----------
I can concatenate both the strings and store that in one column in the database and make it the primary key.

Solution 2
------------
I can create 2 columns in the database and store both the values differently
Make GUID the primary key column and use the other column to store the Reference Number.


I feel solution 2 is better as solution 1 will force to concatenate string while creating a record and while retrieving a record substring will be required , which does not represent a good design.
Also, solution 2 will enable us to query the second column to retrive records efficiently.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 12-11-2007, 05:14 PM
Member
 
Join Date: Dec 2007
Location: New Delhi, India
Posts: 1
vip007 is on a distinguished road
Send a message via Yahoo to vip007
Solution 2 is better than solution 1. String operations are usually heavy for performance issues. Moreover if you want the combination as a primary key than you can make the primary key including both the columns. Moreover if you find at later stage that you need the combined string then also thr are queries which will return the results in appended form. Undoubtly go for solution 2.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel Column Gajesh Tripathi New To Java 2 04-13-2008 03:26 PM
Concatenation file contents Java Tip Java Tips 1 02-07-2008 02:29 PM
Inserting string with slash character into database Java Tip Java Tips 0 02-07-2008 09:57 AM
insert row and column and delete row and column daredavil82 New To Java 7 11-30-2007 11:32 AM
Performance Issues (String Concatenation) JavaForums Java Blogs 0 11-28-2007 06:00 PM


All times are GMT +3. The time now is 10:44 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org