Results 1 to 2 of 2
  1. #1
    varun_33 is offline Member
    Join Date
    Dec 2007
    Posts
    1
    Rep Power
    0

    Default 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.

  2. #2
    vip007 is offline Member
    Join Date
    Dec 2007
    Location
    New Delhi, India
    Posts
    1
    Rep Power
    0

    Default

    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.

Similar Threads

  1. insert row and column and delete row and column
    By daredavil82 in forum New To Java
    Replies: 13
    Last Post: 09-22-2011, 07:10 PM
  2. Excel Column
    By Gajesh Tripathi in forum New To Java
    Replies: 2
    Last Post: 04-13-2008, 03:26 PM
  3. Concatenation file contents
    By Java Tip in forum Java Tip
    Replies: 1
    Last Post: 02-07-2008, 02:29 PM
  4. Replies: 0
    Last Post: 02-07-2008, 09:57 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •