If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > General > Database Concepts & Design > Retrieving Subtypes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-31-05, 14:09
ThatFella ThatFella is offline
Registered User
 
Join Date: Dec 2004
Posts: 5
Retrieving Subtypes

Hello all,

A Widget can go through several kinds of Tests (for now, AlphaTest and BetaTest) that have different attributes.

table widget
( widget_id int primary key
, ...
);

table test
( test_id int primary key
, widget_id references widget
, ...
);

table alpha_test
( test_id references test
, ...
);

table beta_test
( test_id references test
, ...
);

Inserting test data is easy enough. I'm trying to address some retrieval issues.

Given a test_id of 42, I want to cleanly display all the information held about that particular test to the user.

The number of Test subtypes will increase over time, so I'd rather not have to join on every subtype of test for performance and maintenance reasons -- I'd like to minimize the changes when new tests are added.

I'd also like to have a way to be able to store and associate user-friendly attribute names to these tables and fields. What I mean is so that on the GUI I would be able to do something like

Widget 42's Tests:
Alpha & Co -- id: 384 /*instead of alpha_test id: 384*/
Beta -- id: 439 /*instead of beta_test id: 429*/

or on the AlphaTest results page:

Test Operator: John Doe /*instead of test_operator: John Doe*/
Configuration Operator: Jane Public /*instead of config_operator: Jane Public*/

Any suggestions?
-----------------------
Here is my attempt so far.

I add a "test_type_id references test_type" to the test table, and the following tables.

table test_type
( test_type_id int primary key /*one entry for each subtype of test*/
, test_type_name varchar(25) /* "Alpha & Co" would go here */
, test_table_name
)

I still need a way to link back to the actual subtype (ie alpha_test) table. For this I actually stored the table name above. So you'd query this then query again into the table name you just discovered. Is this a horrendous idea?

One last table:

table field
( field_id int primary key,
, test_type_id references test_type
, field_name varchar(25) /* ie "config_operator" */
, field_description varchar(25) /* ie "Configuration Operator" */
);
Your impressions of this and alternative suggestions will be much appreciated. Thanks for reading through the long post.
Reply With Quote
  #2 (permalink)  
Old 01-31-05, 14:57
Vmusic Vmusic is offline
Registered User
 
Join Date: Dec 2004
Posts: 54
Widget Testing

Hi,
Can you explain your testing more.

Is a widget a physcial object or manufactured item?

What are the tests? Are these measurements? Hardness tests?
?????

In theory..... isn't a test a measurement to the specifications?

Vmusic
Reply With Quote
  #3 (permalink)  
Old 01-31-05, 16:05
ThatFella ThatFella is offline
Registered User
 
Join Date: Dec 2004
Posts: 5
Quote:
Originally Posted by Vmusic
Hi,
Can you explain your testing more.

Is a widget a physcial object or manufactured item?

What are the tests? Are these measurements? Hardness tests?
?????

In theory..... isn't a test a measurement to the specifications?

Vmusic
Thanks for the quick reply.

Um, a widget is a physical object that is manufactured? Not sure what you are getting at. . .

I guess a test is a measurement-taking procedure done by a particular instrument. So AlphaTest could actually perform several measurements. The fields in AlphaTest include the settings/configurations of the instrument as well as any comments about the test. Tests actually have a 1-N relationship with Measurements. I didn't include that in the prev post because I didn't feel the details of this would contribute to the more general issues I'm asking about and might possibly confuse the question more. I think for the purposes of this question, we can assume that AlphaTest has fields for each type of measurement done on it.

In this case, a test isn't necessarily a measurement to a specification.

Hope that answers your questions.
Reply With Quote
  #4 (permalink)  
Old 01-31-05, 17:26
Vmusic Vmusic is offline
Registered User
 
Join Date: Dec 2004
Posts: 54
Testing

Hi,
I apologize. I thought the tests were 'quality' tests used in manufacturing, since you used the word 'widget'.

My experience in manufacturing is that a series of quality control tests are performed on manufactured parts, to see that they meet the specification.

Obviously that's not the case here.

I'm still curious as to what you're testing? Is this like a survey or statistical testing?

Now would this be testing for a clinical trial for a medication?

I can see two approaches, one approach assumes the tests are rather clearly defined. This is the subtype path you suggested.
The other uses measurements as repeatable components for tests.

I've attached some images.

Hope this helps!
Vmusic
Attached Images
File Type: gif Measurement1.gif (39.1 KB, 55 views)
File Type: gif Measurement2.gif (45.3 KB, 75 views)
Reply With Quote
  #5 (permalink)  
Old 02-03-05, 11:14
ThatFella ThatFella is offline
Registered User
 
Join Date: Dec 2004
Posts: 5
Quote:
Originally Posted by Vmusic
Hi,
I can see two approaches, one approach assumes the tests are rather clearly defined. This is the subtype path you suggested.
The other uses measurements as repeatable components for tests.

I've attached some images.

Vmusic
Sorry about the late reply.

There's actually both of these things going on. The way I currently have it modelled is that Test holds some basic parameters that all tests will have, say Operator and Date. Each subtype has parameters that are specific to it. There is also a Measurement table that references the Test table:

table measurement
( measurement_id int primary key
, measurement_type_id references measurement_type
, test_id references test
, measured_value double
);

table measurement_type
( measurement_type_id int primary key
, measurement_name /*say Thickness or Weight*/
);

So this basically looks like your two pictures combined.
Reply With Quote
  #6 (permalink)  
Old 02-03-05, 11:22
ThatFella ThatFella is offline
Registered User
 
Join Date: Dec 2004
Posts: 5
In my first post I said I was storing a table name inside one of my tables. I would use this value to determine which subtype of Test I should search:

Quote:
Originally Posted by ThatFella
table test_type
( test_type_id int primary key /*one entry for each subtype of test*/
, test_type_name varchar(25) /* "Alpha & Co" would go here */
, test_table_name
)

I still need a way to link back to the actual subtype (ie alpha_test) table. For this I actually stored the table name above. So you'd query this then query again into the table name you just discovered. Is this a horrendous idea?
I half-expected to get an uproar along the lines of 'you should never do anything like this', 'that's a horrible idea', and 'what's wrong with you'. Not having heard this, am I to assume that this is indeed an acceptable approach?

ThatFella
Reply With Quote
  #7 (permalink)  
Old 02-03-05, 23:21
certus certus is offline
Registered User
 
Join Date: Dec 2003
Location: Canada
Posts: 710
test table name and test type name are usually the same so you would only use one attribute.
__________________
visit: relationary
Reply With Quote
  #8 (permalink)  
Old 02-04-05, 10:11
ThatFella ThatFella is offline
Registered User
 
Join Date: Dec 2004
Posts: 5
Quote:
Originally Posted by certus
test table name and test type name are usually the same so you would only use one attribute.
Well the idea there was that test_table_name may have underscores or be in PascalCase or camelCase and perhaps have Hungarian style prefixes and things that the user doesn't need to see. test_type_name would be what the users are accustomed to seeing; it's strictly for labeling the GUI.

Is there a better way to accomplish this?

ThatFella
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On