Home › Curriculum › Technical Foundations › Relational basics and how Odoo stores data
PostgreSQL and SQL for Odoo · 14 min · PostgreSQL 16 / Odoo 20Relational basics and how Odoo stores data
Tables, keys and relations, and how Odoo maps models, fields and relations to PostgreSQL.
In this lesson
- Tables, keys and relations
- How Odoo maps fields to columns
- Metadata tables you'll query
Key points
- model.name → table model_name; stored fields → columns
- Many2one = FK column; One2many = no column; Many2many = relation table
- Translatable fields stored as JSONB; computed non-stored have no column
- ir_model_data, ir_model, ir_model_fields, ir_ui_view, ir_config_parameter
Real-world example
A client couldn't find why a product showed twice in a report. SELECT on product_product grouped by product_tmpl_id showed two variants of one template, one archived but still referenced by an open order. The consultant explained variants, archived the right one properly through the UI, and the report was fixed.
Questions and answers
Which table holds system parameters?
ir_config_parameter.
What columns does every Odoo table have for auditing?
create_uid, create_date, write_uid, write_date.