How to create a database to save changes over time?

This database will store a list of children. But the problem is that their weight will be measured once a day. How can I save the changes so that I can easily request their actual weight and weight change for one day, one week and one month?

+3
source share
5 answers

I would think something like the following:

table kid
    int pkey(id)
    text name

table weight
    date when
    int kidid fkey(kid.id)
    int weight
    int pkey(id)
+5
source

You need a one-to-many relationship between the child table and the weight table.

Child Table
-----------
ID (Generated) (PK)
Name 


WeightTable
-----------
ID (Generated) (PK)
Date
Weight
ChildID (FK)

, , , ; , "--" . , , .

+2

( ), / , .

, , , , , , , , , .

+1

. , , , , , .. - . . , . sql children_weights, , , 1 8 , . sql .

0

() (PK)

float InitialWeight

WeightTable

() (PK)

float ChangeInWeight

ChildID (FK Child.ID)


, ChangeInWeight < > 0.

The sum of the request (ChangeInWeight) with a date range from the WeightTable relation to search for variation and Query IntitalWeight + Variation, as indicated above, for the actual weight.

0
source

All Articles