Sub topic 4
Data versus Metadata in an Org
This chapter assumes you know what an org is, what a database table and record are, and the basic idea of multi-tenant SaaS. Here you will learn to separate the two kinds of content that live inside an org: data and metadata. The split explains how sandboxes, deployments, and scratch orgs behave.
The two layers
An org holds two kinds of things.
- Data is the business records users create and change: accounts, contacts, opportunities, cases, files.
- Metadata is the configuration that describes how the org is built and how it behaves: custom objects, fields, page layouts, validation rules, flows, Apex classes, permission sets, and so on.
A useful test: if you would not be surprised to see it change many times a day because people are doing their jobs, it is data. If an administrator or developer changes it deliberately to alter how the org works, it is metadata.
| Question | Data | Metadata |
|---|---|---|
| Example | An Account named "Acme" | The Account object's "Industry" field definition |
| Who changes it | End users, integrations | Admins, developers |
| Typical size | Millions of rows | Thousands of components |
| Moved between orgs by | Data Loader, Data Import Wizard, APIs | Change sets, Salesforce CLI, packages |
Why the platform keeps them apart
Salesforce is multi-tenant, so many customers share the same infrastructure. The platform stores each org's metadata separately from its data and reads the metadata at runtime to decide what the data means. A custom field does not create a new database column that you manage. It is a metadata entry that tells the platform how to interpret a slot in the shared data store.
This design is why you can add a field in a running org without downtime, and why a field definition is something you can copy to another org while the records stay behind.
Why it matters in practice
The distinction decides what moves where.
- Deployments move metadata. When you deploy from a sandbox to production, you send components such as a field or an Apex class. You do not send the records created while testing.
- Sandboxes copy metadata from production. Depending on the sandbox type, they also copy some, all, or none of the data. The next chapters cover the types.
- Scratch orgs are built from metadata and start without business data, so you load test data yourself.
Treat configuration as source and data as content. Metadata can live in version control. Data generally should not, because it is large, changes constantly, and often holds personal information.
Common errors
- Assuming a deployment brings data along. A new picklist value deploys, but records that should use it do not appear in the target org.
- Forgetting that some settings are data-like. Items such as certain custom metadata type records and custom settings hold configuration values. Custom metadata type records deploy as metadata. Custom setting values do not, so you must load them separately.
- Testing with production data in a sandbox without a plan. A full copy carries real customer information, so masking and access controls matter.
- Deleting a field and expecting only configuration to disappear. Removing a field definition also affects the data stored under it.
Exercise
You add a custom field "Contract Tier" to Account in a sandbox, then deploy it to production using the Salesforce CLI. Test accounts you created in the sandbox have values in that field. Which of these appears in production after the deploy: the field definition, the test account records, or both?
Show answer
Only the field definition. The field is metadata and the deploy carries it. The test accounts are data, so they stay in the sandbox unless you load them separately.