Currently I am developing a time machine for a open-source Business Intelligence software from scratch using PHP/MySQL.

My time-machine table is used by all other tables that need date info (such as orders, products, etc.) and they binding with time_id. So its MySQL table like this:

 time_id |  timestamp   | day  |  week  |  month  |  quarter
 1          1303689654    25      17       4         2
 2          1303813842    26      17       4         2
 ...

Order table binding like this:

order_id    |  time_id  ...
3123           2
...

edit: it's similar to STAR SCHEMA.

The problem is getting TIME (13:45) information as well. Usually I don't need this, but like orders, and sometimes a couple of tables need this HOUR/MINUTE infomation.

How can I solve this problem cleverly? I have a couple of solutions, but first i want to see your opinions..

有帮助吗?

解决方案

Why don't you simply store timestamps in your other tables?

Or, if you want to keep the dates table, simply add a TIME field to your other tables which need it.

其他提示

If I understand your timestamp correctly, you can probably just go:

echo date('H:i.s',1303689654); 

edit

What are you trying to do? After re-reading your question you may be looking for the JOIN keyword in SQL (brief tute)

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top