Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 123»»»

Data type for Gender Expand / Collapse
Author
Message
Posted Thursday, September 15, 2005 3:37 PM


SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Thursday, January 13, 2011 7:55 PM
Points: 124, Visits: 12
What is the recommended datatype for Gender?
Post #220408
Posted Thursday, September 15, 2005 3:51 PM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Tuesday, August 12, 2014 2:32 PM
Points: 414, Visits: 2,890
could think of a few rather un pc answers but don't think that will help your database issue


Post #220412
Posted Thursday, September 15, 2005 4:31 PM
UDP Broadcaster

UDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP Broadcaster

Group: General Forum Members
Last Login: Wednesday, August 13, 2014 12:03 PM
Points: 1,480, Visits: 1,028

In reality its a boleean

so bit is fine just have to decide

0 = Male, 1 = Female
or 1 = Male, 0 = Female

How bout

Char(1)
M (Male)
F (Female)
U (Unknown)
B (Both)

Post #220423
Posted Thursday, September 15, 2005 4:49 PM


SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Thursday, January 13, 2011 7:55 PM
Points: 124, Visits: 12
Char(1) sound better. I think Boolean might give problems for NULL data.
Post #220428
Posted Thursday, September 15, 2005 4:49 PM


SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Thursday, January 13, 2011 7:55 PM
Points: 124, Visits: 12
Char(1) sound better. I think Boolean might give problems for NULL data.
Post #220429
Posted Friday, September 16, 2005 4:25 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Today @ 3:10 AM
Points: 2,867, Visits: 3,207
I would go for char(1).  Many poorer countries do not perform gender assignment surgery for those babies whose bits are not obvious. 

Original author: SQL Server FineBuild 1-click install and best practice configuration of SQL Server 2014, 2012, 2008 R2, 2008 and 2005. 28 July 2014: now over 30,000 downloads.
Disclaimer: All information provided is a personal opinion that may not match reality.
Concept: "Pizza Apartheid" - the discrimination that separates those who earn enough in one day to buy a pizza if they want one, from those who can not.
Post #220547
Posted Friday, September 16, 2005 6:21 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 4:04 AM
Points: 12,903, Visits: 31,967

i typically use a char(1) with a check constraint to allow only two values:

ie ALTER TABLE BLAH ADD GENDER CHAR(1) NULL CHECK (GENDER='M' OR GENDER='F')



Lowell

--There is no spoon, and there's no default ORDER BY in sql server either.
Actually, Common Sense is so rare, it should be considered a Superpower. --my son
Post #220593
Posted Friday, September 16, 2005 6:44 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Monday, June 23, 2014 7:56 AM
Points: 199, Visits: 57

varchar(1)

Null is unknown. That is the purpose of null.

>How bout

>Char(1)
>M (Male)
>F (Female)
>U (Unknown)
>B (Both)




Post #220600
Posted Friday, September 16, 2005 8:55 AM


SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Thursday, January 13, 2011 7:55 PM
Points: 124, Visits: 12
I see that char or varchar is recommended. Any reason to choose one over the other? What is the selection process to select char, varchar, nvarchar?
Post #220718
Posted Friday, September 16, 2005 9:00 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Monday, June 23, 2014 7:56 AM
Points: 199, Visits: 57
Because of my indoctrination by Oracle DBAs, I use varchar and never use char.  The reason for nvarchar would be for international character purposes.  I have never seen a compelling reason to use char.


Post #220722
« Prev Topic | Next Topic »

Add to briefcase 123»»»

Permissions Expand / Collapse