What MySQL data type suits best for storing average rating values, like movie ratings on IMDB? FLOAT, DECIMAL? Or maybe it will work faster if I round actual values to two decimal places in PHP and save it like INT (8.323243 -> 8.32 -> 832)?
How to store average rating in MySQL?
2k Views Asked by Kadilov At
2
There are 2 best solutions below
0
Sjoerd
On
You don't care about precision, so it is not necessary to use decimal. If you want to only use whole numbers, use an int. Else, use a float or double.
Rounding it first in PHP gains you nothing. Converting it in PHP between int and double will be slower than storing doubles in the database.
Related Questions in MYSQL
- MySQL Select Rank
- When dealing with databases, does adding a different table when we can use a simple hash a good thing?
- Push mysql database script to server using git
- Why does mysql stop using indexes when date ranges are added to the query?
- Google Maps API Re-size
- store numpy array in mysql
- Whats wrong with this query? Using ands
- MySQL-Auto increment
- show duplicate values subquery mysql
- Java Web Application Query Is Not Working
- microsoft odbc driver manager data source name not found and no default driver specified
- Setting foreign key in phpMyAdmin
- No responses from google places text search api
- Adding to MAMP database in SQL/PHP
- I want to remove certain parent- and child-divs in all my wordpress posts with php or some other script
Related Questions in FLOATING-POINT
- Significant digits with IEEE 754 float
- Randomizing values accounting for floating point resolution
- Why is this floating point addition result not correct?
- Numerical issue with np.exp()
- Converting float to uint64 and uint32 behaves strangely
- Addition of floating point, Why the First code work
- how divided integer is converted to floating point number with decimal
- Trouble outputting Float value using Jackson library for Java
- Simple and clean java float to string conversion
- Does OCaml have C-like round() and trunc() functions?
- Splitting a floating point number into a sum of two other numbers, without rounding errors
- How to tell if up to floating point round-off, 4 2-d points might lie on a common circle?
- Is it always safe to negate a floating point number
- Why is the value of 1**Inf equal to 1, not NaN?
- Check if given number is Even, Odd or Neither in PHP?
Related Questions in DECIMAL
- Need Helped Understanding an 8-Bit Signed Decimal with 2's Compliment
- PHP Allow only numbers with 2 decimals
- Excel does not display zero decimal when opening an exported CSV file
- Entity Framework Decimal Truncation Issue
- Comparing two decimals
- Add binary numbers like decimal numbers in Java. eg 0101 + 0110 = 0211
- Python decimal.Decimal id not the same
- Function to convert double to string with given options
- Saving Ruby Decimals in Form
- Java: I want to get an Integer output in double datatype
- search the column with decimal value for '.'
- Decimal out of range exception
- Converting User Chosen Base to Base 10 - MASM
- Control outputted decimal places globally
- Can someone help me explain this code that is converting decimal fractions into a binary?
Related Questions in RATING
- What should be the rating for this app?
- Cordova Plugin to ask for Ratings
- How star ratings system works?
- Setting the minimum stars to a rating bar
- Rating and Feedback Path datas to use in WPF User controls
- How can I set the rating value in the Google Play Store?
- How do I dynamically update the JSON-LD Script for the Schema type = Product
- Actual implementation of 5-star rating system
- Starting values for elo
- Accurate star rating calculation
- How to calculate the user's average rating on all his/her nodes with Fivestar?
- Will the app average rating change if I remove the apk that supports only Froyo or below?
- How to echo star from my rating table?
- CakeDC Ratings stars do now appear and data is not saved
- Creating a rating system for randomised groups
Related Questions in RATING-SYSTEM
- Jquery raty is theres a way to callback the cancel button?
- Thumbs up/ Thumbs down rating implementation using Rating class
- How to avoid that a user removes his session
- Star rating system in rails
- How to load CakeDC.Comments plugin on CakeDC.Ratings plugin?
- GD Star Rating - Thumbs Up/Down Size
- Converting preferences to ratings
- Django star rating system and AJAX
- Average Score of all ratings in comments
- How rating system works?
- ajax toolkit - rating control - want to display current rating & allow people to pick that value
- What approach should be for open voting system
- Star Rating System is Only Updating First Item on the List
- Helper Method does not work in my Index Page, Star Rating Sytem
- Ajaxified Star Rating System is not Updating Correctly
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
The most performant, fast and small data type will indeed be
INT. Sorting, searching, etc. will be the best with this data type, vs.decimaland/orfloat.