Sub topic 15
Designing a Catalog and Schema Layout
This chapter assumes you know the Unity Catalog hierarchy (metastore, catalog, schema, table), the difference between managed and external tables, and how GRANT and REVOKE work. Here you combine those pieces into a layout that fits an organization. The goal is a structure that is easy to secure, easy to find things in, and hard to misuse.
What a layout decides
A layout is a set of choices about where objects live and who can touch them. Three earlier ideas drive those choices:
- Catalogs and schemas are the units of grouping. Every table has exactly one catalog and one schema, so the names you pick become part of every query.
- Privileges are inherited downward. A grant on a catalog or schema reaches everything inside it, including objects created later. Group objects by who needs access, and you can grant at a high level.
- Storage is configured per level. Managed storage can be set on the metastore, a catalog, or a schema. The most specific setting wins. Your boundaries for cost and data residency follow the same structure.
The question to ask is: which boundary do I want a single grant, a single storage location, or a single owner to cover?
Choosing what a catalog represents
A catalog is the widest grouping you control. Three patterns are common. Many organizations combine them.
| Pattern | Example catalogs | Strength | Weakness |
|---|---|---|---|
| By environment | `dev`, `staging`, `prod` | Clear separation of test and production data. Grants differ by environment. | The same schema design repeats in each catalog. |
| By business unit or team | `finance`, `marketing`, `hr` | Ownership is obvious. Each team can manage its own catalog. | Cross-team sharing needs explicit grants. |
| By data domain or source | `sales`, `telemetry`, `reference` | Matches how people think about data. | Environments are not separated unless you add them. |
A frequent combination is environment first and domain second, either as prod_sales and dev_sales, or as prod with a sales schema inside. Both work. The trade-off is below.
Catalog per environment, schema per domain
With dev.sales.orders and prod.sales.orders, the schema and table names are identical across environments. Code that uses short names after USE CATALOG can be promoted from dev to prod by changing only the catalog. This is simple when a single team owns the whole environment.
Catalog per environment and domain
With prod_sales.orders.daily style names, each domain gets its own catalog. You can grant, assign managed storage, and set an owner per domain and environment. This scales better when many teams work independently, but it creates more catalogs to manage.
Choose the first pattern for a small organization. Move to the second when separate teams need separate ownership, storage, or grants.
Using schemas for layers and subject areas
Schemas group related tables inside a catalog. Two uses are common.
- By subject area:
sales,customers,inventory. - By data quality layer:
bronzefor raw data,silverfor cleaned data,goldfor data ready for reporting.
You can combine them, for example sales_bronze and sales_gold. Layers matter for security. Raw data often contains fields that only data engineers should see, while the gold layer is safe to share widely. Because a schema-level grant covers every table in it, putting raw and curated tables in different schemas lets you grant SELECT on the curated schema alone.
The following statements create a catalog with layered schemas and give analysts access only to the curated layer.
CREATE CATALOG IF NOT EXISTS prod;
CREATE SCHEMA IF NOT EXISTS prod.sales_bronze;
CREATE SCHEMA IF NOT EXISTS prod.sales_gold;
GRANT USE CATALOG ON CATALOG prod TO `data-analysts`;
GRANT USE SCHEMA ON SCHEMA prod.sales_gold TO `data-analysts`;
GRANT SELECT ON SCHEMA prod.sales_gold TO `data-analysts`;The analysts can read every table in prod.sales_gold, now and in the future. They cannot see tables in prod.sales_bronze, because they hold no privilege there.
Planning grants around groups
Grant to groups, not to individual users. When a person changes roles, you change group membership and leave the grants alone. Name groups by role, such as data-analysts or data-engineers.
A workable pattern for each environment:
- Data engineers own or manage the catalog, and have write privileges in
dev. - A deployment identity (a service principal) writes to
prod, so no individual's account is the only way to change production. - Analysts get read access on curated schemas only.
Remember that USE CATALOG and USE SCHEMA are required on the parent objects before a table-level or schema-level SELECT has any effect. Grant them once at the level where you want the group to start seeing objects.
Ownership
The owner of an object can grant privileges on it and manage it. Set the owner of each catalog to a group or service principal, not to the person who happened to create it. If the creator leaves and still owns the catalog, you have a management gap. Changing ownership early costs less than recovering later.
Choosing managed or external storage per layer
Managed tables are the default. Unity Catalog controls their storage location and file layout, and dropping the table removes its data. External tables point at a path you control, and dropping them leaves the files in place.
A sensible default is:
- Use managed tables for data your Databricks workloads create and own, such as silver and gold layers.
- Use external tables when other systems also read or write the files, when files must stay at an existing path, or when policy requires a specific storage account.
External tables require a storage credential and an external location that covers the path. Plan those along with the catalog layout. An external location should cover a prefix that matches your structure, for example one prefix per environment, so that permission to use the location follows the same boundary as your catalogs.
If a catalog needs its own storage, for cost reporting or because a business unit must keep data in a separate account, set a managed storage location when you create the catalog.
CREATE CATALOG IF NOT EXISTS prod_finance
MANAGED LOCATION 's3://example-finance-bucket/uc/managed';The bucket name is a placeholder. The path must fall under an external location that you are allowed to use. Managed tables created in prod_finance then store their files there instead of in the metastore's default storage.
Naming conventions
Consistent names make queries readable and support automation.
- Use lowercase letters, digits, and underscores. Avoid spaces and hyphens, since they force backtick quoting.
- Keep names short and meaningful.
ordersis better thantbl_orders_v2_final. - Put the environment in a catalog name or as its own catalog, not in table names. Table names should stay the same when you promote code.
- Decide once whether names are singular or plural, and keep to it.
Putting the layout together
A small organization might use this structure.
The matching privileges follow the same shape. Engineers hold write access across dev. Analysts hold USE CATALOG on prod, plus USE SCHEMA and SELECT on prod.gold only.
You can verify the result at any point using the inspection tools from the previous chapter.
SHOW SCHEMAS IN prod;
SHOW GRANTS ON SCHEMA prod.gold;
SELECT table_schema, table_name, table_type
FROM prod.information_schema.tables
WHERE table_schema = 'gold';Common mistakes
- Granting on a catalog when a schema would do. A catalog-level
SELECTexposes every schema, including raw ones. Grant at the lowest level that matches the need. - Forgetting
USE CATALOGorUSE SCHEMA. A user withSELECTon a table still gets a permission error without them. - Granting to individuals. The grants become impossible to audit as people move teams.
- Leaving ownership with the creator. Transfer ownership to a group or service principal.
- Mixing raw and curated tables in one schema. You then cannot share one without the other using a single grant.
- Creating external tables outside any external location. The statement fails, or you end up with a path no one is allowed to manage.
- Encoding the environment in table names. Promotion then needs code changes beyond the catalog name.
Review checklist
Before you adopt a layout, check each item.
- Each environment is separated by a catalog.
- Raw and curated data are in different schemas.
- Every grant goes to a group or service principal.
- Every catalog has an owner that is not an individual user.
- Managed storage and external locations match your catalog boundaries.
- Names follow a single convention.
Exercise
A company has a finance team and a marketing team. Each must keep its data in its own storage account and manage its own access. Both need separate dev and prod data. Propose a catalog layout and say how you would give a finance-analysts group read access to the curated finance data in production only.
Show answer
Create one catalog per team and environment: dev_finance, prod_finance, dev_marketing, prod_marketing. Set a managed location on each catalog that points to the team's own storage, covered by an external location. Inside prod_finance, use schemas such as bronze and gold. Then grant USE CATALOG on prod_finance, USE SCHEMA on prod_finance.gold, and SELECT on prod_finance.gold to finance-analysts. They get nothing on bronze, on dev_finance, or on the marketing catalogs.
Exercise
An analyst has SELECT on prod.gold.orders but gets a permission error when running SELECT * FROM prod.gold.orders. Name two likely missing privileges and say which statement fixes each.
Show answer
The analyst may lack USE CATALOG on prod or USE SCHEMA on prod.gold. Fix them with GRANT USE CATALOG ON CATALOG prod TO <group> and GRANT USE SCHEMA ON SCHEMA prod.gold TO <group>.