> ## Documentation Index
> Fetch the complete documentation index at: https://docs.devin.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# NoSQL to SQL Migration

> Migrate from NoSQL databases to SQL for improved data consistency and relational integrity

export const PromptBlock = ({children, type, agent, intent, playbookId}) => {
  var utm = 'utm_source=docs&utm_medium=use-case-gallery&utm_campaign=prompt-block';
  var tag = 'docs-use-case-gallery';
  var agentParams = (agent ? '&agent=' + agent : '') + (intent ? '&intent=' + intent : '') + (playbookId ? '&playbookId=' + playbookId : '');
  var label = type === 'schedule' ? 'Schedule in Devin' : type === 'playbook' ? 'Create Playbook' : type === 'knowledge' ? 'Add to Knowledge' : agent === 'advanced' ? 'Try in Devin' : agent === 'dana' ? 'Try in Dana' : agent === 'ada' ? 'Try in Ask Devin' : 'Try in Devin';
  var buildUrl = function (text) {
    var encoded = encodeURIComponent(text);
    if (type === 'schedule') return 'https://app.devin.ai/settings/schedules/create?' + utm + agentParams + '&prompt=' + encoded;
    if (type === 'playbook') return 'https://app.devin.ai/settings/playbooks/create?' + utm + '&body=' + encoded;
    if (type === 'knowledge') return 'https://app.devin.ai/knowledge?' + utm + '&body=' + encoded;
    if (agent === 'ada') return 'https://app.devin.ai/search?' + utm + '&noSubmit=true&prompt=' + encoded;
    return 'https://app.devin.ai/?tags=' + tag + '&' + utm + agentParams + '&prompt=' + encoded;
  };
  const ref = React.useRef(null);
  const [href, setHref] = React.useState('#');
  React.useEffect(() => {
    if (!ref.current) return;
    var codeEl = ref.current.querySelector('pre code');
    if (codeEl) {
      var text = codeEl.textContent.trim();
      if (text) setHref(buildUrl(text));
    }
    var header = ref.current.querySelector('[data-component-part="code-block-header"]');
    if (header && !header.querySelector('.prompt-block-devin-link')) {
      var link = document.createElement('a');
      link.href = href;
      link.target = '_blank';
      link.rel = 'noopener noreferrer';
      link.className = 'prompt-block-devin-link';
      link.style.cssText = 'display:inline-flex;align-items:center;gap:6px;text-decoration:none;color:#fff;font-size:11px;font-weight:500;padding:4px 10px;border-radius:6px;white-space:nowrap;background:#317CFF;transition:background 0.2s;margin-left:8px;';
      link.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg> ' + label;
      link.onmouseenter = function () {
        link.style.background = '#2968D9';
      };
      link.onmouseleave = function () {
        link.style.background = '#317CFF';
      };
      header.appendChild(link);
    }
    var existingLink = ref.current.querySelector('.prompt-block-devin-link');
    if (existingLink && href !== '#') existingLink.href = href;
  });
  return <div className="prompt-block" ref={ref}>{children}</div>;
};

## Overview

Devin can help migrate applications from NoSQL databases to SQL, handling schema design, data transformation, and query refactoring. Whether you're moving from MongoDB to PostgreSQL or DynamoDB to MySQL, Devin can systematically convert your data models, migrate your data, and update your application code to work with relational databases.

<iframe width="840" height="473" src="https://www.youtube.com/embed/KiQJtRIWcK4" title="YouTube video player" className="max-w-full" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen />

## Why Migrate to SQL?

### Data Integrity Benefits

* **ACID compliance**: Ensure data consistency with transactions
* **Referential integrity**: Enforce relationships with foreign keys
* **Schema validation**: Prevent invalid data at the database level
* **Complex queries**: Leverage powerful JOIN operations and aggregations

### Operational Advantages

* **Mature tooling**: Access to decades of SQL optimization and monitoring tools
* **Standardization**: Use industry-standard SQL across different databases
* **Better analytics**: Simplified reporting and business intelligence integration
* **Cost efficiency**: Optimize storage with normalization and indexing

## Common Migration Scenarios

### MongoDB to PostgreSQL

* Convert document collections to normalized tables
* Transform embedded documents into related tables
* Migrate MongoDB queries to SQL with proper JOINs
* Implement indexes for query optimization

### DynamoDB to MySQL

* Map partition keys and sort keys to primary keys
* Convert NoSQL access patterns to SQL queries
* Handle secondary indexes and global tables
* Migrate application code from AWS SDK to SQL drivers

### Schema Design and Normalization

* Analyze NoSQL data structures and relationships
* Design normalized schemas following best practices
* Create migration scripts with data validation
* Implement proper constraints and indexes

## Additional Resources

* [PostgreSQL Documentation](https://www.postgresql.org/docs/)
* [MySQL Documentation](https://dev.mysql.com/doc/)
* [Devin Playbooks](/product-guides/creating-playbooks) - Create reusable migration workflows
* [Devin Knowledge](/product-guides/knowledge) - Store database-specific patterns

## Related Use Cases

* [Migration & Modernization](/use-cases/migration-modernization)
* [Data Analysis](/use-cases/data-analysis)
* [Testing & Refactoring](/use-cases/testing-refactoring)
