kikiz
kikiz

Reputation: 40

MySQL Table efficiency in web wizard

I'm developing an online web wizard and I got stuck on planning the database structure.

Which is more effective?

Making one table like this:

| ID | CLIENT | PARAM | PARAM | PARAM etc.

or a table with formatted parameters like this:

| ID | CLIENT | FORMATED_PARAMS (eg. JSON)

or multiple records with simple table build like this:

| ID | CLIENT | PARAM |

Structure of parameter is an array:

{
    "PARAM_NAME",
    "PARAM_ADDRESS_PART_1",
    "PARAM_ADDRESS_PART_2",
    "PARAM_TYPE",
    "PARAM_VALUE"
}

Number of parameters and their addresses are unknown so above table shouldn't contain that information. It's possible client would have permission to edit stored data so using second version might be complicated.

Upvotes: 0

Views: 33

Answers (1)

MonkeyZeus
MonkeyZeus

Reputation: 20737

I would recommend creating two tables:

Client table

| ID | CLIENT |

Param table

| ID | CLIENT_ID | PARAM_NAME | PARAM_VALUE |
       ^
       ^--- ID from Client table

With this structure you will be able to add endless parameters and even customize the parameters available on a per-client basis.

Welcome to Relational Databases =)

Upvotes: 1

Related Questions