JSON Basics
23 Questions
2 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

What is JSON an abbreviation for?

  • Java Object Notation
  • Just Object Notation
  • Java Scripting Object Notation
  • JavaScript Object Notation (correct)
  • JSON objects can have object IDs.

    False

    What are the key-value pairs in JSON objects?

    attribute name and value

    JSON is widely used for data exchange in modern applications, especially in _______________ services.

    <p>web</p> Signup and view all the answers

    What is the type of data structure used to store multiple values in JSON?

    <p>Array</p> Signup and view all the answers

    SQL extensions are not available for JSON data types.

    <p>False</p> Signup and view all the answers

    Match the JSON data type with its description:

    <p>String = A sequence of characters Integer = A whole number Real = A decimal number Object = A key-value map</p> Signup and view all the answers

    What is the main advantage of using semi-structured data in data exchange?

    <p>It enables data exchange between applications</p> Signup and view all the answers

    XML is a relatively new notation for semi-structured data.

    <p>False</p> Signup and view all the answers

    What are some examples of semi-structured data models?

    <p>JSON and XML</p> Signup and view all the answers

    XML stands for ______________________ Markup Language.

    <p>Extensible</p> Signup and view all the answers

    Why may the relational model's requirement of atomic data types be an overkill in some applications?

    <p>Because it may not be necessary for storing complex data</p> Signup and view all the answers

    Match the following semi-structured data models with their characteristics:

    <p>JSON = Widely used in web-services XML = Uses tags to mark up text Semi-structured Data = Schema changes often Relational Model = Requires atomic data types</p> Signup and view all the answers

    What is a characteristic of semi-structured data models?

    <p>Flexible schema</p> Signup and view all the answers

    JSON is a document format.

    <p>False</p> Signup and view all the answers

    What is the purpose of JSON_agg aggregate function in PostgreSQL?

    <p>To create a JSON collection using aggregation</p> Signup and view all the answers

    In JSON, character encoding is strictly _______________.

    <p>UNICODE</p> Signup and view all the answers

    Match the following data types with their descriptions:

    <p>Arrays = Widely used for scientific and monitoring applications Multisets = Modelled using non-first-normal-form (NFNF) data model Key-value map = Store a set of key-value pairs Sets = E.g., {‘basketball, ‘La Liga’, ‘cooking’, ‘anime’, ‘jazz’}</p> Signup and view all the answers

    JSON has namespaces.

    <p>False</p> Signup and view all the answers

    What is an example of an array database?

    <p>All of the above</p> Signup and view all the answers

    In JSON, the _______________ function is used to generate JSON from relational data.

    <p>json.build_object</p> Signup and view all the answers

    What is the purpose of an object-relational mapping (ORM) system?

    <p>To specify mapping between programming language objects and database tuples</p> Signup and view all the answers

    What is a characteristic of JSON?

    <p>Not a document format</p> Signup and view all the answers

    Study Notes

    JSON

    • JSON is a minimal, textual, language-independent representation widely used for data exchange.
    • It is a notation for representing data in a format that is easy for humans to read and write.
    • JSON is versionless and does not have namespaces, it uses context to avoid ambiguity.
    • Character encoding is strictly Unicode.
    • JSON is not a document format and is not a markup language.

    Generating JSON from Relational Data

    • JSON can be generated from relational data using object-relational mapping.
    • Example: json.build_object(‘ID’, 12345, ‘name’, ‘Einstein’)
    • JSON collections can be created using aggregation functions such as json_agg in PostgreSQL.

    Semi-Structured Data Models

    • Semi-structured data models have flexible schemas, allowing each tuple to have a different set of attributes.
    • They support multivalued data types, such as sets, multisets, and key-value maps.
    • Examples: set of interests {‘basketball, ‘La Liga’, ‘cooking’, ‘anime’, ‘jazz’}, key-value map {(brand, Apple), (ID, MacBook Air), (size, 13), (color, silver)}.
    • Operations on maps: put(key, value), get(key), delete(key).

    Arrays

    • Arrays are widely used for scientific and monitoring applications.
    • Examples: readings taken at regular intervals can be represented as an array of values instead of (time, value) pairs.
    • Array databases provide specialized support for arrays, such as compressed storage and query language extensions.
    • Examples of array databases: Oracle GeoRaster, PostGIS, SciDB.

    Object-Relational Data Model

    • The object-relational data model provides a richer type system with complex data types and object orientation.
    • Applications are often written in object-oriented programming languages, which do not match the relational type system.
    • Approaches for integrating object-orientation with databases include:
      • Building an object-relational database by adding object-oriented features to a relational database.
      • Automatically converting data between programming language models and relational models using object-relational mapping.
      • Building an object-oriented database that natively supports object-oriented data and direct access from programming languages.

    Object-Relational Database Systems

    • User-defined types can be created using object-relational database systems.
    • Table types can be created using array and multiset data types.
    • Example: create type Person (ID varchar(20) primary key, name varchar(20), address varchar(20)) ref from(ID); create table people of Person;

    Type and Table Inheritance

    • Type inheritance allows for the creation of new types based on existing types.
    • Example: create type Student under Person (degree varchar(20)); create type Teacher under Person (salary integer);
    • Table inheritance syntax in PostgreSQL and Oracle: create table students (degree varchar(20)) inherits people; create table teachers (salary integer) inherits people;

    Reference Types

    • Creating reference types: create type Person (ID varchar(20) primary key, name varchar(20), address varchar(20)) ref from(ID); create table people of Person;
    • Using references in path expressions: select head->name, head->address from departments;

    Object-Relational Mapping

    • Object-relational mapping (ORM) systems allow for the specification of mapping between programming language objects and database tuples.
    • Automatic creation of database tuples upon creation of objects.
    • Automatic update/delete of database tuples when objects are updated/deleted.
    • Interface to retrieve objects satisfying specified conditions.
    • Examples: Hibernate ORM for Java, Django ORM for Python.

    XML

    • XML: Extensible Markup Language.
    • Earlier generation notation, still used extensively.
    • XML uses tags to mark up text.
    • Example: Intro.to Computer Science “..” specifies the parent.doc(name) returns the root of a named document.

    Studying That Suits You

    Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

    Quiz Team

    Description

    This quiz covers the basics of JSON, including its features, versions, and how it is used to represent data. It also touches on generating JSON from relational data.

    More Like This

    JSON Question Format
    3 questions

    JSON Question Format

    SteadiestOceanWave avatar
    SteadiestOceanWave
    JSON Data Format and Representation Quiz
    3 questions
    Python Programming and JSON Quiz
    6 questions
    Use Quizgecko on...
    Browser
    Browser