2ndQuadrant is now part of EDB

Bringing together some of the world's top PostgreSQL experts.

2ndQuadrant | PostgreSQL
Mission Critical Databases
  • Contact us
  • EN
    • FR
    • IT
    • ES
    • DE
    • PT
  • Support & Services
  • Products
  • Downloads
    • Installers
      • Postgres Installer
      • 2UDA – Unified Data Analytics
    • Whitepapers
      • Business Case for PostgreSQL Support
      • Security Best Practices for PostgreSQL
    • Case Studies
      • Performance Tuning
        • BenchPrep
        • tastyworks
      • Distributed Clusters
        • ClickUp
        • European Space Agency (ESA)
        • Telefónica del Sur
        • Animal Logic
      • Database Administration
        • Agilis Systems
      • Professional Training
        • Met Office
        • London & Partners
      • Database Upgrades
        • Alfred Wegener Institute (AWI)
      • Database Migration
        • International Game Technology (IGT)
        • Healthcare Software Solutions (HSS)
        • Navionics
  • Postgres Learning Center
    • Webinars
      • Upcoming Webinars
      • Webinar Library
    • Whitepapers
      • Business Case for PostgreSQL Support
      • Security Best Practices for PostgreSQL
    • Blog
    • Training
      • Course Catalogue
    • Case Studies
      • Performance Tuning
        • BenchPrep
        • tastyworks
      • Distributed Clusters
        • ClickUp
        • European Space Agency (ESA)
        • Telefónica del Sur
        • Animal Logic
      • Database Administration
        • Agilis Systems
      • Professional Training
        • Met Office
        • London & Partners
      • Database Upgrades
        • Alfred Wegener Institute (AWI)
      • Database Migration
        • International Game Technology (IGT)
        • Healthcare Software Solutions (HSS)
        • Navionics
    • Books
      • PostgreSQL 11 Administration Cookbook
      • PostgreSQL 10 Administration Cookbook
      • PostgreSQL High Availability Cookbook – 2nd Edition
      • PostgreSQL 9 Administration Cookbook – 3rd Edition
      • PostgreSQL Server Programming Cookbook – 2nd Edition
      • PostgreSQL 9 Cookbook – Chinese Edition
    • Videos
    • Events
    • PostgreSQL
      • PostgreSQL – History
      • Who uses PostgreSQL?
      • PostgreSQL FAQ
      • PostgreSQL vs MySQL
      • The Business Case for PostgreSQL
      • Security Information
      • Documentation
  • About Us
    • About 2ndQuadrant
    • 2ndQuadrant’s Passion for PostgreSQL
    • News
    • Careers
    • Team Profile
  • Blog
  • Menu Menu
You are here: Home1 / Blog2 / Webinars3 / Webinar: Fantastic Data Types and Where to Use Them [Follow Up]
Webinar: Fantastic Data Types and Where to Use Them
Bilal Ibrar

Webinar: Fantastic Data Types and Where to Use Them [Follow Up]

June 26, 2020/0 Comments/in Webinars /by Bilal Ibrar

PostgreSQL has fantastic data types such as ENUM, ARRAY, and JSON, to name a few. These data types were added to cover use cases that were not easily solved with the existing types. Due to their post-relational nature, they remain unusual and even strange to some developers, but once you learn them, you can create unexpected solutions to specific use cases.

For instance, ENUM types are extremely good defining constraints to column values, providing a more descriptive design of your business model. JSON objects can store a variable amount of fields where it is not possible to define traditional tables.

In order to explore this topic in detail, 2ndQuadrant arranged a live webinar “Fantastic Data Types and Where to Use Them”. The session was hosted by Boriss Mejías, PostgreSQL Consultant, and Trainer.

Those who weren’t able to attend the live webinar can now view the recording here.

Due to limited time, some of the questions were not answered during the live webinar, so answers by the host are provided below:


Question: If we have a table with two columns, id and JSON, how can we correct that bad use of JSON?

Answer:  Note that we consider this as a bad use because all columns are put inside a JSONB object, when some of the fields have their own column. The idea is to identify which fields are present in all JSONB objects (or almost all of them), take them out of the JSONB, and put them in their own column. You will end up with a table with: id, a set of columns that belongs to almost all objects, and then a JSONB objects for the variable fields.

 

Question: It is possible in JSONB type to have differen estructure amog rows? For example one row is {“name”:”nombre”} an other row in the same table, same column is {“name”:”nombre”,”lastname”:”apellido”}

Answer:  Yes, it’s possible. The main advantage of the JSONB objects is to have a variable set of fields.

 

Question: When defining an ENUM type field, what space does it occupy each value? 4 bytes?

Answer:  It’s always 4 bytes, regardless the values you put on the ENUM

 

Question: When defining an ENUM type field, what space does it occupy each value? 4 bytes?

Answer:  It’s always 4 bytes, regardless the values you put on the ENUM

 

Question: When making the comparison you should put…

WHERE mood = ‘happy’

OR

WHERE mood = 1?

Answer:  WHERE mood = ‘happy’. That’s one of the advantages of ENUM. You do not worry about the internal implementation, you just used the values that make sense for your application logic. The results from the SELECT query will also have the values ‘meh’, ‘cool’, ‘happy’, directly. You don’t need to join tables or transform from integers to values.


To be the first to know about upcoming PostgreSQL webinars by 2ndQuadrant, visit our Webinars page.

For any questions, comments, or feedback, please visit our website or send an email to [email protected].

Tags: PostgreSQL, webinars
Share this entry
  • Share on Facebook
  • Share on Twitter
  • Share on WhatsApp
  • Share on LinkedIn
0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Search

Get in touch with us!

Recent Posts

  • Random Data December 3, 2020
  • Webinar: COMMIT Without Fear – The Beauty of CAMO [Follow Up] November 13, 2020
  • Full-text search since PostgreSQL 8.3 November 5, 2020
  • Random numbers November 3, 2020
  • Webinar: Best Practices for Bulk Data Loading in PostgreSQL [Follow Up] November 2, 2020

Featured External Blogs

Tomas Vondra's Blog

Our Bloggers

  • Simon Riggs
  • Alvaro Herrera
  • Andrew Dunstan
  • Craig Ringer
  • Francesco Canovai
  • Gabriele Bartolini
  • Giulio Calacoci
  • Ian Barwick
  • Marco Nenciarini
  • Mark Wong
  • Pavan Deolasee
  • Petr Jelinek
  • Shaun Thomas
  • Tomas Vondra
  • Umair Shahid

PostgreSQL Cloud

2QLovesPG 2UDA 9.6 backup Barman BDR Business Continuity community conference database DBA development devops disaster recovery greenplum Hot Standby JSON JSONB logical replication monitoring OmniDB open source Orange performance PG12 pgbarman pglogical PG Phriday postgres Postgres-BDR postgres-xl PostgreSQL PostgreSQL 9.6 PostgreSQL10 PostgreSQL11 PostgreSQL 11 PostgreSQL 11 New Features postgresql repmgr Recovery replication security sql wal webinar webinars

Support & Services

24/7 Production Support

Developer Support

Remote DBA for PostgreSQL

PostgreSQL Database Monitoring

PostgreSQL Health Check

PostgreSQL Performance Tuning

Database Security Audit

Upgrade PostgreSQL

PostgreSQL Migration Assessment

Migrate from Oracle to PostgreSQL

Products

HA Postgres Clusters

Postgres-BDR®

2ndQPostgres

pglogical

repmgr

Barman

Postgres Cloud Manager

SQL Firewall

Postgres-XL

OmniDB

Postgres Installer

2UDA

Postgres Learning Center

Introducing Postgres

Blog

Webinars

Books

Videos

Training

Case Studies

Events

About Us

About 2ndQuadrant

What does 2ndQuadrant Mean?

News

Careers 

Team Profile

© 2ndQuadrant Ltd. All rights reserved. | Privacy Policy
  • Twitter
  • LinkedIn
  • Facebook
  • Youtube
  • Mail
How to use Neural Network Machine Learning model with 2UDA – PostgreSQL and... Bulk transactions with RESTful CRUD API using PostgreSQL and Spring Boot Bulk transactions with RESTful CRUD API using PostgreSQL and Spring Boot 
Scroll to top
×