diff --git a/nova/db/sqlalchemy/api_migrations/migrate_repo/versions/051_nested_resource_providers.py b/nova/db/sqlalchemy/api_migrations/migrate_repo/versions/051_nested_resource_providers.py
new file mode 100644
index 000000000..4745a1341
--- /dev/null
+++ b/nova/db/sqlalchemy/api_migrations/migrate_repo/versions/051_nested_resource_providers.py
@@ -0,0 +1,50 @@
+#    Licensed under the Apache License, Version 2.0 (the "License"); you may
+#    not use this file except in compliance with the License. You may obtain
+#    a copy of the License at
+#
+#         http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+#    License for the specific language governing permissions and limitations
+#    under the License.
+
+from sqlalchemy import Column
+from sqlalchemy import ForeignKey
+from sqlalchemy import Index
+from sqlalchemy import Integer
+from sqlalchemy import MetaData
+from sqlalchemy import Table
+
+
+def upgrade(migrate_engine):
+    meta = MetaData()
+    meta.bind = migrate_engine
+
+    resource_providers = Table('resource_providers', meta, autoload=True)
+    columns_to_add = [
+            ('root_provider_id',
+                Column('root_provider_id', Integer,
+                       ForeignKey('resource_providers.id'))),
+            ('parent_provider_id',
+                Column('parent_provider_id', Integer,
+                       ForeignKey('resource_providers.id'))),
+    ]
+    for col_name, column in columns_to_add:
+        if not hasattr(resource_providers.c, col_name):
+            resource_providers.create_column(column)
+
+    indexed_columns = set()
+    for idx in resource_providers.indexes:
+        for c in idx.columns:
+            indexed_columns.add(c.name)
+
+    if 'root_provider_id' not in indexed_columns:
+        index = Index('resource_providers_root_provider_id_idx',
+                resource_providers.c.root_provider_id)
+        index.create()
+    if 'parent_provider_id' not in indexed_columns:
+        index = Index('resource_providers_parent_provider_id_idx',
+                resource_providers.c.parent_provider_id)
+        index.create()
diff --git a/nova/db/sqlalchemy/api_models.py b/nova/db/sqlalchemy/api_models.py
index 398260699..7e5e7b19f 100644
--- a/nova/db/sqlalchemy/api_models.py
+++ b/nova/db/sqlalchemy/api_models.py
@@ -293,6 +293,10 @@ class ResourceProvider(API_BASE):
         schema.UniqueConstraint('uuid',
             name='uniq_resource_providers0uuid'),
         Index('resource_providers_name_idx', 'name'),
+        Index('resource_providers_root_provider_id_idx',
+              'root_provider_id'),
+        Index('resource_providers_parent_provider_id_idx',
+              'parent_provider_id'),
         schema.UniqueConstraint('name',
             name='uniq_resource_providers0name')
     )
@@ -301,6 +305,13 @@ class ResourceProvider(API_BASE):
     uuid = Column(String(36), nullable=False)
     name = Column(Unicode(200), nullable=True)
     generation = Column(Integer, default=0)
+    # Represents the root of the "tree" that the provider belongs to
+    root_provider_id = Column(Integer, ForeignKey('resource_providers.id'),
+        nullable=True)
+    # The immediate parent provider of this provider, or NULL if there is no
+    # parent. If parent_provider_id == NULL then root_provider_id == id
+    parent_provider_id = Column(Integer, ForeignKey('resource_providers.id'),
+        nullable=True)
 
 
 class Inventory(API_BASE):