title: Combine two unrelated tables/models with same primary key in Django
body: <p>I have two unrelated tables with the same primary key.</p>
  
  <pre><code>ip            mac
  11.11.11.11   48-C0-09-1F-9B-54
  33.33.33.33   4E-10-A3-BC-B8-9D
  44.44.44.44   CD-00-60-08-56-2A
  55.55.55.55   23-CE-D3-B1-39-A6
  
  ip            type     owner
  22.22.22.22   laptop   John Doe
  33.33.33.33   server   XYZ Department
  44.44.44.44   VM       Mary Smith
  66.66.66.66   printer  ZWV Department
  </code></pre>
  
  <p>The first table is automatically refreshed every minute. I can't change the database structure or the script that populates it.</p>
  
  <p>Both tables have <code>ip</code> as PRIMARY KEY.</p>
  
  <p>In a view, I would like to display a table like this:</p>
  
  <pre><code>ip           mac               type    owner          Alert
  11.11.11.11  48-C0-09-1F-9B-54                        Unauthorized
  55.55.55.55  23-CE-D3-B1-39-A6                        Unauthorized
  22.22.22.22                    laptop  John Doe       Down
  66.66.66.66                    printer ZWV Department Down
  33.33.33.33  4E-10-A3-BC-B8-9D server  XYZ Department OK
  44.44.44.44  CD-00-60-08-56-2A VM      Mary Smith     OK
  </code></pre>
  
  <p>How can I model this? Should I make one of the two primary keys a foreign key into the other one?</p>
  
  <p>Once the code is in operation, there will be lots of data, so I want to make sure it's fast enough.</p>
  
  <p>What is the fastest way to retrieve the data?</p>
  
  <hr>
  
  <p><strong>Update:</strong></p>
  
  <p>I tried using <code>OneToOneField</code> for the second table.</p>
  
  <p>This helps me get records that are in both tables, and the records for unauthorized devices (IPs missing in second table):</p>
  
  <pre><code>ip           mac               type    owner          Alert
  11.11.11.11  48-C0-09-1F-9B-54                        Unauthorized
  55.55.55.55  23-CE-D3-B1-39-A6                        Unauthorized
  33.33.33.33  4E-10-A3-BC-B8-9D server  XYZ Department OK
  44.44.44.44  CD-00-60-08-56-2A VM      Mary Smith     OK
  </code></pre>
  
  <p>but I can't get the devices that are down (IP's missing in first table):</p>
  
  <pre><code>22.22.22.22                    laptop  John Doe       Down
  66.66.66.66                    printer ZWV Department Down
  </code></pre>
  
  <p>I asked for help <a href="https://stackoverflow.com/questions/55874502">here</a>, but it seems it can't be done with <code>OneToOneField</code></p>