Foreign Keys ease SQL statements?
-
Hi, I'm creating a Win Form that uses a MS Access Database. I'm new to database programming and wanted to know what advantages, besides referential integrity, is there to creating a Foreign Key? I'm wondering if creating a Foreign Key helps me with SQL statements in my code? Or would creating Foreign Keys not change SQL statements like this: AND Products.CustomerID=Customers.CustomerID thanks, Ron
-
Hi, I'm creating a Win Form that uses a MS Access Database. I'm new to database programming and wanted to know what advantages, besides referential integrity, is there to creating a Foreign Key? I'm wondering if creating a Foreign Key helps me with SQL statements in my code? Or would creating Foreign Keys not change SQL statements like this: AND Products.CustomerID=Customers.CustomerID thanks, Ron
I can't think of another reason besides referential integrity. Foreign keys are constraints and do not change SQL statements. They just guarantee that Products.CustomerID will match the CustomerID in the Customers table. In other words, you shouldn't be able to delete Customer 1 from the Customers table if Customer 1 exists in the Products table.
-
I can't think of another reason besides referential integrity. Foreign keys are constraints and do not change SQL statements. They just guarantee that Products.CustomerID will match the CustomerID in the Customers table. In other words, you shouldn't be able to delete Customer 1 from the Customers table if Customer 1 exists in the Products table.
Thanks Gerald, I thought that, but wanted to ask anyway. Ron