Dynamic tables, I think I need these

D

Dave

Hi all.


I'll try and explain what I want to do and then hopefully someone can tell
me how to do it and whether it is called a dynamic table or someting else!


I am building widgets and these are of different types. For each widget I
record a serial number and the type. Now for each type I want to record
different attributes so say type A has attributes M & N and type B has
attribute X, Y & Z.

I want to pre-define the types so that when the widget is built I can easily
pull up a new serial number and choose the relevant type. However when this
happens I also want to record the values for the relevant attributes for the
given type.

I want to do all this at 'run-time' and not have to configure new types as
new tables in the database every time we have a new type.

Thanks,

Dave.
 
P

Paul Overway

You need 3 tables.

1. Widgets
2. Attributes
3. Widget_Atrributes

Widgets contains fields
WidgetID
WidgetName
Etc.

Attributes contains fields
AttributeID
AttributeName

Widget_Attributes contains fields
WidgetID*
AttributeID*
Value

*This should be a multipart Primary Key to prevent duplicate entries.

Widgets is related to Widget_Attributes. Likewise, Attributes is related to
Widget_Attribute. So, the number of attributes for any given widget in
Widget_Attributes can vary. If in the end you'd rather see Widgets in rows
and columns of Atrributes, you'd create a cross tab.
 
A

Albert D. Kallal

It seems you have good understand of how manufacturing works.

The idea in manufacturing is to build something that solves a need, but NOT
have to change the design for each copy.

The same concepts and rules apply to creating software. While software is
called "soft" due to it not having physical properties, the same concepts
and ideas in manufacturing also apply to software.

The problem with a software machine is that when you write code, and design
the product, it is VERY costly to change the data designs.

It is of little, or no consequence to add 5 records, or 15 records to a well
deigned system. However, to modify the design of the tables is like trying
to modify the design of engine AFTER it has been built, and put in the car.
It is just not practical to modify the table structures, since then the code
and the designs of the forms and designs of the reports all must now be
updated. So, you have to think of the software designs part like a machine,
and you have to purpose build the machine to solve the problem, and having
to change the design of the machine is VERY costly. Thus, to continue this
metaphor, you can easily add to the machine, such adding custom headlight to
a car, but trying to change the actual designs of the motor is out of the
question.

So, we don't have dynamic motor designs, and in fact we don't have such a
thing as dynamic tables in the software industry. The reason whey we don't
have dynamic tables is that software is a machine that needs to eat and
consume STRUCTURED data, and if that data structure changes, then so must
the software that consumes the data.

Thus, the skill, or how this problem is solved is called data modeling. Just
lick a electrician can take standard set of parts and make a radio, or make
a microphone, the parts he uses don't change.

So, we are stuck with tables that should NOT have their designs changed once
the application is in use. Hence, like the knowledge the electrician uses to
take transistors and parts and comes out with a radio, or a microphone, the
resulting "software machine" you make needs to function in such a way that
the table designs do NOT change.

The solution is called data modeling, or normalizing. This enables
developers to build a accounting system with job costing, and yet once
built, that job cost system can be used by many different companies, and yet
the table designs don't change!! And, many of those accounting systems have
complex inventory cost system that allow assemblies of all types to be
entered into the system. So, once company might be watch maker, and the next
company might be Boeing, but they both can use the inventory system because
the designers normalized the table designs used. One might be costing the
part by labor, and feet of wire, the other company might be costing the part
by weight and materials cost, yet they both can use the system table
designs!

So, likely, in your case, you don't need dynamic tables, but you do need to
start learning how to model data structures in tables so that the resulting
software application can use the non changing data structures.
I am building widgets and these are of different types. For each widget I
record a serial number and the type


SerialNum ProductType Product Name Units
123 Fruit Apple
Weight
455 Rocks Granite
Weight
789 Rope Cotten cable Length



.. Now for each type I want to record
different attributes so say type A has attributes M & N and type B has
attribute X, Y & Z.

Type AtrrbiuteType
A M
A N
B X
B Y
B Z

Anyway, you will have to do some reading on this subject, but we have
dynamic tables, and if you did, the software would not work when you change
the designs....

ACC2002: Database Normalization Basics
http://support.microsoft.com/?id=283878

Database Normalization Tips by Luke Chung
http://www.fmsinc.com/tpapers/genaccess/databasenorm.html

Data Normalization Fundamentals by Luke Chung
http://www.fmsinc.com/tpapers/datanorm/index.html

324613 - Support WebCast: Database Normalization Basics
http://support.microsoft.com/?id=324613
 
P

Paul Overway

Expanding on my previous post....forgot about type

You need 5 tables.

1. Widgets
2. Attributes
3. Widget_Atrributes
4. WidgetType
5. WidgetType_Attributes

Widgets contains fields
WidgetID
WidgetName
WidgetTypeID
Etc.

Attributes contains fields
AttributeID
AttributeName

Widget_Attributes contains fields
WidgetID*
AttributeID*
Value

WidgetType contains fields
WidgetTypeID
WidgetTypeName

WidgetType_Attributes contains fields
*WidgetTypeID
*AttributeID


*These should be a multipart Primary Key to prevent duplicate entries.

Widgets is related to Widget_Attributes. Likewise, Attributes is related
to
Widget_Attribute. So, the number of attributes for any given widget in
Widget_Attributes can vary. If in the end you'd rather see Widgets in rows
and columns of Atrributes, you'd create a cross tab.

All the attributes for a given WidgetType get listed in
WidgetType_Attributes. When making an entry in the Widgets form, when the
user selects the WidgetType, any existing records in Widget_Attributes
should be deleted, and the entries in WidgetType_Attributes appended to
Widget_Attributes along with the WidgetID. So, basically, you'd have the
list of attributes for each WidgetType predefined in WidgetType_Attributes
to allow the to be quickly defined in Widget_Attributes.
 
J

John Vinson

Hi all.


I'll try and explain what I want to do and then hopefully someone can tell
me how to do it and whether it is called a dynamic table or someting else!


I am building widgets and these are of different types. For each widget I
record a serial number and the type. Now for each type I want to record
different attributes so say type A has attributes M & N and type B has
attribute X, Y & Z.

I want to pre-define the types so that when the widget is built I can easily
pull up a new serial number and choose the relevant type. However when this
happens I also want to record the values for the relevant attributes for the
given type.

I want to do all this at 'run-time' and not have to configure new types as
new tables in the database every time we have a new type.

YOu have a very straightforward many to many relationship between
types and attributes. This can be modeled with four tables:

Widgets
SerialNumber
Description
TypeName
<any other info about the widget, e.g. date built, ...>

Types
TypeName Primary Key

Attributes
AttributeID Primary Key
AttributeName

TypeAttributes
TypeName Primary Key
AttributeID Primary Key

So a Type A widget would have A in its TypeName field; the
TypeAttributes table would have records

TypeName A; AttributeID "M"
TypeName A; AttributeID "N"


John W. Vinson[MVP]
 
S

SergeK

Dear Dave, You should send a concrete example of your widget and we
immediately prompt you as better create the database structure.

Serge
www.executivpro.com Golden Inventory System
 
Top