Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
Database Design
»
Design Ideas and Questions
»
Storing Negative Numbers
38 posts, Page 1 of 4
1
2
3
4
»
»»
Storing Negative Numbers
Rate Topic
Display Mode
Topic Options
Author
Message
tymberwyld
tymberwyld
Posted Monday, November 10, 2008 6:14 AM
SSC Veteran
Group: General Forum Members
Last Login: Saturday, February 02, 2013 8:21 AM
Points: 283,
Visits: 268
Along with a lot of other horrible decisions, I am now not allowed to use Negative numbers in any database design. Instead, I need to add another column (ex. Operator) which tells whomever that the data in the amount column is either Positive or Negative. Huh? Is there something I missed during my last 10 years designing databases?
Post #599801
GilaMonster
GilaMonster
Posted Monday, November 10, 2008 6:18 AM
SSC-Dedicated
Group: General Forum Members
Last Login: Today @ 4:15 PM
Points: 37,651,
Visits: 29,903
Do they have a reason for this decision?
Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild
: Discussions on DB performance with occasional diversions into recoverability
We walk in the dark places no others will enter
We stand on the bridge and no one may pass
Post #599804
Ronald H
Ronald H
Posted Monday, November 10, 2008 6:18 AM
Ten Centuries
Group: General Forum Members
Last Login: Friday, November 30, 2012 1:52 AM
Points: 1,116,
Visits: 602
Are you trying to say you're looking for another job? Or that the company you work for is just positive by design?
Ronald Hensbergen
Help us, help yourself... Post data so we can read and use it:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
-------------------------------------------------------------------------
2+2=5 for significant large values of 2
Post #599805
Grant Fritchey
Grant Fritchey
Posted Monday, November 10, 2008 6:59 AM
SSChampion
Group: General Forum Members
Last Login: Today @ 12:19 PM
Points: 13,371,
Visits: 25,144
Not unless I've missed it to. If the value of a number is -3, it's -3, not 3 with some negative sign kept elsewhere that may or may not change it. That's a bit of a freaky design. Although, I'd have to check with an accounting friend for the details, I think there is a method of accounting whereby you designate everything as a value and then describe the value as either a credit or debit, + or -, maybe that's what you're dealing with.
----------------------------------------------------
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood..." Theodore Roosevelt
The Scary DBA
Author of:
SQL Server 2012 Query Performance Tuning
SQL Server 2008 Query Performance Tuning Distilled
and
SQL Server Execution Plans
Product Evangelist for
Red Gate Software
Post #599837
tymberwyld
tymberwyld
Posted Monday, November 10, 2008 9:15 AM
SSC Veteran
Group: General Forum Members
Last Login: Saturday, February 02, 2013 8:21 AM
Points: 283,
Visits: 268
Basically what's going on here is that someone is looking at some wireframes of the UI and that's getting translated directly into a database design. If they want to give users an easy way to enter Postive / Negative amounts, by all means, give them a stupid designator / operator selector. However, that should not be how it's stored in the database. As far as accounting goes, I understand your point, but I would think that all Credits would be stored as Negative amounts, yes?
Post #599953
Lynn Pettis
Lynn Pettis
Posted Monday, November 10, 2008 9:28 AM
SSC-Insane
Group: General Forum Members
Last Login: Today @ 9:46 PM
Points: 21,589,
Visits: 27,392
tymberwyld (11/10/2008)
Basically what's going on here is that someone is looking at some wireframes of the UI and that's getting translated directly into a database design. If they want to give users an easy way to enter Postive / Negative amounts, by all means, give them a stupid designator / operator selector. However, that should not be how it's stored in the database. As far as accounting goes, I understand your point, but I would think that all Credits would be stored as Negative amounts, yes?
Not all credits are negative. It depends if they are expenses, liabilities, or assests.
Lynn Pettis
For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here
or
when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here
and
here
Managing Transaction Logs
SQL Musings from the Desert
Fountain Valley SQL
(My Mirror Blog)
Post #599962
tymberwyld
tymberwyld
Posted Monday, November 10, 2008 10:57 AM
SSC Veteran
Group: General Forum Members
Last Login: Saturday, February 02, 2013 8:21 AM
Points: 283,
Visits: 268
Lynn Pettis (11/10/2008)
Not all credits are negative. It depends if they are expenses, liabilities, or assests.
True, sorry, my Accounting knowledge is only so-so :)
Post #600048
Jeff Moden
Jeff Moden
Posted Monday, November 10, 2008 6:06 PM
SSC-Dedicated
Group: General Forum Members
Last Login: Today @ 12:30 PM
Points: 32,893,
Visits: 26,770
Heh... if you really want to throw a ball of wax at them before you decide to find a place with reasonable requirements, tell them the column should be named "IsNotNegative"... :D;)
--Jeff Moden
"
RBAR
is pronounced "ree-bar" and is a "Modenism" for "
R
ow-
B
y-
A
gonizing-
R
ow".
First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."
For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
Post #600323
Matt Miller (#4)
Matt Miller (#4)
Posted Monday, November 10, 2008 6:36 PM
SSCertifiable
Group: General Forum Members
Last Login: 2 days ago @ 1:56 PM
Points: 6,997,
Visits: 13,941
This would bring out the old Bastard DBA from Hell in me. Just encrypt all of the views and all outputs from the DB, calling it a new SOX measure, then mention that they must talk to SEcurity to get their own personal security code to decrypt the output.....
Or -
Comply with the request, and store every number in Hex form, again refusing to convert it back to decimal for output purposes.....
(it's been one of them days, so probably best not to heed any of this advice....:))
----------------------------------------------------------------------------------
Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?
Post #600327
krayknot
krayknot
Posted Monday, November 10, 2008 10:56 PM
Old Hand
Group: General Forum Members
Last Login: Friday, October 07, 2011 1:41 AM
Points: 346,
Visits: 534
tymberwyld (11/10/2008)
Basically what's going on here is that someone is looking at some wireframes of the UI and that's getting translated directly into a database design. If they want to give users an easy way to enter Postive / Negative amounts, by all means, give them a stupid designator / operator selector. However, that should not be how it's stored in the database. As far as accounting goes, I understand your point, but I would think that all Credits would be stored as Negative amounts, yes?
whatever the value and the operator the user selects. you multiply that value by -1.
for example
user entered 100 and selects '-'
the output would be: 100 * -1 = -100
or 100 * 1 =100 or no change
am i correct?
kshitij kumar
kshitij@krayknot.com
www.krayknot.com
Post #600404
« Prev Topic
|
Next Topic »
38 posts, Page 1 of 4
1
2
3
4
»
»»
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.