3

I was messing around with Kartris online shop and I was reading this definition for a product version(you have basic information of a product in one table and many versions of products wich can have different prices)

The most exact data types are decimal and numeric, don't they?, instead they are using real data type an approximated data type which can't represent some values decimal values.

I know this will store this range of values

  • 3.40E + 38 to -1.18E - 38, 0 and 1.18E - 38 to 3.40E + 38 and also know it's for performance lookup since they are searching by name and not by value which is a very smart design msdn states it's 20 times faster than other types like int and you have to have speacial treatment in lookups comparisons and less space in disk to storage values.

my concern is what if i want some math on these values will my Accountant complaint i've lost any money or cents or what escenarios will i encounter to get data truncated or wrong values? some scales won't be represented as exact as decimal or numeric but i want to know wich ones are the special ones.

USE [KartrisSQL716]
GO

/****** Object:  Table [dbo].[tblKartrisVersions]    Script Date: 12/17/2015 18:23:49 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[tblKartrisVersions](
    [V_ID] [bigint] IDENTITY(1,1) NOT NULL,
    [V_CodeNumber] [nvarchar](25) NULL,
    [V_ProductID] [int] NULL,
    [V_Price] [real] NULL,
    [V_Tax] [tinyint] NULL,
    [V_Weight] [real] NOT NULL,
    [V_DeliveryTime] [tinyint] NOT NULL,
    [V_Quantity] [real] NOT NULL,
    [V_QuantityWarnLevel] [real] NOT NULL,
    [V_Live] [bit] NOT NULL,
    [V_DownLoadInfo] [nvarchar](255) NULL,
    [V_DownloadType] [nvarchar](50) NULL,
    [V_OrderByValue] [smallint] NOT NULL,
    [V_RRP] [real] NOT NULL,
    [V_Type] [char](1) NULL,
    [V_CustomerGroupID] [smallint] NULL,
    [V_CustomizationType] [char](1) NOT NULL,
    [V_CustomizationDesc] [nvarchar](255) NULL,
    [V_CustomizationCost] [real] NOT NULL,
    [V_Tax2] [tinyint] NULL,
    [V_TaxExtra] [nvarchar](255) NULL,
 CONSTRAINT [Versions_PK] PRIMARY KEY NONCLUSTERED 
(
    [V_ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'n:NONE, i:Image, t:Text' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tblKartrisVersions', @level2type=N'COLUMN',@level2name=N'V_CustomizationType'
GO

ALTER TABLE [dbo].[tblKartrisVersions]  WITH CHECK ADD  CONSTRAINT [FK_tblKartrisVersions_tblKartrisProducts] FOREIGN KEY([V_ProductID])
REFERENCES [dbo].[tblKartrisProducts] ([P_ID])
GO

and constraints go on and on...

thank you in advance

  • 5
    Because some people don't know what they are doing – Neil McGuigan Dec 18 '15 at 4:01
  • 4
    If you want to know the exact reason they chose REAL, you'll have to ask them. If you want us to guess, you're not really going to like our answers, because mostly they'll point to them making a bad decision for reasons unknown. – Aaron Bertrand Dec 18 '15 at 4:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.