473,387 Members | 1,903 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

the datatype


hello !

I got some problems here. I have an attribute that determines the unit
of something,e.g. the size of using "mm" , the length of using "seconds"
and something others may using "n-page", so ,which data type should I
use. the "nvarchar" or others?
thank you very much!

*** Sent via Developersdex http://www.developersdex.com ***
May 17 '06 #1
4 1307
>> I have an attribute that determines the unit of something,e.g. the size of using "mm" , the length of using "seconds" and something others may using "n-page", so ,which data type should I use. the "nvarchar" or others? <<

You need to learn how a relational design works. What meaningful name
could you give such a column? "some_kind_of_unit" or "don't_know_unit"
or "could_be_anything" is a bit vague. Since seconds cannot be
transformed into volts, etc. this column is in violation of !NF -- it
holds several totally different things, like field in a file system.

Units of measure are part of an attribute's value, not an attribute.
You are confusing data and meta-data. Get of a copy of SQL PROGRAMMING
STYLE or SQL FOR SMARTIES and read the chapters on scales and
measurements, and the design of encoding schemes.

May 17 '06 #2
If you are just storing the description, eg...

mm
seconds
n-page

then I'd hold them using nvarchar and size it according to the maxium length
you expect, if its just the above then nvarchar(7).

If you are talking about the units themselves then i'd go down this
route....

create table unit_type (
id int not null identity constraint sk_unit_type unique clustered,
name nvarchar(7) not null constraint pk_unit_type primary key
nonclustered
)

create table measurement (
unit_type_id int not null references unit_type( id ),
unit decimal( 10, 5 ) not null
)

Hope that helps.

Tony.

--
Tony Rogerson
SQL Server MVP
http://sqlblogcasts.com/blogs/tonyrogerson - technical commentary from a SQL
Server Consultant
http://sqlserverfaq.com - free video tutorials
"John Kevien" <ke*********@163.com> wrote in message
news:mJ*************@news.uswest.net...

hello !

I got some problems here. I have an attribute that determines the unit
of something,e.g. the size of using "mm" , the length of using "seconds"
and something others may using "n-page", so ,which data type should I
use. the "nvarchar" or others?
thank you very much!

*** Sent via Developersdex http://www.developersdex.com ***

May 17 '06 #3
Just curious: why nvarchar instead of varchar?

"Tony Rogerson" <to**********@sqlserverfaq.com> wrote in message
news:e4*******************@news.demon.co.uk...
If you are just storing the description, eg...

mm
seconds
n-page

then I'd hold them using nvarchar and size it according to the maxium
length you expect, if its just the above then nvarchar(7).

If you are talking about the units themselves then i'd go down this
route....

create table unit_type (
id int not null identity constraint sk_unit_type unique
clustered,
name nvarchar(7) not null constraint pk_unit_type primary key
nonclustered
)

create table measurement (
unit_type_id int not null references unit_type( id ),
unit decimal( 10, 5 ) not null
)

Hope that helps.

Tony.

--
Tony Rogerson
SQL Server MVP
http://sqlblogcasts.com/blogs/tonyrogerson - technical commentary from a
SQL Server Consultant
http://sqlserverfaq.com - free video tutorials
"John Kevien" <ke*********@163.com> wrote in message
news:mJ*************@news.uswest.net...

hello !

I got some problems here. I have an attribute that determines the unit
of something,e.g. the size of using "mm" , the length of using "seconds"
and something others may using "n-page", so ,which data type should I
use. the "nvarchar" or others?
thank you very much!

*** Sent via Developersdex http://www.developersdex.com ***


May 17 '06 #4
Hi Neil,

Its the Microsoft recommendation for string data types, use the N (unicode)
versions, there are a few things that require unicode if you use SSIS too.

I'm finding it a hard habbit to get into!

Tony.

--
Tony Rogerson
SQL Server MVP
http://sqlblogcasts.com/blogs/tonyrogerson - technical commentary from a SQL
Server Consultant
http://sqlserverfaq.com - free video tutorials
"Neil" <no****@nospam.net> wrote in message
news:wp****************@newsread3.news.pas.earthli nk.net...
Just curious: why nvarchar instead of varchar?

"Tony Rogerson" <to**********@sqlserverfaq.com> wrote in message
news:e4*******************@news.demon.co.uk...
If you are just storing the description, eg...

mm
seconds
n-page

then I'd hold them using nvarchar and size it according to the maxium
length you expect, if its just the above then nvarchar(7).

If you are talking about the units themselves then i'd go down this
route....

create table unit_type (
id int not null identity constraint sk_unit_type unique
clustered,
name nvarchar(7) not null constraint pk_unit_type primary key
nonclustered
)

create table measurement (
unit_type_id int not null references unit_type( id ),
unit decimal( 10, 5 ) not null
)

Hope that helps.

Tony.

--
Tony Rogerson
SQL Server MVP
http://sqlblogcasts.com/blogs/tonyrogerson - technical commentary from a
SQL Server Consultant
http://sqlserverfaq.com - free video tutorials
"John Kevien" <ke*********@163.com> wrote in message
news:mJ*************@news.uswest.net...

hello !

I got some problems here. I have an attribute that determines the unit
of something,e.g. the size of using "mm" , the length of using "seconds"
and something others may using "n-page", so ,which data type should I
use. the "nvarchar" or others?
thank you very much!

*** Sent via Developersdex http://www.developersdex.com ***



May 17 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: Sanjay Minni | last post by:
What is the datatype to be used for Primary Key columns for most optimised access given that - There will be a single column primary key only - The values will only be integers (but as...
1
by: thepercival | last post by:
Hello, I have a stored procedure and the return data type is number(16) as you can see. but I get it back in the code as a var_numeric and then the precision depends on the value of the...
8
by: Eternally | last post by:
Hi folks, I've got a program which has a function which uses templates to accept parameters of any type. Works well, but there's one certain datatype which I want to special case and do an...
0
by: SoYouKnowBrig | last post by:
Hi All, I am using Microsoft.ApplicationBlocks.Cache.CacheManager to persist a System.Data.Dataset object. This Dataset object has a DataTable that is created from an existing DataTable using...
10
by: andrewcw | last post by:
I read in a earlier post that I can get the column of a grid to sort by datetime if the column type was set as Date I deserialize my XML and one attribute of the XSD has type as dateTime but upon...
3
by: Sri | last post by:
In VB, to know the field type of a column stored in a recordset the command I use is If rsQuery.Fields(k).Type = adCurrency Then How will I achieve the same in ASP.net. I could not find a...
1
by: Bryan | last post by:
I have a class called "Prop". I want that class to have a property called "DataType" where the user can select and store a datatype. How can I store a DataType value in a class property. how...
4
by: Orchid | last post by:
How can I change a Date datatype to a Number datatype? For example, I want a date 10/31/2006 to show 1031 as Number datatype. But I don't want it becomes 39021. What formula should I use? ...
0
by: graju80 | last post by:
I am kind of new to Db2... Question: What are the rules that DB2 uses to determine the right datatype for a particular column for on-the-fly SQL generation? For example...
11
by: BD | last post by:
Hi, all. I'm running 8.2 on Windows. This is a development platform for a project whose production environment is running on a mainframe. I believe that the RI compilation process is not...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.