简体   繁体   中英

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.

The requester can choose send to employee X and add more employees to send like also send to employee Y and employee W.

The requester can notify employee Z about the request and add more employees to the notification employee T and employee 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.

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. At the end I will have like a 7 different connections and SQL select statement to report one request.

Note: I resume the table, I also have UOM by request that will fall on the same issue that the employees. Each request can have multiples UOM by menu. 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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