Results 1 to 6 of 6

Thread: DB Field Types

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2000
    Posts
    86

    DB Field Types

    Hi

    This question is more to do with database design, something I`ve recently started.
    My question is... I have a form used as a front end to a SQL DB. The form controls what is entered into the database. It contains multiple radio buttons with text such as 'Small' 'Medium' 'Large'. At present if 'Small' is selected a value of 'Small' (string) is added to the DB. Would it be better to have each of these text values mapped to a value of type INT? ie. 'Small' = 1, 'Medium' = 2, 'Large' = 3 etc. So when 'Medium' is selected a value of '2 would be added rather than "Medium'. Would this result in faster query returns?

    Would like to know which would be the better way to go.
    Any help or advice would be appreciated.

    Thanks

    Kelly

  2. #2
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367
    I would use the Numbers, because you could use a control array for your option buttons.

    So lets say

    optBtn(1) is your small option
    optBtn(2) is your medium option
    optBtn(3) is your large option

    If you store the number in the DB so when you load the data back you can just use optbtn(rs.fields("field1").value = true.

    Hope this helps,

  3. #3
    Fanatic Member
    Join Date
    Aug 2001
    Location
    Connecticut
    Posts
    855
    I would use strings. A database should be designed so that it is independent of any front end application. A string is more readable and useful (suppose another app needs a list of the string values, what're you going to do, map it back from numbers to strings?).
    VB 6.0, Access, Sql server, Asp

  4. #4
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    Well ...

    Wherever possible, in such cases, use numbers.

    It will ease the job of writing queries, for one, as you don't have to type out long words, and no bother about the case.

    .
    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Sep 2000
    Posts
    86
    Thanks for your replies.

    I was thinking the best way would be to have a reference table within the database which links the values to the string of text.
    So, if someone selects 'Large', the program will go to the reference table and find 'Large' then select the int value linked with 'Large' and insert it into the record. This way it would not be limited to the front end??
    Secondly, I don`t really want the user to be able to understand the raw data in the database??

    I guess I`m just trying to weigh up adv and disadv. of each method.

    Thanks again

    Kelly

  6. #6
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    Well ...

    That is a good suggestion, but only when you require a large number of such options, and also want the user to customize it to suit his needs.

    .
    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

Posting Permissions

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



Click Here to Expand Forum to Full Width