I'm trying to re-design a database I "inherited" (gasp-shock-surprise, eh?
).
The current design has just one table with about 20 fields in it... I'm no database-design-fu black belt, but that sounds all kinds of wrong. I'm hoping to get some comments on my attempt at re-design.
This database is for tracking inventory (mostly computer servers). Each asset in inventory has it's own row, and many attributes covering it.
Here's an example of the current design:
--------------------
CURRENT DB
- (autoNumber) (the PK)
- department#
- ID# (a business-related value, not the PK)
- brand
- model
- state
- city
- address
- softwareName
- softwareVersion
- owner
- administrator
- hostname
- IP address1
- IP address2
---------------------
That is a good smattering of the challenges I have going for me for examples of fields. I have these main constraints:
- each asset can have only one of the following:
> ID#
> brand
> model
> physical location (state/city/address fields)
> softwareName
> softwareVersion
> owner
> administrator
- each asset can (theoretically) have infinite IP addresses and/or host names
- each asset can (theoretically) have more than one department# (in practice, this will range between one as the vast majority but may range up to about 10)
The following are supposed to be enforced as "unique" fields... but there is nothing in place to enforce this and in practice they are not always unique:
- IP Address1 and IP Address2 fields
- hostname field
- ID# field
There are no other constraints I am aware of.
-----------------------
My issue was this: almost everything I look at related to this kind of design has multiple entity / relationship sets. Those seem to make sense. However, in this case if I think of each asset as an "entity" the only relationship I can really see is a "HAS" relationship to all these fields, which is what they currently all are - attributes in one giant table. This doesn't seem quite right though.
In doing my reading I've come across the following ideas:
> break out IP Address fields and hostname fields out to different tables (since an asset can theoretically be assigned an infinite number of each).
> possibly create a location table (to store the state/city/address fields)
> possibly create a software table (to store the softwareName and softwareVersion fields)
> possibly create a department# table (to store the department# field)
===========================
So after my reading, I've come to some interesting conclusions. This is my theoretical re-design, please tell me what you think ; ) Lord knows I can only improve this thing...
tblDepartments
- departmentID (PK, autonumber)
- department#
- assetID (FK)
tblLocation
- locationID (PK, autonumber)
- state
- city
- address
tblSoftware
- softwareID (PK, autonumber)
- softwareName
- softwareVersion
tblHostNames
- hostNameID (PK, autonumber)
- hostName
- assetID (FK)
tblIPAddresses
- IPAddressID (PK, autonumber)
- IPAddress
- assetID (FK)
tblAssets
- assetID (PK) > the current "(autoNumber) (PK)"
- ID#
- brand
- model
- locationID (FK)
- softwareID (FK)
That's it. Again, I was hoping to get some feedback to help improve this thing. It makes a decent amount of sense but I'm sure there is a lot of improvement I could think about? I've read these forums for the past few hours as well as paging through an old design book and random websites, but that doesn't leave me feeling as confident as I'd hope ; )
Thanks again!!
The current design has just one table with about 20 fields in it... I'm no database-design-fu black belt, but that sounds all kinds of wrong. I'm hoping to get some comments on my attempt at re-design.
This database is for tracking inventory (mostly computer servers). Each asset in inventory has it's own row, and many attributes covering it.
Here's an example of the current design:
--------------------
CURRENT DB
- (autoNumber) (the PK)
- department#
- ID# (a business-related value, not the PK)
- brand
- model
- state
- city
- address
- softwareName
- softwareVersion
- owner
- administrator
- hostname
- IP address1
- IP address2
---------------------
That is a good smattering of the challenges I have going for me for examples of fields. I have these main constraints:
- each asset can have only one of the following:
> ID#
> brand
> model
> physical location (state/city/address fields)
> softwareName
> softwareVersion
> owner
> administrator
- each asset can (theoretically) have infinite IP addresses and/or host names
- each asset can (theoretically) have more than one department# (in practice, this will range between one as the vast majority but may range up to about 10)
The following are supposed to be enforced as "unique" fields... but there is nothing in place to enforce this and in practice they are not always unique:
- IP Address1 and IP Address2 fields
- hostname field
- ID# field
There are no other constraints I am aware of.
-----------------------
My issue was this: almost everything I look at related to this kind of design has multiple entity / relationship sets. Those seem to make sense. However, in this case if I think of each asset as an "entity" the only relationship I can really see is a "HAS" relationship to all these fields, which is what they currently all are - attributes in one giant table. This doesn't seem quite right though.
In doing my reading I've come across the following ideas:
> break out IP Address fields and hostname fields out to different tables (since an asset can theoretically be assigned an infinite number of each).
> possibly create a location table (to store the state/city/address fields)
> possibly create a software table (to store the softwareName and softwareVersion fields)
> possibly create a department# table (to store the department# field)
===========================
So after my reading, I've come to some interesting conclusions. This is my theoretical re-design, please tell me what you think ; ) Lord knows I can only improve this thing...
tblDepartments
- departmentID (PK, autonumber)
- department#
- assetID (FK)
tblLocation
- locationID (PK, autonumber)
- state
- city
- address
tblSoftware
- softwareID (PK, autonumber)
- softwareName
- softwareVersion
tblHostNames
- hostNameID (PK, autonumber)
- hostName
- assetID (FK)
tblIPAddresses
- IPAddressID (PK, autonumber)
- IPAddress
- assetID (FK)
tblAssets
- assetID (PK) > the current "(autoNumber) (PK)"
- ID#
- brand
- model
- locationID (FK)
- softwareID (FK)
That's it. Again, I was hoping to get some feedback to help improve this thing. It makes a decent amount of sense but I'm sure there is a lot of improvement I could think about? I've read these forums for the past few hours as well as paging through an old design book and random websites, but that doesn't leave me feeling as confident as I'd hope ; )
Thanks again!!