473,405 Members | 2,310 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Handling multiple units..!!

Narender Sagar
189 100+
Hi All,
I am making a database in which I have 3 tables, one is BOM Table (Bill of materials), one Inventory Table and one Item Master table. There are various kind of items in each table and their respective Units in these tables. Now, the Units can be different in each table for a given item. e.g. The Units in Item Master Table for an Item "X" can be KG, while for same Item the units in BOM Table can be GM and in Inventory Table the Units can be Ltr.
I've created a 'Conversion' table in which I maintained the all possible conversions (from KG to GM or GM to Ltr etc.).
My objective is to have common Units for a given Item (for this I think the Item Master Unit will rule).
I'm planning to make two separate queries for BOM Table and Inventory Table and bringing the items to common unit i.e. Item Master's Units.
I'm just wondering is their any better way to accomplish this job..
Thanks
Sep 24 '16 #1
5 1233
zmbd
5,501 Expert Mod 4TB
Sometimes I need to do conversions in the lab
What I have is a table with the SI units and the conversion factors. You can find a simple one on Wiki
https://en.wikipedia.org/wiki/Conversion_of_units

I set it up this way:
T_Unit_Class (Length, Mass, Time, Volume, Pressure...)
T_Units (Unit_Name, Unit_Symbol, FK_Unit_Class, Unit_Formula, Unit_FactorToSIBase)

Example
(Meter, M, Length, M, 1)
(KiloGram, Kg, Mass, Kg, 1)
(Gram, g, Mass, Kg/1000, 0.001)

Now one could set up a table that self joins back to the Base SI Units; however I've never bothered.

Usage, a bit contrived;
1 Unit in and unit convert to, find in table, check for same classification.
2 Unit in, find in table, find conversion factor to SI-Base, Convert to SI Base,
3 Find new unit, find conversion factor, inverse factor, convert.

:)

You could get really fancy and have a table with the Metric scalars (n,u,m,d,D,K,M etc) and then attempt to find if the unit conversions are simple scalars... :)
Sep 24 '16 #2
Oralloy
988 Expert 512MB
Narender,

What you suggest makes sense. After all, medicines are usually measured in grams, where fruit is measured in kilograms.

One project, which I worked on, had a reference table of units-of-measure in the schema. One record of which was "count", used for items like trucks. This was very handy, as we could use it for unit display values, like "kg" or "count", and their (possible) language dependencies.

As you know, some items have the problem of how they are managed - in bulk, small items are often sold by the "kilo", and smaller quantities are done by "count". If I want ten 6mm*20mm SHCS (socket-head cap-screws), I buy them by count. If I want 200,000 screws, I'll have to buy by weight.

This also means that each small part has a unique conversion from count to weight. For example a 6mm*20mm SHCS weighs roughly 75% that of an 8mm*20mm SHCS - meaning that there are 33% more 6mm screws per kilogram than there are 8mm screws.

The conversion may also be unique to each manufacturer in some cases. Consider for a moment aspirin tablets.

You sound like you've considered several solution ideas:
  • Use of UNIT and CONVERSION tables
  • Fundamental UNITs have exact conversions that apply to all products (e.g. gram to kilograms).
  • Each product has a unique set of conversions that apply to dissimilar units:
    • Screw count to weight is unique to each screw type.
    • Screw count to weight may be unique to manufacturer, depending on manufacturing details.
    • Liquid densities differ, depending on material - water is nominally 1.00g/cm^3, oil is roughly 0.75g/cm^3.
    • Nitrogen can deliver as liquid or compressed gas.
  • At times a unit conversion cannot be performed, or is ambiguous, perhaps pointless.
    • Ordering a litre of 6mmx20mm SHCS makes little sense.
    • Converting a litre of 6mmx20mm SHCS into kilograms is highly inaccurate.
    • Converting a litre of 6mmx20mm SHCS into a count is likely worse.
    • It is probably meaningless to say "one" oxygen (although one atom oxygen is actually intelligible).
    • Converting "one" to "kilograms" oxygen actually makes physical sense, but is likely meaningless in your context.
  • For some products, it may be worth maintaining separate "products" which represent form:
    • Nitrogen, gaz.
    • Nitrogen, liquid.
  • And some products include sizing, or packaging:
    • Resistor, 10 ohm, bulk.
    • Resistor, 10 ohm, tape.
    • Resistor, 10 ohm, individually wrapped.
    • Nitrogen, gas, 450 bar.
    • Nitrogen, liquid, 10 kl (10,000 litres).
    • Lead Styphnate, 1 kg bulk.
    • Lead Styphnate, 80 mg, primer.
    • &c.

So we need to understand the requirements and what the implications are. If you want help mapping requirements into solutions, ask away, and be prepared for questions in reply.

In other words, build the "right" solution, as there is no value in unnecessary complexity designed to solve non-problems. Let's deal with building a good solution to your immediate problem. We can worry about building a fully-comprehensive solution when you really need to do so.

This looks like it might be a class assignment, based on how you have written it up (and the lack of accompanying detail). (If I'm wrong, you have my apologies). So ask direct questions and you'll get direct answers here. We have a bunch of very bright people helping us here, and they appreciate interesting and difficult questions.

Cheers!
Oralloy
Sep 24 '16 #3
Narender Sagar
189 100+
Thank you ZMBD & Oralloy..
What I understand from your response is that I'm on right direction as I'm trying to build something similar as you advised.
Although your suggestion sounds much more professional and internationally applicable solution.
best regards,
Sep 25 '16 #4
jforbes
1,107 Expert 1GB
For what you are doing, I wouldn't implement a units conversion unless it is absolutely needed as it can get pretty hairy as zmbd and Oralloy have done a good job of pointing out.

One other important note: I've worked on a few systems with an Item Master and typically they create multiple entries (and Part Numbers) for the same item in its different Units of Measure. Usually in this case, when a pallet or carton needs to be opened and the resultant material needs to be inventoried there is usually either a Manufacturing process or Outside process where the Initial Item is shipped to a Process which then returns the Item in the other U/M. This way any cost accounting can be applied/adjusted as usually the cost associated with a single quantity and bulk quantity of the same item are different.
Sep 26 '16 #5
Narender Sagar
189 100+
Hi jforbes,
I'm fully understanding the point you are emphasizing.
Thanks for same.
Sep 27 '16 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: john | last post by:
How do u guys handle multiple sessions?? i.e, opening different browser windows by running iexplore.exe or clicking IE icons and opening the application. My sessions are mixing up. what i mean is...
3
by: Ramachandran | last post by:
Hi, I am novice in ASP and am trying to build an online test that records user input one question at a time. So each question is a form by itself. I want to make a single ASP file that will...
1
by: Chris Beach | last post by:
Hi, I have a JSP page with several forms on it. Some of these forms are generated dynamically, and each of them submits some information to a database. Handling one form is easy, as I can...
2
by: Subodh | last post by:
Hi, Currently we get data from more then 200 different sources and all of our vendors provide data in different file formats. The problem is we have more then 100 DTS packages now and the...
3
by: darrel | last post by:
My understanding is that using the FILE form element to allow a file upload is limited to one unique file per page. Is that correct? Any thoughts on how best to design an interface to allow...
3
by: Tina | last post by:
I have an aspx page with a textbox and an "add to my Account Button." when the button is pushed, my program adds the amount in the textbox to the database which, lets say takes a few seconds. If...
7
by: Java Challenge | last post by:
Dear all, I'd like to handle two similar events with the same code (pressing enter in a search textbox AND clicking on the button "search"). I could copy the code in both events handlers but this...
4
by: beatdream | last post by:
I am designing a database to handle different kinds of products ... and these products can have different properties...for example, a trouser can be specified by the width, length, color, and other...
1
by: bizt | last post by:
Hi, I am having my first real attempt at an ajax class as so far Ive managed to build one that, once instatiated, will allow me to define which function it will call on completion then retrieves...
4
by: gamaz | last post by:
Hi, I am trying to work on a stored procedure that will work with multiple database. I have a prototype of multiple databases. Those are named as the following: ts2_aldkm_app, ts2_aldkp_app,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.