1. Home
  2. Explore
  3. Computer Science
  4. Data Types and Structures

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Data Types and Structures

Preparing Data for Analysis

Why data preparation matters

A strong analysis begins before calculations or visualizations. Analysts must identify the data that fits the question, understand how it was produced, and prepare it so that it can be used responsibly. Preparation helps determine whether data is relevant, reliable, organized, and appropriate for its intended purpose.

The broader data analysis process consists of six stages:

  1. Ask a question or define the problem.

  2. Prepare the data needed to investigate it.

  3. Process the data so it is ready for analysis.

  4. Analyze it to find patterns and answer the question.

  5. Share findings in a way that meets stakeholders’ needs.

  6. Act on the findings.

Data supports the story an analysis communicates, but that story is only useful when the data is valid for the question and handled carefully. Analysts should consider accuracy, relevance, bias, credibility, privacy, access, and equity.

For example, an analysis of Medicare enrollment and online searches could examine whether enrollment increases over time and how search activity relates to demand. Such an analysis should use relevant and valid data, protect the privacy of people making searches, and consider whether the data and its interpretation treat different groups fairly. Its findings may help medical professionals and patients make better-informed decisions.


How data is generated and collected

Data is information or a collection of facts. It is often generated as a result of people’s activities, especially their online activities, but it can also be produced through observation or deliberate collection.

Data generated through activity

Digital activity produces data in many forms:

  • A digital photograph is a piece of data. It also contains further information, such as its pixels and the colors of those pixels.

  • Texts, emails, searches, video views, social media activity, and mobile-device use contribute to large and growing collections of data.

  • Some data is generated indirectly. For example, websites may use cookies—small files stored on a computer that contain information about a user—to remember preferences or help advertisers infer interests and habits. Cookies can inform advertising without necessarily identifying a person directly.

Data generated online may reveal information about people, so its collection and use should be considered in light of people’s rights, privacy, and ethical responsibilities.

Data generated through collection

Data can also be created or gathered by intentionally collecting information. Common methods include:

  • Forms, questionnaires, and surveys

  • Interviews

  • Observations

  • Scientific measurements or examinations

Examples illustrate how collection serves different purposes:

  • A census agency collects information about a population. The resulting data can help inform decisions about public services such as schools, hospitals, and fire departments.

  • A survey can ask patients about their experiences with telemedicine compared with in-person visits. Organizations can use the results to improve care.

  • In a job interview, an employer collects information about a candidate to support a hiring decision. The candidate can also collect information about the organization to assess whether it is a good fit.

  • Scientists collect data through observations, such as studying animal behavior or examining bacteria under a microscope.

Understanding how data was generated provides context for interpreting it. Understanding collection methods also helps analysts plan efficient and appropriate analyses.


Choosing data for an analysis

A project’s question or business problem usually narrows down which data is useful. An analyst should choose data because it can help answer the question—not simply because it is available.

Data sources and levels of ownership

Data can be classified according to how it was collected and who collected it.

  • First-party data is collected directly by an individual or organization using its own resources. It is often preferred because the analyst can identify where it came from and how it was gathered.

  • Second-party data is collected directly from an organization’s own audience and then sold or shared with another party. For example, an analyst who cannot conduct a traffic study might purchase data collected by an experienced organization.

  • Third-party data comes from outside sources that did not necessarily collect it directly. It may have passed through multiple sources before reaching the analyst, so its provenance and reliability may be less clear.

Second- or third-party data can still be useful. However, all data—regardless of source—should be checked for accuracy and trustworthiness. Analysts should also assess bias and credibility, confirm that the data applies to the question, and ensure that it is approved for use.

Population and sample

A population is the complete set of possible data values relevant to a particular analysis. For a study of city traffic, the population might be all cars in the area being studied.

Collecting data from an entire population can be difficult. A sample is a subset of a population intended to represent it. An analyst might:

  • Observe traffic at one location as a sample of city traffic, or

  • Select a random subset from the available population data.

The appropriate sample depends on the project. The way the sample is selected matters because a sample that does not represent the population can produce misleading conclusions.

Other data-collection considerations

Before collecting data, an analyst should consider:

  • Relevance: Does the data help answer the question? For a traffic investigation, traffic volume by time of day is more directly useful than unrelated financial data.

  • Data type: Is the information stored in a suitable form? Dates stored as dates, for instance, can help reveal which days of the week tend to have high traffic.

  • Time frame: Is an immediate answer needed, or should data be collected over a longer period? An immediate analysis may rely on historical data, meaning data that already exists. A study of traffic patterns over time may require repeated collection and affect other design choices.

  • Permission and ethics: Is the data approved for use, and can it be used without violating people’s rights or privacy?


Data formats and broad classifications

Data can be described in several ways. These classifications help analysts understand what analyses are possible and how data should be organized.

Qualitative and quantitative data

  • Qualitative data describes qualities, categories, or characteristics. It is not naturally counted or measured as a numerical amount. Movie titles and cast members are examples.

  • Quantitative data represents an amount or quantity that can be counted or measured and expressed numerically. A movie’s budget or box-office revenue is an example.

Quantitative data can be further divided into discrete and continuous forms.

Discrete and continuous data

  • Discrete data consists of distinct, countable values, generally with a limited set of possible values. Counts are typical examples. Monetary amounts recorded to the nearest cent also have a discrete representation because they use fixed increments.

  • Continuous data can be measured at increasingly fine levels of precision and can take fractional values within a range. A duration measured with a timer is an example: it could be recorded in minutes with several decimal places.

Nominal and ordinal data

These are two forms of qualitative data:

  • Nominal data consists of categories without an inherent order. Responses such as “yes,” “no,” and “not sure” are nominal; no category is naturally higher or lower than another.

  • Ordinal data consists of categories with an ordered relationship or scale. Ratings from one to five are ordinal because the values indicate a ranking, such as how strongly someone liked a movie.

The spacing between ordinal values should not automatically be treated as equal. An ordered rating communicates relative position, but it does not necessarily show that the difference between adjacent ratings is uniform.

Internal and external data

  • Internal data is held within an organization’s own systems. It may be easier for the organization to collect and is often more familiar to it.

  • External data is generated or held outside the organization. It can be especially valuable when an analysis needs information from many sources.

A company’s data set may combine both. For example, a film studio might have internal data about its own movies but need external data to compare them with movies made by other studios.

Structured and unstructured data

  • Structured data is organized according to a defined format, commonly rows and columns. Spreadsheets and relational databases are common places to store it. Its consistent structure makes it easier to search, query, compare, and analyze.

  • Unstructured data does not fit neatly into a predefined row-and-column format. Audio files, video files, emails, photographs, and social media content are examples.

Unstructured data may still contain internal organization, but its content is not presented in a uniform structure that can be readily analyzed as a conventional table. Much of the data generated today is unstructured. Analysts, however, often receive structured versions or representations of it when it is prepared for analysis.


Structured data, data models, and databases

Structured data is more than information displayed in a grid. It is organized so that its elements and relationships can be understood consistently.

A data element is an individual piece of information, such as a person’s name, an account number, or an address. A data model describes how data elements are organized and how they relate to one another.

Data models help to:

  • Keep information consistent.

  • Show how data is organized.

  • Help analysts and other stakeholders interpret the data for business purposes.

Structured data is well suited to databases because analysts can enter it, query it, and analyze it when needed. It is also generally straightforward to use in visualizations, including charts, graphs, heat maps, and dashboards.

Spreadsheets and relational databases are common sources of structured data. Analysts may extract data from databases using tools such as spreadsheets and SQL. Understanding the organization of a data set is essential before extracting or analyzing it.


Data types in spreadsheets

A data type identifies the kind of value represented by a piece of data. Data types can vary among programming or query languages and database systems. In spreadsheets, three common value types are numbers, text (or strings), and Booleans.

Number data

A number data type represents numerical values that can be used as quantities. In a search-interest data set, for example, numbers might show the relative popularity of search terms over time.

A value such as 100 may represent the peak or maximum relative search interest in the selected time period rather than the actual number of searches. Other values are interpreted relative to that maximum. This distinction matters: a numerical value does not always represent a raw count.

Numbers can sometimes be displayed in different formats, such as percentages or currency, without changing the underlying kind of information.

Text or string data

A text, or string, data type is a sequence of characters and punctuation containing textual information. Examples include:

  • Movie titles

  • Names

  • Categories or descriptions

A value can contain digits but still be treated as text if it is not meant for calculation. Phone numbers and street addresses are examples: arithmetic operations on them are generally not meaningful.

Boolean data

A Boolean data type has two possible logical values: true or false. For example, a spreadsheet formula might determine whether a search-interest value meets a threshold. Each result would indicate whether the condition is true or false.

The displayed words could be changed by a spreadsheet formula, but the information remains Boolean if it still represents one of two logical outcomes.

Data types and errors

A common spreadsheet mistake is confusing a cell’s displayed value with its data type. Calculations that work on numbers may fail when applied to text or other incompatible types. Errors can also result from incorrectly entered values.

Knowing the data type helps an analyst choose suitable calculations and avoid errors. For instance, calculating an average requires numerical values; text labels cannot generally be averaged meaningfully.


Tables, records, fields, and values

A data table, or tabular data, is organized into rows and columns. In spreadsheets, those are usually called rows and columns; when describing structured data more generally, they are often called records and fields.

  • A record is one complete entry in a table, often represented by a row.

  • A field is a category of information represented in a column. In some contexts, “field” may also refer to an individual piece of data.

  • A value is the specific information in a cell at the intersection of a record and a field.

For a playlist:

  • Each song is a record.

  • Song title, artist, duration, and favorite status are fields.

  • A particular song’s title or duration is a value.

Each record in a table should contain the same fields in the same order, so that the same kind of information can be compared across records. Different fields may have different data types. A title is usually text; a duration may be numeric or represented as a time value; and a favorite indicator may be Boolean.

Tables can describe many kinds of things, including clients, products, and invoices. Understanding records, fields, and values helps analysts navigate a data set and interpret what each entry represents.


Wide and long data

Wide and long describe two common ways of arranging data, especially data collected across multiple time points.

Wide data

In wide data, each subject typically occupies one row, and separate columns hold the values of different attributes or time points.

For example, a population table might have:

  • One row for each country.

  • One column for the population in each year.

Wide data makes it easy to compare values across columns. An analyst can quickly compare countries in a given year or compare a country’s values across years.

Long data

In long data, each row represents one subject at one time point. A subject therefore appears in multiple rows when it has data for multiple time points.

A population table in long format might have:

  • A country field.

  • A year field.

  • A population field.

Each country appears once for each year with available data. Long data can be compact and works well when there are multiple variables for each subject at each time point. If another variable—such as average population age—is added, it can be represented with another column rather than adding a separate column for every year.

Choosing between formats

Neither format is always best. The appropriate format depends on the analysis and the tools being used. Analysts may need to transform wide data into long data, or long data into wide data. Recognizing the structure helps an analyst compare information correctly and prepare it for a particular analysis.


Key principles for working with data

  • The data selected should directly support the question or business problem.

  • Data provenance matters: analysts should understand who collected the data and how.

  • Samples should be chosen with care so they represent the population relevant to the analysis.

  • Data must be checked for accuracy, trustworthiness, bias, and credibility, regardless of source.

  • Data types determine which operations are appropriate and help prevent calculation errors.

  • Structured organization—through data models, tables, records, and fields—makes data easier to search and analyze.

  • Privacy, ethics, access, and equity should remain central when data concerns people.

  • Wide and long are alternative arrangements of data; the best choice depends on how the data will be used.

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent