Recent

Author Topic: SQLite: Several foreign keys  (Read 3076 times)

vice

  • New Member
  • *
  • Posts: 28
SQLite: Several foreign keys
« on: October 13, 2008, 04:09:53 pm »
If I want to create a simple master/detail relationship of one-to-many, it is easy:

Tables and fields:

Contact: Code, Name <-- Master table
Phone: Number, Contact (Contact is a foreign key reference to the primary key column in the Contact table) <-- Detail table

Contact TDataSource properties:
 - DataSet: ContactDataset
 - Name: ContactDataSource

Contact TSqlite3Dataset properties:
 - Name: ContactDataset
 - TableName: Contact

Phone TDataSource properties:
 - DataSet: PhoneDataset
 - Name: PhoneDataSource

Contact TSqlite3Dataset properties:
 - Name: PhoneDataset
 - TableName: Phone
 - IndexFieldNames: Contact
 - MasterFields: Code
 - MasterSource: ContactDataSource

But, if I want to create a master/detail relationship of one-to-many with several foreign keys, how I do it?

For example I want to create this relationship:

Contact: Code, Name <-- Master table
Company: Code, Name <-- Master table
Phone: Number, Contact, Company (Contact and Company are foreigns keys) <-- Detail table

How I do it?

Best regards.

 

TinyPortal © 2005-2018