473,396 Members | 1,923 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,396 software developers and data experts.

Help with database design/model.

Hello all,

I'm struggling with finding a correct design layout for my Acces databse.

This is currently what I have:

A Form where the user can select 4 different parts in comboboxes. After selecting the cost of each part should appear in the textbox. When the button is pressed the values will be stored to tblOrders (the form is bounded to it).



This table contains all the existing parts. These values are the rowsources for the comboboxes.



All the Form values are stored with a OrderID in this table:



This is the Query I want to run to see which parts are used in each orderID. Clearly this wont work because there are multiple columns with identical names.



Can someone please point me in the correct direction to turn this database into a proper one.

Kind regards,

Jeroen3131
Oct 23 '14 #1
6 3608
twinnyfo
3,653 Expert Mod 2GB
Jeroen3131,

It does not appear that your database tables are properly normalized. Please refer to this article for additional information: Database Normalization.

The basics: Your form should not have four combo boxes to select four different items on one order. You should have all items for one order as separate records, but as one OrderID.

I am currently unable to see your images at work, but your descriptions make it clear that your first step should be to normalize your data tables so you can better manage your orders and items.
Oct 23 '14 #2
twinnyfo
3,653 Expert Mod 2GB
Perhaps, list your tables in the thread, listing the field name, field type and any additional notes concerning that field. List the pertinent data for these tables and we can assist with design.

We have helped many others (and I have been helped) to redesign DBs through this forum).
Oct 23 '14 #3
Seth Schrock
2,965 Expert 2GB
Unless you have a reason for doing so, calculated fields (like the cost of a part) should not be stored in your tblOrders. The exception to this rule would be that the cost changes so you would need to lock in the cost at the time of purchase.

Also, what would happen if someone purchased five parts? For this reason, it is better to have a subform so that you can have unlimited number of parts that a person can order. Both of these ideas are covered in Database Normalization and Table Structures.

So a proper design would have the following tables:
  • tblProducts
  • tblOrders
  • tblOrderDetails
More tables can also be used to store customer information, product categories, etc. tblOrders would contain information about a sale, such as purchase date, cashier, customer, etc. tblOrderDetails would be related to tblOrders and tblProducts using the Primary Key to Foreign Key link and would contain the information about each part being sold such as the quantity sold, the product ID (could be selected from a combo box), etc. If your costs don't change, then this table wouldn't contain a cost field. If you do need the ability to lock in the price, then it would have the price field.

If you download the Northwind sample database, you can see how all this works.
Oct 23 '14 #4
Twinny, thanks for the clear article about Database Normalization.

Seth, I've tried to keep the problem clear/small by using this fictional database which I described in the 1st post. I did this because the database contains confidential data from the company I'm working for. But I've discussed it and removed the confidential part so I can show you guys the actual database I'm working on .

The goal of the database is:

A employee can CREATE, EDIT and VIEW a Work Instruction.
Each Work Instruction contains several steps, "Work Steps".

Each Work Step contains:
  1. a Step Name
  2. a Department Name
  3. a Work Station Operation name
  4. a Work Station Operation number
  5. a Machine Model
  6. a Machine Variant
  7. an English description
  8. a Dutch description
  9. a Step Revision Number
  10. a maximum of 4 different kind of Parts which are used
  11. a maximum of 4 pictures of the used Parts
  12. a big Picture of the action being performed

I've already set up a Form for the user to CREATE a Work Step:


The layout of the form matches the actual layout of one page of the Work Instruction document. Each page consists of max. 2 Steps.

On this Form you can see multiple Attachment Objects to add Pictures. I'm going to replace these with Image Objects to keep the database compact.

These are the database items:



Name: tblDepartment
Primary Key: DeptID
Department [text]

Name: tblOperations
Primary Key: OperationID
Operation [number]
Description [text]
Work Station [number]
Foreign Key: DeptID [number]from tblDepartment

Name: tblVariantList
Primary Key: VarID
Variant [text]
varDescription [text]

Name: tblVariant_per_Model

Primary Key: variantID
Foreign Key: ModelID [number] from tblModels

Name: tblModels
Primary Key: ModelID
Model [text]

Name: tblParts
Primary Key: PartID
SAPnumber [number]
PartDescription [text]
PartPicture [text] (link to image of part)

Name: tblSteps
Primary Key: stepID
StepName [text]
DescriptionEN [text]
DescriptionNL [text]
Foreign Key: DeptID
Foreign Key: OperationID
Foreign Key: VariantID
Foreign Key: ModelID
Picture [text] (link to image of action]
Foreign Key: Part1
Qty1 [number]
Foreign Key: Part2
Qty2 [number]
Foreign Key: Part3
Qty3 [number]
Foreign Key: Part4
Qty4 [number]

The main problem (I think) is that I want to display 4 record values (four Parts from tblParts) in one record (one StepID).

If I normalise the database and create a query like this:

ID.....PartID.....Qty.....PartPicture
1..........2..........10.......C:\abcdef2.jpg
2..........1..........15.......C:\abcdef1.jpg
3..........3..........13.......C:\abcdef3.jpg
4..........4..........17.......C:\abcdef4.jpg
1..........1..........25.......C:\abcdef1.jpg
etc.

How does the Img Control know which part to display for a single StepID? If the Img Source of Part 1 looks for StepID 36 it finds 4 different part pictures but it needs to show only the picture of part 1.

I hope the database information clearifies the situation a bit.
Oct 24 '14 #5
Seth Schrock
2,965 Expert 2GB
Ok, I have few questions to clear some things up. So a single step on the form you provided shows a big picture window, four part comboboxes, four quantities, one english description, one dutch description, and four small pictures. Fairly obvious that the four quanities, parts and small images coincide with each other, but what does the big picture on the left side do? Based on your question about the Image control knowing which part to display, I'm guessing that it shows just the picture for the first part?

As far as the normalized table design goes, here is how the steps and parts would related to each other:
Expand|Select|Wrap|Line Numbers
  1. tblSteps
  2. StepID: PK
  3. StepName
  4. rest of fields...
  5.  
Expand|Select|Wrap|Line Numbers
  1. tblStepParts
  2. StepPartID: PK
  3. StepID: FK
  4. PartID: FK
  5. Qty
  6.  
Expand|Select|Wrap|Line Numbers
  1. tblParts
  2. PartID: PK
  3. PartPicture
  4. PartDescription
  5. rest of fields...
I think that you know how these would be related. Just match up the names. Now your query would pull all the fields from tblStepParts and the Part picture from tblParts.
Expand|Select|Wrap|Line Numbers
  1. SELECT SP.StepID, SP.PartID, SP.Qty, P.PartPicture
  2. FROM tblStepParts As SP INNER JOIN tblParts As P 
  3. ON SP.PartID = P.PartID
You would then create a form that has the Qty textbox, a combo box bound to the PartID field that displays the description from tblParts, and an image control display the picture. Add this form to the main form as a subform. You would create the Master/Child link between the parent and subforms on the PartID field. You can then enter the qty, select the part from the combobox and then your picture will automatically populate without any code.

Going back to your question about how the image control knows which image to pull, you can actually link it so that the image displayed in the big image control corisponds to whichever record you have selected in the subform.
Oct 24 '14 #6
zmbd
5,501 Expert Mod 4TB
wow,
Wish I'd been here sooner; however, we have a seriously broad question in the original post and now it's growing branches.

OP: Help with database design/model.
Posts #2 thru #6 seem to answer the original question.
At Post#6 we get a secondary question started. I'll be splitting the thread at this point.

Link to split: http://bytes.com/topic/access/answer...ubforms-parent

To help keep this thread useful, I suggest that we narrow the topic down to proper table and database design and normalization.
Oct 28 '14 #7

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

Similar topics

3
by: Rushikesh | last post by:
I am designing a WEB BASED Accounting Software with ASP and SQL Server. For this I need some help for the Database design. My design is as follows. I)User table: User_id, UserName..... Users...
1
by: Stephan Ranocchia | last post by:
I'm in the process of designing a database and would like some suggestion on how to architect it. I have 3 'objects', frequency, task, skill. For each task there is a frequency however for...
0
by: Krist | last post by:
Hi All, I have a database design question, pls give me some help.. I want to define tables for salesman's sales target commission . The commission could be given per EITHER sales amount of :...
1
by: Krist | last post by:
Hi All, There is some additional info I forget on this same topic I just posted. I have a database design question, pls give me some help.. I want to define tables for salesman's sales target...
5
by: Don Vaillancourt | last post by:
Hello all, Over the years as I design more database schemas the more I come up with patterns in database design. The more patterns I recognize the more I want to try to design some kind of...
2
by: John C | last post by:
I am trying to develop a access database version 2002 from scratch and I am a novice programmer and need much direction. I have been researching and studying about relational database design and...
4
by: scottrm | last post by:
Is anyone aware of any book/website/tutorial that has a decent object oriented design model for an asp.net e-commerce site (or even a generic e-commerce site). The ibuyspy.com sample site does not...
2
by: CAradhana | last post by:
I am checking online shopping sites like amazon. Can anybody tell me, is there any way to get Product database structure. i.e. database design to store product category and corresponding attributes...
12
by: nyathancha | last post by:
Hi, I have a question regarding best practices in database design. In a relational database, is it wise/necessary to sometimes create tables that are not related to other tables through a...
7
by: Jonathan Wood | last post by:
I've been given a spec that seems unwieldy to me. As I'm pretty new to DB design, I would appreciated any input this spec. The site has three types of users: ADMIN, RESELLERS, and CLIENTS. The...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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,...

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.