Quote:
|
Originally Posted by DadOnTheEdge
Gracias Achiola!
Yes this helps, thanks. It's helping me see new things. Do you think that this would work?
If I have multiple instruments to sell each with multiple parts could I do this
Instrument table
Parts table
let's say we have two instruments in the instrument table:
cheap instrument
expensive instrument
and then in the parts table we have two columns
instrument name and parts name with four rows
cheap instrument keyboard-part
Expensive instrument door-part
Cheap instrument tubing-part
Expensive instrument power cord-part
Could I enter a bunch of parts and then just group them by instrument name and then do some sort of join back to the instrument table?
Thanks again Achiola, your English is great, mine is not and it is my first language :-(
|
I suspect you still haven't 'got' it yet
so you have a product table...
a product is made of many parts.....
you have a another table beneaths that which identifies what parts go into that product.
however taking a step back a part in itself is also a product (how else could you treat somethting, say a power cord, which may be sold separately to the main product, or is common across a range of products
so you may have
table: products
ID 'PK (Primary Key)
description
blah-di-blah
table: goesinto
ProductId ' (FK: foreign key) identifies what product/part is
ParentId ' (FK: foreign key) identifies what this prosuct/part is used in
blah-di-blah
..you'd put other columns here say for example the quantity of product_id used in parent_id. in this case both ProductID and ParentID are the Primary key in this table as the combination of the two elements defiens what makes this row unique (ie you can only ever have one productID / parentID combination.. you can have lots of productid's matched with one parentid, you can have lots of papentid's defined with different productids (ie what parentid is comprised of. there is nothign stopping you rolling up producs into sub assemblies eg product (parentid) X is made up of prodcuts (1,5,2 & 10), product ZQ is made up product A,F, C, X. its also possible for say a product to be used in more that one sub assmebly ( eg you may decide to standardise on a M8 Hex bolt and that may be used for sub assemblies and the final assembly
if you have different versions of the same part you may need to define a verision/build id as part of the primary key of your goesinto table. eg version 1 had ......., version 2 replaced the IEC cord with a Telefunken cord
productid ' identifies what product/part is
parentid ' identifies what this prosuct/part is used in
BuildNo ' identifies the specific build of this product
again taking a step back think about what you are proposing
you are making a direct map between each product (the cheap and the expensive). for data modelling purposes that doesn't matter.. but what happens if say you introduce 2 more instruments, a 'value' instrument and a 'luxury' instrument. you don't want to have to revist the data model and make chanegs to the application. you want to make htose changes in data only. its part fo the science of problem ownership, when the user makes a change to their business practices you need to do as much as possible to make certain its the users problem to make data changes, than your problem to make db & application changes.
I think you may well benefit form reading up on normalisation
there are 2 excellent web pages on this
Fundamentals of Relational Database Design -- r937.com
and
The Relational Data Model, Normalisation and effective Database Design
HTH