---
title: Structured data models
framework: Technology Overviews
role: article
path: technologyoverviews/structured-data-models
---

# Structured data models

Build a structured data model for your app, and persist that data model to disk or iCloud.

## Build a structured model with modern Swift types

To manage even moderate amounts of data, you need an efficient system for storing and accessing it. You also need a system that’s easy to use and integrates with your app’s existing types. SwiftData and Core Data provide database-level features, without requiring an actual database. And when you do need a database to manage your content, SQLite is available on all Apple platforms. Build a structured model with modern Swift types If you’re building your app using SwiftUI, SwiftData makes a great companion for managing your data. With SwiftData, you can focus on building your app’s data structures first, and add persistence and other data management features second. That’s because SwiftData infers information about your data structures from the structures themselves. All you do is annotate your data structures with Model your schema with SwiftData. You can use SwiftData to save your data to a local disk or to someone’s Syncing model data across a person’s devices. In your code, identify groups of objects you want to store together and put them into a ModelContainer. Store all of your objects in one container or create multiple containers to manage different types of data separately. Retrieve objects from disk using a Preserving your app’s model data across launches. Because SwiftData works well with SwiftUI, you can incorporate queries directly into your app’s views and fetch your content there. Like any modern data management system, SwiftData also supports the features that you need to ensure the integrity of your data. Add Concurrency support to your types to ensure fetch and save operations behave correctly in threaded code. The framework also provides built-in support for Reverting data changes using the undo manager, so people can revert unwanted changes. Build a structured model with any language If you’re not using SwiftUI for your interface, or if you prefer to work in Objective-C, build your data model using Core Data. Core Data offers the same basic capabilities as SwiftData, including object-level management of data, query-based fetches, undo support, Mirroring a Core Data store with CloudKit, and more. With Core Data, you build the schema for your data model visually using Xcode’s Modeling data. Specify the entities for your data model and configure the attributes and relationships of those entities using this tool. At runtime, create NSManagedObject from the entities in your schema, put those objects in a Core Data stack and save them to disk using a NSManagedObjectContext. Use the managed object context to coordinate other tasks, too, such as undoManager. Store data using SQLite If you’re already familiar with SQL databases, or simply need a lightweight and reliable database engine to manage large amounts of data, use SQLite. This database engine is available in the SDK for all Apple platforms, so you can use the same code for all versions of your app. Use your code to store your app’s on-disk content, or to deliver content to your app over the network.
