I think the main reason is for data integrity. If you have a relationship between two tables invoice and invoice_item
. You won’t be able to add an invoice item that does not related to an invoice. This is what you want!
It’s called referential integrity. It can get pretty messy in your database if you don’t have foreign keys because you could delete and corrupt your data easily.
e.g. You could delete invoice and not it’s corresponding invoice items. This is considered bad.
I think this gives you something to go on.
Related Posts:
- MySQL Error: : ‘Access denied for user ‘root’@’localhost’
- What is the difference between “INNER JOIN” and “OUTER JOIN”?
- What is the difference between “INNER JOIN” and “OUTER JOIN”?
- ORA-00904: invalid identifier
- Self Join to get employee manager name
- MySQL Error: : ‘Access denied for user ‘root’@’localhost’
- Case statement in MySQL
- How do you trouble shoot a “Data type mismatch in criteria expression” error in MS Access 2010?
- What is the difference between JOIN and UNION?
- Error Code: 2013. Lost connection to MySQL server during query
- how to drop partition without dropping data in MySQL?
- How to SUM two fields within an SQL query
- The ALTER TABLE statement conflicted with the FOREIGN KEY constraint
- What is it exactly a BLOB in a DBMS context
- The backend version is not supported to design database diagrams or tables
- Simulate CREATE DATABASE IF NOT EXISTS for PostgreSQL?
- “You tried to execute a query that does not include the specified aggregate function”
- Postgres Error: More than one row returned by a subquery used as an expression
- How do I reset a sequence in Oracle?
- MySQL equivalent of DECODE function in Oracle
- what is the difference between triggers, assertions and checks (in database)
- Solutions for INSERT OR UPDATE on SQL Server
- How do I count unique items in field in Access query?
- “select * into table” Will it work for inserting data into existing table
- SQL WITH clause example [duplicate]
- The wait operation timed out. ASP
- SQL query to select dates between two dates
- Must declare the scalar variable
- How can I do a FULL OUTER JOIN in MySQL?
- How do I escape a single quote in SQL Server?
- How to update multiple columns in single update statement in DB2
- T-SQL split string based on delimiter
- Finding duplicate values in a SQL table
- MySQL Cannot Add Foreign Key Constraint
- How do I restore a dump file from mysqldump?
- Oracle error : ORA-00905: Missing keyword
- How do I import an SQL file using the command line in MySQL?
- How do I do multiple CASE WHEN conditions using SQL Server 2008?
- Difference between JOIN and INNER JOIN
- MySQL Multiple Joins in one query?
- “CASE” statement within “WHERE” clause in SQL Server 2008
- ORA-00972 identifier is too long alias column name
- What is the difference between Scope_Identity(), Identity(), @@Identity, and Ident_Current()?
- Combining “LIKE” and “IN” for SQL Server
- 1052: Column ‘id’ in field list is ambiguous
- 1052: Column ‘id’ in field list is ambiguous
- Oracle – ORA-01489: result of string concatenation is too long [duplicate]
- SQL Server WITH statement
- Oracle “Partition By” Keyword
- What is the equivalent of ‘describe table’ in SQL Server?
- Add a column with a default value to an existing table in SQL Server
- SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax — PHP — PDO [duplicate]
- Using group by on multiple columns
- How do you force mysql LIKE to be case sensitive?
- What is the difference between a stored procedure and a view?
- Bulk load data conversion error (truncation)
- How to order by with union in SQL?
- PostgreSQL create table if not exists
- DATEDIFF function in Oracle
- How to do a batch insert in MySQL
- GROUP BY and COUNT using ActiveRecord
- MySQL – Get row number on select
- How to truncate the text returned for a column in a MySQL query
- Display data from a non wordpress database on a page template
- How to auto login user again after change user_login
- Bulk Update of Custom Post Type Post Status through SQL
- How do I add indexes to WordPress Database?
- How To Write An Inner Join With WP Query
- Block search SQL from happening
- Update user_login, user_nicename, and display_name
- Change sticky status of posts from phpMyAdmin
- WordPress and MySQL: how to transfer Meta_key and Meta_Value from one post_id to another
- Transferring working local PHP site to wordpress – with database (MySQL)
- Create table from array with prepare
- How to import a Typo3 database to a wordpress site?
- Does deleting a Plugin via the WordPress admin ‘completely’ remove the code?
- Is it possible to query from external database? [duplicate]
- Is it possible to have more than 1 MySQL database in my WordPress blog?
- Using AND and bracket grouping in SQL not working
- How to Assign / Move all Deleted post to a category
- Delete/Replace words from X to Y in post content
- How to delete a particular row in a database table
- Clean up very big and very dirty database
- Getting value from database table depending on field value
- How can I convert everything from category X to have post format Link
- custom tables in wordpress Database? (can i just create them with sql?)
- Bulk delete WordPress Post and all metadata, etc using SQL query
- Accidently changed the GUID
- Translating WP query into to SQL query
- Reset post IDs with all post meta
- Help posting values to DB on submit using $wpdb->query
- Alter the cost of products using phpmyadmin sql query
- How to Add or Change Post Title
- Why does DROP TABLE-ing the `wp_options` reset my user session?
- How to create index (sql) to a meta_key?
- How to refactor DB queries for better TTFB in WordPress?
- query sql-table and change entities
- Backtick (MySQL norm) added to SQL Server Query causing error
- $wpdb not working
- Deleting the MySQL database