3 Replies - 716 Views - Last Post: 28 March 2016 - 09:40 AM

#1 somecoder  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 04-March 16

Sql doubts in choosing the right data type

Posted 26 March 2016 - 03:05 AM

Hello all!

So I've got this problem :

I have to create a database of olympic games, like tracking results etc...

Sorta like all rounder database.

So I've got an attribute named result, and let's now interpret this result as perhaps some athletics result like Usain Bolt running i don't know 9.77

this is obvious going to be formatted like this NUMBER(3,2)

But suppose we have to measure a result of long distance runners, maybe a marathon

It would probably look something like this :

02:45:12

Now how do I stick that into a format of NUMBER(x,y) where x denotes precision, and y denotes scale.

Thanks for all your help and effort!

Is This A Good Question/Topic? 0
  • +

Replies To: Sql doubts in choosing the right data type

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 13566
  • View blog
  • Posts: 54,121
  • Joined: 12-June 08

Re: Sql doubts in choosing the right data type

Posted 26 March 2016 - 07:47 AM

Why not use a time or datetime since both are measured in that.
Was This Post Helpful? 0
  • +
  • -

#3 baavgai  Icon User is offline

  • Dreaming Coder
  • member icon


Reputation: 6996
  • View blog
  • Posts: 14,635
  • Joined: 16-October 07

Re: Sql doubts in choosing the right data type

Posted 26 March 2016 - 12:39 PM

You could reasonably store an integer and unit type. In some, your unit type might be seconds or milliseconds. In others, points or tenths of points. Your database is to store data. Presentation, like a clock time, is an application level problem.
Was This Post Helpful? 0
  • +
  • -

#4 ybadragon  Icon User is offline

  • Home Owner
  • member icon

Reputation: 571
  • View blog
  • Posts: 2,647
  • Joined: 11-May 12

Re: Sql doubts in choosing the right data type

Posted 28 March 2016 - 09:40 AM

I'm doing something similar to this problem at work right now, and I have done what @baavgai suggested. My unit of measure is configurable, so I just put a unit of measure column, and an int as the unit value.

This post has been edited by ybadragon: 28 March 2016 - 09:42 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1