簡體   English   中英

資產庫存數據庫設計

[英]Asset Inventory Database Design

我在IT商店工作,我正在嘗試創建一個數據庫來跟蹤我們的硬件庫存。 要點是,條形碼資產只能位於一個位置,無論是桌面,機架還是某種存儲(在貨架,托盤等)。

我原來有這樣的事情。

Table Asset(barcode);
Table Rack(rack_id, rackName);
Table Desk(desk_id, deskName);
Table Storage(storage_id, StorageName);

對於每個“位置”表(機架,桌面,存儲),我有一個表來跟蹤資產的放置位置:

Table Desk_Item (desk_item_id, desk_id, barcode);
Table Rack_Item (rack_item_id, rack_id, barcode);
Table Storage_Item (storage_item_id, storage_id, barcode);

但我不喜歡有三個單獨的表來跟蹤資產。 所以我想我應該制作一個位置表

Table Location(location_id, barcode);
Table Rack(rack_id, rackName, location_id);
Table Desk(desk_id, deskName, location_id);
Table Storage(storage_id, StorageName, location_id);
Table Asset(barcode);

所以現在Location表跟蹤資產的位置。 但令我感到奇怪的是,如果我查詢位置表,我必須檢查機架,桌面和存儲。 這是設計這個的正確方法嗎? 欣賞任何想法或建議。

你應該有一個location_type表。

location_type_id    location_type
      1             Rack
      2             Desk
      3             Storage

如果您以后想要添加另一個location_type例如ex: 'truck'您也沒有必要修改數據庫,只需添加一個新type

而不是多個表,用於RackDeskStorage單個表location

location_id      location_type_id  name
    1                  1           'Im a Rack'
    2                  1           'Im another Rack'
    3                  2           'Im just a desk'

最后是你的Assets

barcode          location_id
 xxxxxx              1            -- is in first rack
 yyyyyy              2            -- is in the second rack

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM