my question would be can age be considered a composite attribute? Because name is a composite attribute and it can be divided into first name, middle name and last name. And therefore can age be a composite attribute since you can divide it into years, months and then days?
Sign up
- Anybody can ask a question
- Anybody can answer
- The best answers are voted up and rise to the top
|
Can age be a composite attribute? No. age is a function of birthdate and now.
So, what about birthdate? Can it be a composite attribute? Yes, it can, but it only makes sense to store dates as a composite in data warehousing situations. Often, when warehousing data, you would store year, month, and day as separate things to make it easier to write queries such as
Or
You'd also likely have a table that maps dates to quarters, so you could ask things like:
These are contrived examples, but hopefully illustrate the point. I'd recommend doing some research on "star schema" databases and "slowly changing metrics". |
|||||||||
|
Yes, you can store Age as a composite of year, month, date, hour, minute, second in the database if you want to. However this is probably not a good idea in most cases, because Age can be derived from other values that are usually preferable to have stored in the database. The main reason is that it is better to store birthdate rather than Age; because birthdate is constant but Age depends on the current time. As soon as you save your Age, (unless it is some kind of value for "Age at a certain time", rather than dynamic age) then it will be increasingly incorrect over time. Storing data that can be derived from other pieces of data is also a violation of some levels of Normal Form and can lead to issues such as data redundancy and inconsistency. |
|||
|