Ms-access – How to query for something like “last active” per column in Access

best practicesms accessms-access-2016

Let's Say i have two Tables, let's call them

PC-Info 
| ID | Hostname  | Location          |
|:---|----------:|:-----------------:|
| 1  | Hostname1 | This Room         |
| 2  | Hostname2 | That Room         |
| 3  | Hostname3 | The other Room    |
| 4  | Hostname4 | Somewhere Offsite |    

And

IsUp
| Timestamp  | Hostname1   | Hostname2   |
|:-----------|------------:|:-----------:|
| 19.02.2017 | up          | down        |
| 20.02.2017 | down        | down        |
| 21.02.2017 | down        | up          |
| 22.02.2017 | up          | down        |

What would a query in Access look like to get the last time the host was "up", bundeled with the other Info? Or is this database flawed from the ground up?

Since the amount of hosts ist fixed and the timestamps will increase over time, I thought it was the better idea to have fixed columns and add rows per timestamp.

Best Answer

I would have....

| Hostname | Timestamp | Status |
|----------|-----------|--------|
| Host1    | 19.02.2017| up     |
| Host2    | 19.02.2017| down   |
| Host3    | 19.01.2017| down   |

Then you could have another table...

| ID | Hostname | Location       |
|----|----------|----------------|
| 1  | Host1    | Living Room    |
| 2  | Host2    | Bedroom        |

When you run queries, it's easy to find all of Host1's activities, or you could easily find all the activities for 19.02.2017. Yes you have a million rows, but that doesn't matter.