W
W
w_b_x2015-11-09 00:04:15
PostgreSQL
w_b_x, 2015-11-09 00:04:15

How to store the distance to the stars?

Good day!
Now I am making a database of stars, it stores both relatively close to us stars and distant ones (from the Sun and much further).
In all major sources, the distance is indicated in light years/hours/minutes.
For example, from the Earth to the Sun ~ 8 light minutes. And up to UDFj 13 billion light years.
How and in what form should I store such data in an SQL database, what type should I use?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
ndbn, 2015-11-09
@w_b_x

Store 2 values:
1) A float - distance
2) B integer - power of 10
result A * (10 ^B)
To Sun (8; 0), to UDFj (13, 9)
float for precision

A
Aleksey Ratnikov, 2015-11-09
@mahoho

BIGINT is fine for you.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question