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
  • 21,987
  • 13
  • 41
  • 69
sai
  • 71
  • 1
  • 1
  • 9

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,184
  • 8
  • 25