0

I am using SQL Server database and Django. I have a Database named as Person Database and Other database as Student Database. In Person database I created models, but in Student database there are no models because the tables and data are already existing. So I am getting data of Student database using Pyodbc. Now I am creating a new model in Person database where I need to create a foreign key for student database. Can anyone help me out how to do it.

Dale K
  • 25,246
  • 15
  • 42
  • 71
sai
  • 151
  • 1
  • 2
  • 10

1 Answers1

0

You cannot create a Foreign Key relation in between tables of different databases. Foreign Key relations can only be created between tables of the same database. There is a workaround on this, although it is not recommended. Please refer this answer.

Mehran
  • 1,264
  • 10
  • 27