-2

I am using join in my quires and i want to know if the relations between database tables leads to increase performance of the queries.

Thank You.

Ali
  • 1,633
  • 7
  • 35
  • 58

1 Answers1

1

For boosting performance, you should use indexes, use appropriate datatypes as well (storing number as string takes more space and comparing may be less efficient).

Relations between tables, i.e. foreign key are constraints, so you cannot enter new value to referenced table without referencing records in other table - it is a way to keep data integrity, eg.

Table1
id  table2_id
1   1
2   1
3   3

Table2
id  some_column
1   123
2   123
3   null

Here, Table1.table2_id references Table2.id. Now you won't be able to insert such row to Table1: 4, 4, because there's no id = 4 in Table2.

Michał Turczyn
  • 32,028
  • 14
  • 47
  • 69
  • Relations gives you ability to set values to null or even remove whole rows when something related is deleted – Damian Dziaduch Aug 24 '18 at 11:05
  • @DamianDziaduch Well, it's not what OP asked, but you're right. This is other topic, what to do when referenced record is deleted: raise error, cascade delete, update referencing row to null :) – Michał Turczyn Aug 24 '18 at 11:20