Want to keep learning?

This content is taken from the Raspberry Pi Foundation & National Centre for Computing Education's online course, Programming 103: Saving and Structuring Data. Join the course to learn more.
stressed robot with piles of books surrounding them and relaxed robot with a cup of tea surrounded by book shelves

Structured and unstructured data

What is data structure and why is it so important?

Data with no structure is rather difficult to work with. Take, for example, a list of names and a list of phone numbers. If there is no structure in place then how can you find the phone number for someone?

Unstructured data can be compared to a backpack full of loose items. You can reach in and rummage around for an item, but it can take a few attempts to find what you want. Structured data is more like books in a library. They are stored using a structure that enables a user or a librarian to easily find one book within a library of thousands.

Structured data enables human beings to understand and work with complex data. Adding structure can also enable complex simulations and experiments to be conducted using a computer to speed up the process. If the data had no structure then there would be no easy way for the computer to process the data.

Standardised data structures enable data to be shared and understood across the world; for example, meteorologists will use a standardised data structure when working with the raw data that will be used to predict the weather.

To begin with, the high score data in your quiz game was unstructured and to most people this data would be meaningless despite it looking so simple. You understood what the data represented as it was written by your code. As the data was a simple number it did not require a formal structure. Had the game stored a lot of different types of data such as player scores, how many times a player had attempted the game, player names, etc. then it would have required a structure in order to make sense of the data that was being saved. As more data is introduced, structure is necessary to make sense of the data.

There are many different data structures for files. Some use commas to separate values, such as the CSV file format which may be familiar to spreadsheet users, but there are other data structures in daily use. For example, HTML (HyperText Markup Language) has been used to write web pages since the web was invented in 1989. HTML structure enables a user to create pages of text, graphics, video, and audio using a framework of tags, which look like <h1>Hello World</h1>, to format and identify content. In programming there are constructs that can be used to store structured data. For example, dictionaries are used to store data using a key reference that enables direct selection of a value from a large dictionary. In the next step you will be introduced to dictionaries and shown how you can use them in your projects.

In the comments section give examples of other real-world human-readable and machine-only data structures and how they are used.

Share this article:

This article is from the free online course:

Programming 103: Saving and Structuring Data

Raspberry Pi Foundation