Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
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: Thursday, April 28, 2016 1:17 PM
Points: 415, Visits: 3,086
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: Monday, March 28, 2016 1:01 PM
Points: 1,487, Visits: 1,069

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
Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: 2 days ago @ 12:55 PM
Points: 3,008, Visits: 3,621
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 2016, 2014, 2012, 2008 R2, 2008 and 2005. 1 February 2016: now over 36,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: Yesterday @ 7:44 PM
Points: 14,198, Visits: 37,114

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

--
help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!
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, February 9, 2015 7:07 AM
Points: 199, Visits: 60

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, February 9, 2015 7:07 AM
Points: 199, Visits: 60
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