Why is it more efficient to create two tables vs one? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Why is it more efficient to create two tables vs one?

Re: "Rather than storing the customer name in both tables, the orders table contains a reference to the customer ID that appears in the customers table. This approach is more efficient, as opposed to storing the same text values in both tables."

1st May 2019, 2:45 PM
Kristen Bein
Kristen Bein - avatar
2 Answers
+ 4
Imagine you have a `customer` table with 20 or so columns (address, name, ...), and a table `who_bought_what`: customer_id, object_id 1, 14828 1, 48220 1, 58338 So customer 1 bought three things and by storing only the ID instead of the whole customer, you don't have to put the same 20 values into your table three times. Saves a lot of space. Later on you can join the tables if you need to.
1st May 2019, 2:54 PM
Schindlabua
Schindlabua - avatar
+ 2
Of course! Thanks!
1st May 2019, 2:56 PM
Kristen Bein
Kristen Bein - avatar