title: How do I write my FK value in a different table? C# | SQLite
body: <p>I'm working on a school project where I am creating a client management system.   Due to a requirement, I was required to change my database schema from using 1 table to using 2. Currently, I am able to write to both tables in my database, however, I am having trouble getting the concepts of foreign keys.  I have very limited SQL experience. My current execute statements are writing to both my tables except my the client ID column in the MedicalInformation table.  It is showing null and I'm not sure how I should proceed from here.</p>
  <pre><code>cnn.Execute(&quot;INSERT INTO ClientInformation (FirstName, MiddleInitial, LastName, Phone, Email, Address, City, State, Zip, DateOfBirth, Occupation, Employer, EmergencyContact, EmergencyContactRelationship, EmergencyContactPhone) &quot; +
              &quot;VALUES (@FirstName, @MiddleInitial, @LastName, @Phone, @Email, @Address, @City, @State, @Zip, @DateOfBirth, @Occupation, @Employer, @EmergencyContact, @EmergencyContactRelationShip, @EmergencyContactPhone)&quot;, client);
  
  
  cnn.Execute(&quot;INSERT INTO MedicalInformation (CurrentMedications, ChronicPain, ChronicPainWhere, OrthopedicPain, OrthopedicPainWhere, Pregnant, PreferedPressureLight, PreferedPressureMedium, PreferedPressureDeep, Allergies, AllergiesWhat, Cancer, HeadacheMigraine, Arthritis, Diabetes, JointReplacement, HighLowBloodPressure, Neuropathy, Fibromyalgia, Stroke, HeartAttack, KidneyDysfunction, BloodClots, Numbness, SprainsStrains, AreasOfDiscomfort) &quot; +
              &quot;VALUES (@CurrentMedication, @ChronicPain, @ChronicPainWhere, @OrthopedicPain, @OrthopedicPainWhere, @Pregnant, @PeferredPressureLight, @PeferredPressureMedium, @PeferredPressureDeep, @Allergies, @AllergiesWhat, @Cancer, @HeadacheMigraine, @Arthritis, @Diabetes, @JointReplacement, @HighLowBloodPressure, @Neuropathy, @Fibromyalgia, @Stroke, @HeartAttack, @KidneyDysfunction, @BloodClots, @Numbness, @SprainsStrains, @AreasOfDiscomfort) &quot;, client.MedicalInfo);
  </code></pre>
  <p>This is a portion of the tables</p>
  <pre><code>CREATE TABLE &quot;MedicalInformation&quot; (
      &quot;_ID&quot;   INTEGER NOT NULL UNIQUE,
      &quot;Client_ID&quot; INTEGER,
      
      PRIMARY KEY(&quot;_ID&quot; AUTOINCREMENT),
      FOREIGN KEY(&quot;Client_ID&quot;) REFERENCES &quot;ClientInformation&quot;(&quot;Client_Id&quot;)
  );
  
  CREATE TABLE &quot;ClientInformation&quot; (
      &quot;Client_Id&quot; INTEGER NOT NULL UNIQUE,
     
      PRIMARY KEY(&quot;Client_Id&quot; AUTOINCREMENT)
  );
  </code></pre>
  <p>My clientinfo class</p>
  <pre><code>public class ClientInformation
      {
          //Client Information
          public int Client_ID { get; set; }
          public string FirstName { get; set; }
          public string MiddleInitial { get; set; }
          public string LastName { get; set; }
          public string Phone { get; set; }
          public string Email { get; set; }
          public string Address { get; set; }
          public string City { get; set; }
          public string State { get; set; }
          public string Zip { get; set; }
          public string DateOfBirth { get; set; }
          public string Occupation { get; set; }
          public string Employer { get; set; }
          public string EmergencyContact { get; set; }
          public string EmergencyContactRelationship { get; set; }
          public string EmergencyContactPhone { get; set; }
          public MedicalInformation MedicalInfo { get; set; }
          public ClientInformation(string firstname, string middleinitial, string lastname, string phone, string email, string address, string city, string state, string zip, string dateofbirth, string occupation, string employer,
          string emergencycontact, string emergencycontactrelationship, string emergencycontactphone, MedicalInformation clientMedicainfo)
          {
              this.FirstName = firstname;
              this.MiddleInitial = middleinitial;
              this.LastName = lastname;
              this.Phone = phone;
              this.Email = email;
              this.Address = address;
              this.City = city;
              this.State = state;
              this.Zip = zip;
              this.DateOfBirth = dateofbirth;
              this.Occupation = occupation;
              this.Employer = employer;
              this.EmergencyContact = emergencycontact;
              this.EmergencyContactRelationship = emergencycontactrelationship;
              this.EmergencyContactPhone = emergencycontactphone;
              this.MedicalInfo = clientMedicainfo;
          }
  
      }
  </code></pre>