Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: How can I store a mathrix in a table
El Thu, 10 Sep 1998 16:16:45 GMT, prochak_at_my-dejanews.com escribio:
>In article <35f6fbf2.5006303_at_news.mad.ibernet.es>,
> jgonzalezs_at_nexo.es (Julio G. Suarez) wrote:
>> Hi all. I'm working with Oracle 7.3 and this is my trouble for the
>> week:
>> Supose that we want to store the history of faults on pieces, so we
>> need a table with the piece code and the fault number as primary key.
>> The damage is described by a 10 x 10 square pattern, like this:
>>
>> 0 1 2 3 ... 10
>> 1
>> 2 x x
>> 3 x
>> ....
>> 10
>>
>> In this example, the damage (shown whith an "x") is on the points
>> (2,2), (2,3) and (3,2).
>>
>> In order to store this kind of data, I have think on three ways:
>> 1.- Add 100 boolean-like columns to the fault's table.
>> 2.- Add 10 number columns whith the translated to decimal ten bit
>> binary number.
>> 3.- Create a child table whith as rows as damaged points for a fault.
>
>Do you mean a table like:
>table faults (
>pieceID number
>xloc number
>yloc number
>)
>which lists each 'X' (ie sparse matrix storage)
>
>or like
>table faultpattern(
>patternID number
>x1y char(10)
>x2y char(10)
>...
>x10y char(10)
>)
>which holds the whole pattern in one record
>
>
I'll try to explain myself better:
First I have the Pieces table, with the PieceID primary key.
table pieces (
pieceID number
manufacturer varchar2
purchase_date date
...
)
Then I have the Faults_table. Since the pieces are reusable, there can
be (and will be) more than one fault (arround fifty) for each piece.
Thus the faults_table primary key is PieceID and fault_number. There
will be more columns in this table, like the fault date and so on. At
this same level is where I need to know the "picture" of the damaged
part of the piece in this single fault. There is a one on one relation
between the fault and the picture (represented by the matrix).
table piece_faults (
pieceID number foreign key ... references pieces
fault_num number
fault_date date
...
"picture_of_the_damaged_zone_for_this_fault"
)
The child table I talked about in the original question is one table
like this:
damaged_points table (
pieceID number
fault_num number
xloc number yloc number
Thus, when we detect a fault in the 2345 piece, we insert a record in
the piece_faults table, which is asigned a fault_number (for example,
42 if this is the 42nd fault for the 2345 piece). We enter then more
data for this fault (like the date and so on) and the "picture"
displayed through the matrix.
If I use the damaged_points table method, and there were three damaged
points ((2,2), (2,3) and (3,2)) we should insert into damaged_points
this three rows:
PieceID fault_num xloc yloc
2345 42 2 2 2345 42 2 3 2345 42 3 2
Usually, the number of damaged points is arround 10 or 15.
>>
>> Could you suggest me the best way?
>>
>> Thanks!
>>
>
>Give us some more information and maybe we can help in more
>detail.
We may store arround 3-4 faults a day through a form with the
appropiate fields and I'm thinking on 100 (10 x 10) check boxes for
entering the damaged points.
We want to display the faults knowing the key of the fault.
This is what I want to optimize, because the intend of statisticly
analize the damaged points dispersion is secondary.
Maybe, in the future, we would like to answer questions like
Where do the class 'C' pieces use to fail?
Is this fault becoming habitual for this piece?
but I'm not sure we ever use this features.
I hope this will light my question up!
--
Best Wishes!
Lío.
(For mail or reply, change nospam by nexo, like this:)
jgonzalezsuare_at_nexo.es
Received on Wed Sep 16 1998 - 18:14:18 CDT