Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. Help with SQL Server (NOT A programming question) [modified]

Help with SQL Server (NOT A programming question) [modified]

Scheduled Pinned Locked Moved The Lounge
csharpdatabasewpfquestionsql-server
90 Posts 59 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M malharone

    :) .. it's not that bad! Our disagreement is on booleans. Though he wants me to textualize enums and store their text values as strings instead of storing the numeric representation. Currently, we don't use [flags] on enums and we are too scared of renaming the enum so it has been working out so far. Anyways, he's at a highler level than I am in the hierarchy of things so my voice has no opinion to the management. Furthermore, the "varchar" for boolean strangely made into the "SQL Standards" document in the company (before I joined) and even more strangely it got approved. So as of now, I look like a clueless idiot! This is so obvious, may be that's why I wasn't able to find any links. Any suggestion would be greatly helpful.

    J Offline
    J Offline
    jschell
    wrote on last edited by
    #74

    malharone wrote:

    Anyways, he's at a highler level than I am in the hierarchy of things so my voice has no opinion to the management. Furthermore, the "varchar" for boolean strangely made into the "SQL Standards" document in the company (before I joined) and even more strangely it got approved. So as of now, I look like a clueless idiot!

    Varchar for a boolean would always be wrong. The type should be char(1). So is it documented as char(1) or varchar(1). And if you have coding standards that specify a particular process and you have gotten to the point where you have obviously not followed the process then it demonstrates that the process is broken.

    1 Reply Last reply
    0
    • M Marco Turrini

      malharone wrote:

      Furthermore, the "varchar" for boolean strangely made into the "SQL Standards" document in the company

      1. Leave that company as soon as possible 2) Using char(1) for a boolean is stupid enough, but using varchar is even worse: varchars are introduced by two bytes used to specify the actual length of the data in the row, so a varchar(1) is actually consuming 3 bytes, not 1 as you would probably expect; on the other hand, bit fields use just 1 bit (and, if memory doesn't fail me, Sql Server can group them in bytes) 3) Using [var]char introduce wide possibilities for unnecessary errors and runtime exceptions.

      Marco Turrini

      J Offline
      J Offline
      jschell
      wrote on last edited by
      #75

      Marco Turrini wrote:

      1. Using char(1) for a boolean is stupid enough,

      Yet oddly enough many implementations use it quite successfully. Perhaps it is the users and not the idiom that is the problem.

      Marco Turrini wrote:

      1. Using [var]char introduce wide possibilities for unnecessary errors and runtime exceptions.

      You meant in terms of booleans and not in general correct? Given that the OP already mentioned that constraints are in use I can't see how there are going to be many problems introduced in the SQL code itself.

      M 1 Reply Last reply
      0
      • J Jeremy Fowler

        Wow, I think firing someone or leaving your job is a little overkill for this problem. I think you might have to look at this from the DBA or even the customer's point of view. I have no idea what the boolean field will be used for, but if the software your designing is the only thing accessing it, then you probably have a valid argument. However, if this field will be accessed from multiple applications - Crystal Reports, SQL Reporting Services, Analysis Services, Some Web App, etc.. - then you have to think about how it will look in those reports and applications. From your point of view, a 0 and 1 is pretty straight forward. However, from the customer's point a view a 0 or 1 does not look nice in a report. You have to take a step back and look at the big picture. Does the performance increase of using a binary datatype outweigh the readability of the data? How many rows of data are you expecting and how often will this field be accessed? These are all questions you need to ask. Speak with your DBA, if he has been there longer than you, he may know the reasons for doing it that way. Maybe the rest of you need to think through situations a bit more before jumping to conclusions based on so little information. I suppose its just too easy to judge people. -- modified at 11:10 Tuesday 11th September, 2007

        J Offline
        J Offline
        jschell
        wrote on last edited by
        #76

        Jeremy Fowler wrote:

        However, from the customer's point a view a 0 or 1 does not look nice in a report.

        Except the OP suggested that enums are stored as numerics. So those don't show up in reports? And certainly reporting tools in general allow values to be mapped either in SQL itself or even in the the supported report language so that wouldn't seem to be a problem to me.

        J 1 Reply Last reply
        0
        • P PIEBALDconsult

          " The Microsoft SQL Server 2005 Database Engine optimizes storage of bit columns. If there are 8 or less bit columns in a table, the columns are stored as 1 byte. If there are from 9 up to 16 bit columns, the columns are stored as 2 bytes, and so on. "

          malharone wrote:

          1. In HIS past projects, he used char(1) and no one complained

          Probably back before the advent of the bit type?

          J Offline
          J Offline
          jschell
          wrote on last edited by
          #77

          PIEBALDconsult wrote:

          The Microsoft SQL Server 2005 Database Engine optimizes storage of bit columns. If there are 8 or less bit columns in a table, the columns are stored as 1 byte. If there are from 9 up to 16 bit columns, the columns are stored as 2 bytes, and so on.

          Interesting. Which means in terms of performance that the bit must be extracted before doing any comparison. What happens if it is used in an index?

          1 Reply Last reply
          0
          • B BruceCarson

            Your DBA is correct - using a CHAR(1) is better than using a Bit field (sorry)!!! Here's the rationale: 1) Bit fields are not transportable - so when you move to Oracle you'll be able to do so with much less work. 2) Your CHAR(1) field can be marked as NULL (if desired). 3) Much easier for anyone querying the database with a non SQL-Server tool to get the results (go ahead and see what a product like Business Objects (or whatever it's called today) does with a bit field. 4) Bit fields are not part of the ANSI standard SQL. 5) Many CASE tools and Database Design tools do not support bit fields I disagree with your DBA on one point though! Limit the character to only the uppercase version of 'Y' or 'N' - even though SQL-Server is normally case-insensitive (unless you explicitly tell it not to be) many other database systems are not.

            J Offline
            J Offline
            jschell
            wrote on last edited by
            #78

            BruceCarson wrote:

            1. Your CHAR(1) field can be marked as NULL (if desired).

            At least in 2005 a bit field can allow nulls.

            1 Reply Last reply
            0
            • T timbailey

              Validation of the char(1) type will need to be performed (duplicated) in every tier of the application to make sure the app can make a boolean decision based on it. It needs to be Y, N and not null in every case. In my view, this is "harder" than using a boolean-compatible bit type as the database representation. Would you choose to put all your dates and numeric values in the database as char(n) fields? "The" application can only be a GUI for the database if two conditions exist. One is that all of the business logic exists only in the database. The other is that the application be the only app that uses the database. Business logic doesn't belong in your GUI. And T-SQL is not the most flexible tool around for handling business logic. But feel free to do whatever blows your skirt up. It's all ultimately bit values, no matter how you code it. Tim Bailey Energy Laboratories, Inc.

              J Offline
              J Offline
              jschell
              wrote on last edited by
              #79

              timbailey wrote:

              Validation of the char(1) type will need to be performed (duplicated) in every tier of the application to make sure the app can make a boolean decision based on it. It needs to be Y, N and not null in every case.

              Huh? What do you mean by "application"? Certainly in the stored procedures that would be true. But it hardly the case in in say the C# or Java code that was accessing it. If every "tier" in there is managing booleans via Y/N because the database is then there is something seriously wrong with the design of the application. And that problem has nothing to do with how booleans are implemented in the database itself.

              timbailey wrote:

              Would you choose to put all your dates and numeric values in the database as char(n) fields?

              Double huh? No language I know moves time values without conversion from the database to something else. In C# the precision of DateTime doesn't even match that of the equivalent SQL Server value. Using a string would allow one to preserve that. And what are you going to do if you want to preserve the time zone which SQL Server has absolutely zero support for? If you are unfortunate enough to be using C# it doesn't support timezones either so you would have no choice but to either use unmanaged code or to use a text field in some form.

              1 Reply Last reply
              0
              • A AKAJamie

                My name is Jamie Haddock. I helped Jeffrey Richter with the creation of 'CLR via C#" (Microsoft Press - See acknowledgement section of book). It concerns me deeply to hear about your situation. And it concerns me even more to hear the choices your DBA has made for the variable types your application uses. Based on what you have stated regarding the uncooperative nature of your DBA, I recommend you review your application's SQL DB requirements with your management and let them decide how best to deal with the DBA. You sound like your understand what you are talking about. Explain it to your management. If they disagree with you then you'll have to decide if you want to remain in that work environment.

                J Offline
                J Offline
                jschell
                wrote on last edited by
                #80

                AKAJamie wrote:

                My name is Jamie Haddock. I helped Jeffrey Richter with the creation of 'CLR via C#" (Microsoft Press - See acknowledgement section of book). It concerns me deeply to hear about your situation. And it concerns me even more to hear the choices your DBA has made for the variable types your application uses. Based on what you have stated regarding the uncooperative nature of your DBA, I recommend you review your application's SQL DB requirements with your management and let them decide how best to deal with the DBA.

                Did you see the post that indicated that the OP's organization has specifically documented the standards for databases and where it states what those specific standards are? And that obviously those standards have not been followed. To me that suggests that the process of the company is either flawed or that some group of cowboy programmer(s) have be avoiding the process. In either case neither case is it a matter of the DBA versus the programmer but rather one of what exactly the company is doing and is supposed to be doing in terms of process control.

                1 Reply Last reply
                0
                • J jschell

                  Marco Turrini wrote:

                  1. Using char(1) for a boolean is stupid enough,

                  Yet oddly enough many implementations use it quite successfully. Perhaps it is the users and not the idiom that is the problem.

                  Marco Turrini wrote:

                  1. Using [var]char introduce wide possibilities for unnecessary errors and runtime exceptions.

                  You meant in terms of booleans and not in general correct? Given that the OP already mentioned that constraints are in use I can't see how there are going to be many problems introduced in the SQL code itself.

                  M Offline
                  M Offline
                  Marco Turrini
                  wrote on last edited by
                  #81

                  jschell wrote:

                  Yet oddly enough many implementations use it quite successfully.

                  They used to say the same for years expressed with two digits. Of course the problem is the user: the fact is you can't be assured your user (and I mean either the developer and the end user) are educated enough. Using a [var]char lets doors open for a end user or a developer to write "dirty" values: who said that the only two chars are to be 'Y'es and 'N'o; in Italy we say 'S'i and 'N'o, in France they say 'O'ui and 'N'on, in Germany 'J'a and 'N'ein, in Russia 'D'a and 'N'iet (I think) Why only 'Y' should be used for the True value? If you think this is irrilevant, I'm writing right now an application which is already shipped in Italian/Italy and will be in German/Italy and French/Algeria

                  jschell wrote:

                  Given that the OP already mentioned that constraints are in use I can't see how there are going to be many problems introduced in the SQL code itself.

                  Because you can't assume that nobody will ever access data with something else than your application (the Business Logic you implemented in your OP application). Besides Microsoft ones, at least two free tools come to my mind which let you access directly data. To avoid this, you have to implement several procedures; among these is the correct use of the proper data type. That said, of course there are lot of applications which use char to store boolean value. As far as I am concerned, they can store everything as [var]char: boolean, dates, enums, timestamps and currency values... it's someone else's database and application, and I will not have to mantain it, nor wish to.

                  Marco Turrini

                  J 1 Reply Last reply
                  0
                  • J Jeremy Fowler

                    Wow, I think firing someone or leaving your job is a little overkill for this problem. I think you might have to look at this from the DBA or even the customer's point of view. I have no idea what the boolean field will be used for, but if the software your designing is the only thing accessing it, then you probably have a valid argument. However, if this field will be accessed from multiple applications - Crystal Reports, SQL Reporting Services, Analysis Services, Some Web App, etc.. - then you have to think about how it will look in those reports and applications. From your point of view, a 0 and 1 is pretty straight forward. However, from the customer's point a view a 0 or 1 does not look nice in a report. You have to take a step back and look at the big picture. Does the performance increase of using a binary datatype outweigh the readability of the data? How many rows of data are you expecting and how often will this field be accessed? These are all questions you need to ask. Speak with your DBA, if he has been there longer than you, he may know the reasons for doing it that way. Maybe the rest of you need to think through situations a bit more before jumping to conclusions based on so little information. I suppose its just too easy to judge people. -- modified at 11:10 Tuesday 11th September, 2007

                    M Offline
                    M Offline
                    Marco Turrini
                    wrote on last edited by
                    #82

                    Jeremy Fowler wrote:

                    However, from the customer's point a view a 0 or 1 does not look nice in a report. You have to take a step back and look at the big picture.

                    Please, don't misunderstand me but, just looking at the big picture, I can assure you that a char field is not necesseraly clearer to an end user than a bit one. I'm working with Italian, French, German and Arabic speaking end user and to very little of them a 'Y' would be a readable representation of a True value: you can't assume they studied English at school (e.g., in Italy a stident can study English or French) and anyway you can't bet they really know English (maybe it was centuries ago...); some of them would also be offended that my db doesn't allow them to store their national True value, but that's - partially - another story; a 0 or 1 field is much more ... neutral and doesn't leave room for misunderstanding or errors (once you have trained them, of course). As someone else stated, even enum values are stored as integer... or are you going to store their description? I don't think so...

                    Marco Turrini

                    J J 2 Replies Last reply
                    0
                    • J jschell

                      Jeremy Fowler wrote:

                      However, from the customer's point a view a 0 or 1 does not look nice in a report.

                      Except the OP suggested that enums are stored as numerics. So those don't show up in reports? And certainly reporting tools in general allow values to be mapped either in SQL itself or even in the the supported report language so that wouldn't seem to be a problem to me.

                      J Offline
                      J Offline
                      Jeremy Fowler
                      wrote on last edited by
                      #83

                      jschell wrote:

                      Except the OP suggested that enums are stored as numerics. So those don't show up in reports?

                      Actually, the author said this in a latter post:

                      malharone wrote:

                      Though he wants me to textualize enums and store their text values as strings instead of storing the numeric representation.

                      Since he wants him to stored the text values as strings, this would fall inline with the requirements of easy to read reports.

                      jschell wrote:

                      And certainly reporting tools in general allow values to be mapped either in SQL itself or even in the the supported report language so that wouldn't seem to be a problem to me.

                      His company may require their customers to write their own reports. They may even provide some basic reporting utility to do this that might not have some of the advanced functions of Crystal or some of the other advanced reporting engines. Its a lot easier for a novice user to drag a field onto a report than have to resort to advanced features like functions to map a bit value to a readable format. The point I was trying to make is that we don't know the circumstances that already exist in this situation. There could be many reasons why someone would need to use a char datatype rather than a bit.

                      1 Reply Last reply
                      0
                      • M Marco Turrini

                        Jeremy Fowler wrote:

                        However, from the customer's point a view a 0 or 1 does not look nice in a report. You have to take a step back and look at the big picture.

                        Please, don't misunderstand me but, just looking at the big picture, I can assure you that a char field is not necesseraly clearer to an end user than a bit one. I'm working with Italian, French, German and Arabic speaking end user and to very little of them a 'Y' would be a readable representation of a True value: you can't assume they studied English at school (e.g., in Italy a stident can study English or French) and anyway you can't bet they really know English (maybe it was centuries ago...); some of them would also be offended that my db doesn't allow them to store their national True value, but that's - partially - another story; a 0 or 1 field is much more ... neutral and doesn't leave room for misunderstanding or errors (once you have trained them, of course). As someone else stated, even enum values are stored as integer... or are you going to store their description? I don't think so...

                        Marco Turrini

                        J Offline
                        J Offline
                        Jeremy Fowler
                        wrote on last edited by
                        #84

                        Well, we don't know if his company is an international company. They may only make an English version of the product and only sell to clients in the US. Also, the author did say in a later post that they store the text value of enums as strings.

                        malharone wrote:

                        Though he wants me to textualize enums and store their text values as strings instead of storing the numeric representation.

                        1 Reply Last reply
                        0
                        • M Marco Turrini

                          jschell wrote:

                          Yet oddly enough many implementations use it quite successfully.

                          They used to say the same for years expressed with two digits. Of course the problem is the user: the fact is you can't be assured your user (and I mean either the developer and the end user) are educated enough. Using a [var]char lets doors open for a end user or a developer to write "dirty" values: who said that the only two chars are to be 'Y'es and 'N'o; in Italy we say 'S'i and 'N'o, in France they say 'O'ui and 'N'on, in Germany 'J'a and 'N'ein, in Russia 'D'a and 'N'iet (I think) Why only 'Y' should be used for the True value? If you think this is irrilevant, I'm writing right now an application which is already shipped in Italian/Italy and will be in German/Italy and French/Algeria

                          jschell wrote:

                          Given that the OP already mentioned that constraints are in use I can't see how there are going to be many problems introduced in the SQL code itself.

                          Because you can't assume that nobody will ever access data with something else than your application (the Business Logic you implemented in your OP application). Besides Microsoft ones, at least two free tools come to my mind which let you access directly data. To avoid this, you have to implement several procedures; among these is the correct use of the proper data type. That said, of course there are lot of applications which use char to store boolean value. As far as I am concerned, they can store everything as [var]char: boolean, dates, enums, timestamps and currency values... it's someone else's database and application, and I will not have to mantain it, nor wish to.

                          Marco Turrini

                          J Offline
                          J Offline
                          jschell
                          wrote on last edited by
                          #85

                          Marco Turrini wrote:

                          They used to say the same for years expressed with two digits.

                          Interesting analogy which is really a bad one. Unless you are suggesting that true and false is going to "grow" in to a tri-state value. But of course a char field could handle that where a bit couldn't.

                          Marco Turrini wrote:

                          If you think this is irrilevant, I'm writing right now an application which is already shipped in Italian/Italy and will be in German/Italy and French/Algeria

                          First if you are talking about display values, such as in a GUI, then there is something wrong with your design. Secondly, are you claiming that every single value in your database is written in such a way that it is appropriate for other languages? How do you use enumerations? With a mapping table presumably. Which obviously would work with a char(1) as well and would be absolutely required for a bit field. And what happens in Italy when someone from France uses it in Italy? Is the Italian version of the MS SQL Server going to display the 'bit' in French? Perhaps by reading the mind of the user as they type at the keyboard? If you want to internationalize a product I suggest you start at the user interface and not attempt it at the instrinic data level.

                          Marco Turrini wrote:

                          Because you can't assume that nobody will ever access data with something else than your application (the Business Logic you implemented in your OP application). Besides Microsoft ones, at least two free tools come to my mind which let you access directly data. To avoid this, you have to implement several procedures; among these is the correct use of the proper data type.

                          What are you talking about? Unless you go spelunking through the binary files of the database your statement is pointless. I don't care how you access it the constraints will still be enforced. I can only guess that you are suggesting that the data type is propogated throughout an appplication - which is a poor practice that has nothing at all to do with bit/char.

                          M 1 Reply Last reply
                          0
                          • M Marco Turrini

                            Jeremy Fowler wrote:

                            However, from the customer's point a view a 0 or 1 does not look nice in a report. You have to take a step back and look at the big picture.

                            Please, don't misunderstand me but, just looking at the big picture, I can assure you that a char field is not necesseraly clearer to an end user than a bit one. I'm working with Italian, French, German and Arabic speaking end user and to very little of them a 'Y' would be a readable representation of a True value: you can't assume they studied English at school (e.g., in Italy a stident can study English or French) and anyway you can't bet they really know English (maybe it was centuries ago...); some of them would also be offended that my db doesn't allow them to store their national True value, but that's - partially - another story; a 0 or 1 field is much more ... neutral and doesn't leave room for misunderstanding or errors (once you have trained them, of course). As someone else stated, even enum values are stored as integer... or are you going to store their description? I don't think so...

                            Marco Turrini

                            J Offline
                            J Offline
                            jschell
                            wrote on last edited by
                            #86

                            Marco Turrini wrote:

                            Please, don't misunderstand me but, just looking at the big picture, I can assure you that a char field is not necesseraly clearer to an end user than a bit one. I'm working with Italian, French, German and Arabic speaking end user and to very little of them a 'Y' would be a readable representation of a True value: you can't assume they studied English at school (e.g., in Italy a stident can study English or French) and anyway you can't bet they really know English (maybe it was centuries ago...); some of them would also be offended that my db doesn't allow them to store their national True value, but that's - partially - another story; a 0 or 1 field is much more ... neutral and doesn't leave room for misunderstanding or errors (once you have trained them, of course). As someone else stated, even enum values are stored as integer... or are you going to store their description? I don't think so...

                            Interesting argument. However that entire argument is a marketing/business decision. NOT a technology one. So if you are concerned that customers might be offended by data in the database then marketing/business needs to drive that decision down to the technology level. And it is not and never will be a decision that a developer (in a company with marketing/sales) will or should make. Regardless of whether they are a DBA or not. Naturally one won't find a technological posting that supports that either.

                            1 Reply Last reply
                            0
                            • J jschell

                              Marco Turrini wrote:

                              They used to say the same for years expressed with two digits.

                              Interesting analogy which is really a bad one. Unless you are suggesting that true and false is going to "grow" in to a tri-state value. But of course a char field could handle that where a bit couldn't.

                              Marco Turrini wrote:

                              If you think this is irrilevant, I'm writing right now an application which is already shipped in Italian/Italy and will be in German/Italy and French/Algeria

                              First if you are talking about display values, such as in a GUI, then there is something wrong with your design. Secondly, are you claiming that every single value in your database is written in such a way that it is appropriate for other languages? How do you use enumerations? With a mapping table presumably. Which obviously would work with a char(1) as well and would be absolutely required for a bit field. And what happens in Italy when someone from France uses it in Italy? Is the Italian version of the MS SQL Server going to display the 'bit' in French? Perhaps by reading the mind of the user as they type at the keyboard? If you want to internationalize a product I suggest you start at the user interface and not attempt it at the instrinic data level.

                              Marco Turrini wrote:

                              Because you can't assume that nobody will ever access data with something else than your application (the Business Logic you implemented in your OP application). Besides Microsoft ones, at least two free tools come to my mind which let you access directly data. To avoid this, you have to implement several procedures; among these is the correct use of the proper data type.

                              What are you talking about? Unless you go spelunking through the binary files of the database your statement is pointless. I don't care how you access it the constraints will still be enforced. I can only guess that you are suggesting that the data type is propogated throughout an appplication - which is a poor practice that has nothing at all to do with bit/char.

                              M Offline
                              M Offline
                              Marco Turrini
                              wrote on last edited by
                              #87

                              jschell wrote:

                              Interesting analogy which is really a bad one. Unless you are suggesting that true and false is going to "grow" in to a tri-state value.

                              Stretching too much it's meaning, a tri-state could be handled by allowing null values; but I actually would never do that. The analogy referred to the fact that "it's always been like this" isn't a really string argument, IN MY PERSONAL AND HUMBLE OPINION, of course. But anyone is free to act as he likes, unless he hurts someone [else?]. There are lot of applications happily using char representation of data, some store directly the entire description of the enumeration or foreign keys (I've also seen date stored as char in the ISO format for sorting reason).

                              jschell wrote:

                              First if you are talking about display values, such as in a GUI, then there is something wrong with your design.

                              You can take for granted, but maybe for other reasons, since I think I didn't express properly: 1) If I need to display "custom" values, I use a foreign key on another table; what I call enumerations are values which are invariant, regardless of the culture: just as a very quick example I may have an enumeration which tells me if it's an invoice or a refund to guide the flow of the program; then I have a separate table to store descriptive values for documents: I may have several types of invoices with different description, all of type 0=Invoice, refunds of type 1, and so on (it's just a quick example, not a full analysis). In the terminology we use in our company enumerations are NOT stored anywhere - but we use this terminology just to clearly tell them from foreign table; they are usually shown - if they really are - just in applications accessed only to higly trained staff, usually ourselves (trained on our application, I mean, not generally, of course) . 2) I'm not claiming that every single value in my database is written in such a way that it is appropriate for other languages; my attempt is to avoid to be tied to a particular language/culture in the database

                              jschell wrote:

                              Is the Italian version of the MS SQL Server going to display the 'bit' in French?

                              Mais ouis, with a very naive accent:-D Of course, not, it shows just 0 and 1. But what happens in Italy when someone from France uses a char(1) in Italy, to see her O(uis) refused by the Italian constraint applied by the dba

                              J 1 Reply Last reply
                              0
                              • M Marco Turrini

                                jschell wrote:

                                Interesting analogy which is really a bad one. Unless you are suggesting that true and false is going to "grow" in to a tri-state value.

                                Stretching too much it's meaning, a tri-state could be handled by allowing null values; but I actually would never do that. The analogy referred to the fact that "it's always been like this" isn't a really string argument, IN MY PERSONAL AND HUMBLE OPINION, of course. But anyone is free to act as he likes, unless he hurts someone [else?]. There are lot of applications happily using char representation of data, some store directly the entire description of the enumeration or foreign keys (I've also seen date stored as char in the ISO format for sorting reason).

                                jschell wrote:

                                First if you are talking about display values, such as in a GUI, then there is something wrong with your design.

                                You can take for granted, but maybe for other reasons, since I think I didn't express properly: 1) If I need to display "custom" values, I use a foreign key on another table; what I call enumerations are values which are invariant, regardless of the culture: just as a very quick example I may have an enumeration which tells me if it's an invoice or a refund to guide the flow of the program; then I have a separate table to store descriptive values for documents: I may have several types of invoices with different description, all of type 0=Invoice, refunds of type 1, and so on (it's just a quick example, not a full analysis). In the terminology we use in our company enumerations are NOT stored anywhere - but we use this terminology just to clearly tell them from foreign table; they are usually shown - if they really are - just in applications accessed only to higly trained staff, usually ourselves (trained on our application, I mean, not generally, of course) . 2) I'm not claiming that every single value in my database is written in such a way that it is appropriate for other languages; my attempt is to avoid to be tied to a particular language/culture in the database

                                jschell wrote:

                                Is the Italian version of the MS SQL Server going to display the 'bit' in French?

                                Mais ouis, with a very naive accent:-D Of course, not, it shows just 0 and 1. But what happens in Italy when someone from France uses a char(1) in Italy, to see her O(uis) refused by the Italian constraint applied by the dba

                                J Offline
                                J Offline
                                jschell
                                wrote on last edited by
                                #88

                                Marco Turrini wrote:

                                Mais ouis, with a very naive accent Of course, not, it shows just 0 and 1. But what happens in Italy when someone from France uses a char(1) in Italy, to see her O(uis) refused by the Italian constraint applied by the dba

                                I believe you are missing the point. Data exists in three forms. 1. Application 2. User 3. Mixed. Application data is something that the user should never see. Does your delivery consist of nothing but SQL? Or is there C++/C#/Java/etc code? If something besides SQL then either it does not matter how you implement the boolean or there is seriously something wrong with your implentation. User data is that data that the user types in and which never impacts the functional flow (based on the data itself). When a user types in a customer name that is user data. You application doesn't make a functional flow decision on whether the customer's name is Fred or Francois. Mixed data is data that, due to BUSINESS NEEDS, is exposed to the customer yet impacts functional flow. If your application has a text box that allows the user to enter SQL then that could be consider a mixed view. And in that case would you expect "SELECT" to be required to be displayed in different languages? (I doubt ANSI-SQL does.) So far nothing you have said suggests that the booleans are anything but application data. Now if your deliverable is ONLY SQL and no other code then that might be of concern. Or if a marketing need drove this decision then that would be relevant as well. Other than that you are dealing with Application data. And you do NOT make application data language specific. It is vastly inefficient and is pointless. And arguing that somemone might see it is pointless - someone might decompile the code or might even purchase the source code but I doubt that you are putting comments your code in 50 different languages. And if you really are delivering just SQL and nothing else then an obviously solution would be to run the code base through an automatic processor to make it language specific. That would deal with all issues (which there would certainly be more than just boolean values.)

                                Marco Turrini wrote:

                                1. I'd suggest you exactly the opposite, using n[var]char over [var]char and choosing carefully the collation, just to start off, or you could dive in some troubles.

                                Do you really think that no one has created language indepent applica

                                M 1 Reply Last reply
                                0
                                • J jschell

                                  Marco Turrini wrote:

                                  Mais ouis, with a very naive accent Of course, not, it shows just 0 and 1. But what happens in Italy when someone from France uses a char(1) in Italy, to see her O(uis) refused by the Italian constraint applied by the dba

                                  I believe you are missing the point. Data exists in three forms. 1. Application 2. User 3. Mixed. Application data is something that the user should never see. Does your delivery consist of nothing but SQL? Or is there C++/C#/Java/etc code? If something besides SQL then either it does not matter how you implement the boolean or there is seriously something wrong with your implentation. User data is that data that the user types in and which never impacts the functional flow (based on the data itself). When a user types in a customer name that is user data. You application doesn't make a functional flow decision on whether the customer's name is Fred or Francois. Mixed data is data that, due to BUSINESS NEEDS, is exposed to the customer yet impacts functional flow. If your application has a text box that allows the user to enter SQL then that could be consider a mixed view. And in that case would you expect "SELECT" to be required to be displayed in different languages? (I doubt ANSI-SQL does.) So far nothing you have said suggests that the booleans are anything but application data. Now if your deliverable is ONLY SQL and no other code then that might be of concern. Or if a marketing need drove this decision then that would be relevant as well. Other than that you are dealing with Application data. And you do NOT make application data language specific. It is vastly inefficient and is pointless. And arguing that somemone might see it is pointless - someone might decompile the code or might even purchase the source code but I doubt that you are putting comments your code in 50 different languages. And if you really are delivering just SQL and nothing else then an obviously solution would be to run the code base through an automatic processor to make it language specific. That would deal with all issues (which there would certainly be more than just boolean values.)

                                  Marco Turrini wrote:

                                  1. I'd suggest you exactly the opposite, using n[var]char over [var]char and choosing carefully the collation, just to start off, or you could dive in some troubles.

                                  Do you really think that no one has created language indepent applica

                                  M Offline
                                  M Offline
                                  Marco Turrini
                                  wrote on last edited by
                                  #89

                                  jschell wrote:

                                  I believe you are missing the point.

                                  And I believe you are missing the point, the starting one, to be precise. I replied to Jeremy Fowler who stated that, looking at the big picture, a 'Y' or 'N' value is more understandable from the end-user point of view when printing reports. It wasn't me the one who suggested that boolean value where input and shown directly to the end-user. I just argued that one should not show directly boolean values (and someone else added enum values) to the end-user, for reasons I won't repeat. Although I appreciated your thouroghly lesson above, I can't understand what this has to do with defending the use of a char data type for boolean value: if you like it, you can use char data type in your database to express anything (date, currency, integer); then there's a layer which converts database data to the correct application data (and type). But if I have such a layer, why shouldn't I use a bit data type in the database to express boolean values? Much more than your lesson (with which - believe it or not - I agree much more than you think, but I suspect that we have seriuos communication problems), I find that using a char(1) could be preferable just in two circumstances: 1) you have to mantain the application in a database which doesn't support bit data type (someone else cited Oracle); but if you use a data access layer (call it ORM or whatever you like), this shouldn't be a real issue. 2) you want to build an index based on that value; but you may incur in a severe performance paylod.

                                  Marco Turrini

                                  J 1 Reply Last reply
                                  0
                                  • M Marco Turrini

                                    jschell wrote:

                                    I believe you are missing the point.

                                    And I believe you are missing the point, the starting one, to be precise. I replied to Jeremy Fowler who stated that, looking at the big picture, a 'Y' or 'N' value is more understandable from the end-user point of view when printing reports. It wasn't me the one who suggested that boolean value where input and shown directly to the end-user. I just argued that one should not show directly boolean values (and someone else added enum values) to the end-user, for reasons I won't repeat. Although I appreciated your thouroghly lesson above, I can't understand what this has to do with defending the use of a char data type for boolean value: if you like it, you can use char data type in your database to express anything (date, currency, integer); then there's a layer which converts database data to the correct application data (and type). But if I have such a layer, why shouldn't I use a bit data type in the database to express boolean values? Much more than your lesson (with which - believe it or not - I agree much more than you think, but I suspect that we have seriuos communication problems), I find that using a char(1) could be preferable just in two circumstances: 1) you have to mantain the application in a database which doesn't support bit data type (someone else cited Oracle); but if you use a data access layer (call it ORM or whatever you like), this shouldn't be a real issue. 2) you want to build an index based on that value; but you may incur in a severe performance paylod.

                                    Marco Turrini

                                    J Offline
                                    J Offline
                                    jschell
                                    wrote on last edited by
                                    #90

                                    Marco Turrini wrote:

                                    And I believe you are missing the point, the starting one, to be precise. I replied to Jeremy Fowler

                                    I could have sworn, that your original point, was the following....

                                    Marco Turrini wrote:

                                    1. Using char(1) for a boolean is stupid enough, ... 3) Using [var]char introduce wide possibilities for unnecessary errors and runtime exceptions.

                                    I don't see anything that qualifies that statement with something about reports that export those values directly.

                                    Marco Turrini wrote:

                                    Although I appreciated your thouroghly lesson above, I can't understand what this has to do with defending the use of a char data type for boolean value:

                                    In point of fact I don't really see why it matters whether one chooses one or the other. Either can lead to problems when used incorrectly. When used correctly neither will.

                                    Marco Turrini wrote:

                                    But if I have such a layer, why shouldn't I use a bit data type in the database to express boolean values?

                                    And why should insist on using a bit type and assert that the alternative is contemptible (which 'stupid' suggests.)

                                    Marco Turrini wrote:

                                    I find that using a char(1) could be preferable just in two circumstances:

                                    And as far as I can see the only arguments for that point of view are one of the following: 1. A very, very limited market segment which should be driven by marketing not technological reasons. 2. A very, very flawed architecture which requires that data types flow throughout the system.

                                    1 Reply Last reply
                                    0
                                    Reply
                                    • Reply as topic
                                    Log in to reply
                                    • Oldest to Newest
                                    • Newest to Oldest
                                    • Most Votes


                                    • Login

                                    • Don't have an account? Register

                                    • Login or register to search.
                                    • First post
                                      Last post
                                    0
                                    • Categories
                                    • Recent
                                    • Tags
                                    • Popular
                                    • World
                                    • Users
                                    • Groups