Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialMikael Paavola
2,876 PointsWhy are integers different for databases (SQL LITE)
In every programming language i've ever had a run into c, c++, python and java
the int data type is a whole number with no decimal points
such as 3, 5, 7 3123 and so on.
And a floating point is 3.0, 4.4, 0.1234
Why then would databases have a different definition on integers?
Refering to this video: https://teamtreehouse.com/library/database-foundations/introduction-to-data-databases-and-sql-2/introduction-to-data-types-2 It seems awfully confusing
1 Answer
Steven Parker
231,275 PointsDatabases typically only have a NUMBER type. The concept of "integer", if used, is probably just a shorthand for a NUMBER with a certain storage size limitation with a default output format that has no decimal.
While many common programming languages have a completely separate type for integer, it's not universal. If you were familiar with JavaScript, for example, the handling of numbers in a database would seem quite natural.