I'm trying to think of the best way to design a database, and I'm really running around in circles in my head unable to come up with the answer !
The aim of the database is to show what software is installed on computers. I'd like to be able to:
- Group computers by locations
- Search for software and display locations with that software
- Have various versions of the same software (where I can also search for a specific version of software)
- Have an overview of a location (count how many machines are in a location)
- Have an overview of a location (display all the different software available, and how many computers have each software package installed - this is causing me big headaches!)
The tables I have are:
- computers
- locations
- software
- software_computer_relation_table
The tables break down as:
- computer table has the computer name, and location ID in it
- location table has the location ID, and a break down of the location (building, floor number and room number)
- software table has the software id, software name, and version number (if the software name is the same, but version number different a new row is created)
- software_computer_relation_table this has the ID of the computer name, and the ID of the software (couldn't use software name as a primary key because multiple rows are created with different versions).
The main problem I'm getting is when I try to give an overview of the location with what software is available (ignoring the version), and how many computers have that software installed within that location, because the software table softwarename column is not unique (because there can be different versions), a location can appear to have more software installs that machines actually available (because the software name can appear twice on one machine because the version number isn't included).
I think the solution to this, is to create a computer table, software name table, and a software version table (which links back to the software name table) however I cannot think of how I can link all three tables together in the way I want.
Please help me !
Any help / guidance / best practices given is much appreciated ! I'm new to SQL :)
Thanks, Josh