What is a schema in a database?

Answer

A schema is the logical structure that defines the organization of data in a database — the blueprint of tables, columns, data types, constraints, indexes, views, stored procedures, and relationships. It represents what data can be stored and how it is organized, without containing the actual data. In PostgreSQL and SQL Server, schemas are also namespaces that group database objects (tables, views) under a name (e.g., public.users, hr.employees). Schemas allow multiple logical groups of objects in one database, useful for multi-tenant applications or separating concerns (e.g., app, analytics, audit).