Mawg
Mawg

Reputation: 40140

Should I have one database or multiple?

I want to have multiple test runs of a device and record the reslts.

Each run will consist of

Question: I have thought to create one databse for each test run (since the measurements table will have multiple rows specific to that run and I would otherwise have to add an extra column as an Index).

Am I correct to use multiple databses, or is there a better way, with a single databse?

Upvotes: 0

Views: 79

Answers (3)

Tim Dearborn
Tim Dearborn

Reputation: 1177

Use one database. In your measurements table, add a field with a run_id specifying the specific run.

Example below - your field types may vary, depending on your needs.

CREATE TABLE IF NOT EXISTS measurements
(
    measurement_id INT NOT NULL AUTO_INCREMENT,
    run_id INT,
    start_time INT,
    stop_time INT,
    description VARCHAR(255),
    PRIMARY KEY (measurement_id)
);

CREATE TABLE IF NOT EXISTS runs
(
    run_id INT NOT NULL AUTO_INCREMENT,
    description VARCHAR(255),
    PRIMARY KEY (run_id)
);

Upvotes: 3

Farhan Syed
Farhan Syed

Reputation: 326

If you are looking for a suggestion, you need to use single database. It will help you with scalability and maintenance as far as ease of use is concerned. Using multiple DBs / schemas will pose a headache at a later stage. It is only a suggestion though.

Upvotes: 1

tadman
tadman

Reputation: 211560

If you have to ask, the answer is always one.

You wouldn't be asking this question if you needed more than one because you would have gone beyond thinking you needed multiple databases to knowing you do.

What you need to focus on is creating a simple schema that can handle what you want and is indexed properly so it's quick to query.

Upvotes: 3

Related Questions