I am building c# project for sales management
I made table to register orders (selling items) and table to register items came in into my warehouse
as you know in stores for example you may sell LED screen with 50 Inch or LED screen with 32 Inch or what every the screen specs it is or what ever the product it is
now if I want to know how many screens I sell and how many screens still in my warehouse for specific day, week,month or year no matter what the screen specs it is (size, type LED LCD )
so I want to make classifications for the products in new table (Product_Classification)
on three levels with meaningful identifier
and then include that meaningful identifier within these tables so I am able to query any statistical info I want for example
how many screen I selled in a day, week,month or year? how many screen with size 50 Inch I selled in a day, week,month or year?... etc
I planning to format that identifier and divided it into 3 parts with 4 digits in each part and each part linked to a level in that tree XXXX-XXXX-XXXX
example 1
PK_ID | Full_identifier | identifier_Description | class1_ID | class1_Description | class2_ID | class2_Description | class3_ID | class3_Description
1 | 1122 | electronic devices | | | | | |
2 | 11223344 | electronic devices | 3344 | LED screen | | | |
3 | 112233445566 | electronic devices | 3344 | LED screen | 5566 | 32 Inch | |
4 | 1122334455668899 | electronic devices | 3344 | LED screen | 5566 | 32 Inch | 8899 | Sony Brand
advantage of this Full_identifier :
as you can see each 4 digits of the Full_identifier will allow me to access a level on that classification like I can query all electronic devices by using first part of the
Full_identifier 1122
or query all LED screen by using first two parts of theFull_identifier 11223344
another reason to implement it, when a user want to register a product in warehouse from UI he doesn't have to select 4 categories to categorize the product, at my UI there is only one
dropdown list
which will be built at run time from this tableProduct_Classification
with auto-complete when user start typing a list of nested available categorize will appear and when he choose a category then theFull_identifier
will be stored in required column so whenever I need any sub-category in the tree table I can access it right away by substring theFull_identifier
according to chosen level by user
- for statistical reports if I want to list all LED screen I can simply do by using 3344 the second part of the Full_identifier as below example
> SELECT Full_identifier, > identifier_Description > || ' - ' > || class1_Description > || ' ' > || class2_Description > || ' ' > || class3_Description > AS PRODUCT_Classification FROM PRODUCT_CLASSIFICATION WHERE Full_identifier = 3344
if I want to list all Sony Brand products I can simply do by using 8899 the second part of the Full_identifier as below example
SELECT Full_identifier,
identifier_Description
|| ' - '
|| class1_Description
|| ' '
|| class2_Description
|| ' '
|| class3_Description
AS PRODUCT_Classification FROM PRODUCT_CLASSIFICATION WHERE Full_identifier = 8899
questions
How to manage that identifier
if I used sequence
for each level class1_ID
which will be incremented only if the class1_Description
not changed
I can make that identifier
unique but not PK as recommended here
Is that Possible and good implemented ?