7

The answers and discussion on questions like this one talk about folded vs pivoted tables.

eg.

The only difference between a paper presentation and a sound electronic presentation is that a folded table structure is more convenient in the latter case while a pivoted table structure in the former...

I couldn't find anything on Google about what those terms mean (Google gave results about protein structures).

Could someone please explain what those terms mean with examples?

  • A 'folded table' is not a technical term, but rather a description used by the respondent. If you look at the answer again a 'pivoted table' is one where the the debit and credit are side by side on a single row. whereas a 'folded table' shows each entry on a separate line (or row). The OP describes these as "One row per transaction" or "Two rows per transaction" respectively. – Sir Swears-a-lot Mar 27 '17 at 0:42
9

It's just a different way of representing the data. Also known as wide (pivoted) and long (folded). As an example and to keep it simple, imagine that we have a record with 3 properties: id, name, description in the wide (pivoted) version each property would be its own column like so:

CREATE TABLE `example_table` (
  id int not null,
  name archer(50) not null,
  description archer(100) null
)

In the long (folded) format you would have two columns like so:

CREATE TABLE `example_table` (
  property varchar(50) not null,
  value varchar(100) not null
)

The later gives you greater flexibility if the columns are not known in advance or are likely to change often. However, it is generally more complicated to implement because you have to design a way of knowing what type the value is, and then you have the overhead of serialization/deserialization to the storage type (in this example varchar(100)).

The wide format is better when the properties do not change very often and are known in advance. This will offer better performance but will be less flexible if changes are required.

Generally, where possible choose the wide format when you know the structure of the data you are storing, and choose long if you need maximum flexibility and are willing to accept the added complexity.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.