Database model for describing the IT environment

I'm looking to write a Django app to help document fairly small IT environments. I get stuck on the best way to model the data as the number of attributes per device can vary, even between devices of the same type. For example, a SAN will have 1 or more arrays and 1 or more volumes. Then the arrays will have the Name, RAID Level, Size, Number of disk attribute, and the volumes will have the Size and Name attributes. Different SANs will have different numbers of arrays and volumes.

The same goes for servers, each server can have a different number of disks / partitions, all of which will have the attributes "Size", "Used space", etc., and this will depend on the servers.

Another type of device could be a switch that will not have arrays or volumes, but will have multiple network ports, some of which may be gigabit, others 10/100, others 10Gigabit, etc.

Also, I would like to add device types in the future without changing the model. The new type of device could be a telephone system, which will have its own unique attributes that may differ between different telephone systems.

I have looked into EAV database design but seems to be very quick on this and I don't understand if it is better to do it. I was thinking about something in the build of the model as shown in the picture.

http://i.stack.imgur.com/ZMnNl.jpg

A bonus is the ability to create "snapshots" of environments at specific times, allowing you to view changes in the environment over time. It can help to add date column to attribute table.

This application does not need to scale very much for recording (no more than 1000 devices), so massive scalability is not a big problem.

+3


source to share


3 answers


If you are more comfortable doing something line by line in the image you posted, below is a slightly modified version (sorry I can't upload the image, the rep is missing).

+-------------+
| Device Type |
|-------------|
| type        |--------+
+-------------+        |
                       ^
                  +---------------+     +--------------------+     +-----------+
                  | Device        |----<| DeviceAttributeMap |>----| Attribute |
                  |---------------|     |--------------------|     |-----------|
                  | name          |     | Device             |     | name      |
                  | DeviceType    |     | Attribute          |     +-----------+
                  | parent_device |     | value              |
                  | Site          |     +--------------------+
                  +---------------+       
                       v
+-------------+        |
| Site        |        |
|-------------|        |
| location    |--------+
+-------------+

      



I've added a linker table DeviceAttributeMap

to give you more control over the directory Attribute

, allowing you to query devices with the same Attribute

but different values. I also added a field in the device model named parent_device

as a self-referencing foreign key to capture the relationship between the device's parent device. You probably want to make this field optional. To make the foreign key parent_device

optional in Django, set the null and blank attributes to True.

0


source


Since your attributes are specific to the model instance and are different for each instance, I would suggest going with a completely free schema

class ITEntity(Model):
    name = CharField()

class ITAttribute(Modle)
    name = CharField()
    value = CharField()
    entity = ForeignKey(ITEntity, related_name="attrs")

      



It's a very simple model and you can do everything else like templates (like switch template, router template, etc.) in your application code - much more straight forward, then using a complex model like EAV (me like EAV but it doesn't look like it for that).

Adding a story is also easy - just add a timestamp to ITAttribute

. When changing an attribute, create a new one instead. The fetch attribute is then selected by the one with the last timestamp. This way, you can always have an idea of ​​your environment at a certain point in time.

+1


source


You can try document based NoSQL database like MongoDB. Each document can be a device with as many fields as you like.

0


source







All Articles