Database as fileformat

A question for beginners about database design. For example, I have an application that manages some registrar data. 1000 consecutive measurements of time, voltage, current, temperature. In addition, each run of the sequence has metadata (date, location, etc.).
Therefore, I need a table for each set of dimensions and a main table that lists these tables and metadata for each.

A few questions:
This does not actually use the fact that all data tables have the same format - there is no concept of "array of tables", does this mean anything?

I would just give each data table a unique name, place it in the main table as a column, and then just replace it with the select SQL statement - or is there a better way?

edit: the reason for many tables, one for each run, is that there can be 10-100 runs with many 1000 dimensions. If I want to display / query / delete only one run, it would seem more natural to have each in its own table.
It seems like this is the programmer’s thinking (everyone should be collections of separate objects), it seems to prefer the database approach - store everything together and use index / cross-reference.

+3
source share
8 answers

, , , .

: , , .

" ", . , :

Metadata
----------
experimentName
experimentLocation
experimentDateTime
...
measurementTableName

, :

Measurement0001    Measurement0002    Measurement0003    Measurementt0004 
--------------     --------------     --------------     -------------- 
measurementNum     measurementNum     measurementNum     measurementNum 
voltage            voltage            voltage            voltage        
amps               amps               amps               amps           

:

select * from Metadata where experimentName='Johnson Controls 1'

, , TableName (, Measurement0002). :

select * from Measurement0002 order by measurementNum

" ". :

Metadata
----------
experimentName
experimentLocation
experimentDateTime
...
measurementSetID

.

Measurement
--------------
measurementSetID
measurementNum
voltage            
amps               

, , :

select * from Metadata where experimentName='Johnson Controls 1'

, , MeasureSetID, , (, id = 2). :

select * from Measurement where measurementSetID=2 order by measurementNum

, ... . , TableName ; MeasureSetId .

:

select * from Measurement0002                      order by measurementNum
select * from Measurement where measurementSetID=2 order by measurementNum

- , SetID:

select * from <tablename>                                order by measurementNum
select * from Measurement where measurementSetID=<setID> order by measurementNum

, (measureSetID), , ID.

+2

(Run), // ().

(Measurements), ///, () FK ( , RunID).

, 2 .

+7

, , , .

, , . - , , , , , n x 100 x m x 1000 .

. , , , , . OTOH.

+2

( Grant ):

+-------------------+     +----------------------+
|    Sequence       |     | Measurements         |     +------------------+
+-------------------+     +----------------------+     | Measurement Type |
|  metaID (pri Key) |---->| metaID               |     +------------------+
|  location         |     | typeID               |---->| typeID (pri Key) |
|  other metadata   |     | measureID   (pri Key)|     | typeName         |
+-------------------+     | value                |     | typeUnits        |
                          +----------------------+     +------------------+

, :

typeID      typeName     typeUnits
0           Volts        V
1           Current      A

.

, , .

, 1, 2, , , .

, 10-100 . // ,

, , - , SQL. , , SQL, WHERE = "sequencenumber". . SQL , "" . , SQL - , , , .

-
, . , . , / , , , .

, , , .

-Adam

+2

(, , , ), .

, (1 = , 2 = ..).

, , .

, - . , . (, INT, locationId, )

.

0

, , , .

'TestInfo'. .., . . , "RunId", .

'RunInfo' runId , , ..

RunId , . , runinfo .

- , , .

0

, ( ) .

+-------------------+     +----------------------+
|    Meta Data      |     | Measurements         |
+-------------------+     +----------------------+
|  metaID (pri Key) |---->| metaID <-(index this)| 
|  location         |     | measureID   (pri Key)|
|  metaDate         |     | voltage              |
+-------------------+     | amperes              |
                          | current              |
                          +----------------------+

( ), .

0

, , , .

, , . , "", ( ) measureID ( ).

- - .

, , , , .

, - , . , , .

0

Source: https://habr.com/ru/post/1702704/


All Articles