![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I am working with a database that tracks educational courses. The provider of the course is responsible for entering in the data about the course. One of the attributes of the course is how long it is. It may be expressed in any of various units: minutes, hours, days, weeks, months, or years. Originally I modeled it as two columns - one a decimal for the duration and another an FK into a duration unit table to show the unit that was used. I also added a constraint such that either both columns had to be NULL or both had to have a value - a user could not fill in one without entering in the other. |
|
Now I'm wondering if a better way would have been to include it all in one column, similar to this (this is in T-SQL): |
#3
| |||
| |||
|
|
Another quick note... I cannot just use a single duration unit (for example, express everything in seconds or minutes). There may be reporting on this information, but I don't anticipate any math being performed on it. I think I would still store everything in the same unit (e.g. seconds) and store |
#4
| |||
| |||
|
|
postgres has a interval datatype which internally includes atleast 4 different types *seconds *days (not all days are 86400 seconds) *months *and years. *and allows useful multples like miuntes, hours, and weeks, *and can be used in timestamp arithmetic. |
![]() |
| Thread Tools | |
| Display Modes | |
| |