简体   繁体   English

具有查找数据的数据库设计

[英]Database Design with Lookup data

I am creating a database and I need some help with the design. 我正在创建一个数据库,我需要一些设计帮助。

My table will look like this: 我的表将如下所示:

id
request_employee_id
request_menu
request_submenu
request_qty
send_employee_id
notify_employee_id

Each request has a add more option. 每个请求都有一个添加更多选项。 For example: 例如:

Request Menu 请求菜单

id - 1 | Desc - Pencil
id - 2 | Desc - Pen
id - 3 | Desc - Eraser
id - 4 | Desc - Marker

Depending on the selected Request Menu will have different submenu option. 根据所选的“请求菜单”,将具有不同的子菜单选项。

Request Submenu 请求子菜单

id - 1 | Desc - Yellow HB
id - 1 | Desc - Black HC
id - 2 | Desc - Blue Ink
id - 2 | Desc - Black Ink
id - 2 | Desc - Red Ink
id - 3 | Desc - NULL
etc...

The requester can choose Pencil from the primary menu and Yellow HB from the submenu and then can add another request for Eraser on the primary and no submenu and choose more different requests. 请求者可以从主菜单中选择“铅笔”,从子菜单中选择“黄色HB”,然后可以在主菜单上添加另一个对“橡皮擦”的请求,而没有子菜单,然后选择更多不同的请求。

The requester can choose send to employee X and add more employees to send like also send to employee Y and employee W. 请求者可以选择发送给员工X并添加更多的员工来发送,就像发送给员工Y和员工W一样。

The requester can notify employee Z about the request and add more employees to the notification employee T and employee Y. 请求者可以将有关请求通知员工Z,并将更多员工添加到通知员工T和员工Y。

The question I have is basically if I have to use normalization and how to handled. 的问题基本上是是否必须使用规范化以及如何处理。 I am thinking how to get the data for a report. 我正在考虑如何获取报告数据。

In case a User post a request with multiples menus and sub menus, multiples send user and different notify users, If I have normalization I will have to use a lot of JOINS statements and the data will be repeated by how many user and menus I will get. 万一用户发布带有多个菜单和子菜单的请求,多个发送了用户并且通知了多个不同的通知用户,如果我进行了规范化,我将不得不使用许多JOINS语句,并且数据将重复多少个用户和菜单得到。

Or use multiples separate database connection to get: all menus from each request, another connection and query for all send_employee by request, another connection for notify_employee by request. 或使用多个独立的数据库连接来获取:每个请求的所有菜单,另一个连接和按请求查询所有send_employee,另一个按请求查询notify_employee的连接。 At the end I will have like a 7 different connections and SQL select statement to report one request. 最后,我将使用7个不同的连接和SQL select语句来报告一个请求。

Note: I resume the table, I also have UOM by request that will fall on the same issue that the employees. 注意:我恢复了工作表,我也应要求提供了UOM,该UOM将与员工处于同一问题上。 Each request can have multiples UOM by menu. 每个请求可以通过菜单具有多个UOM。 Eaches, Bag, Cases, etc. 每个人,袋子,箱子等

How will be the best design to handle a scenario like this. 如何最好的设计来处理这种情况。

Thank you 谢谢

It can be simple like this: 这样可以很简单:

CREATE TABLE tbl_Request(
    Request_ID INT IDENTITY(1,1) PRIMARY KEY,
    Employee_ID INT NOT NULL,
    Request_DT DATETIME NOT NULL,
    Closed_Dt  DATETIME
);
GO
CREATE TABLE tbl_Category(
    Category_ID INT IDENTITY(1,1) PRIMARY KEY,
    Category_Name VARCHAR(32) NOT NULL
);
GO
CREATE TABLE tbl_Item(
    Item_ID INT IDENTITY(1,1) PRIMARY KEY,
    Category_ID INT NOT NULL,
    Item_Name VARCHAR(32) NOT NULL
);
GO
CREATE TABLE tbl_Request_Details(
    Request_ID INT NOT NULL,
    Item_ID INT NOT NULL,
    Quantity DECIMAL NOT NULL
);
GO

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM