# Inserting Hierarchical Rows

**URL:** <https://forum.codewithmosh.com/t/inserting-hierarchical-rows/1471>\
**Category:** SQL\
**Created:** [December 27, 2020, 4:50am UTC](https://forum.codewithmosh.com/t/inserting-hierarchical-rows/1471 "2020-12-27T04:50:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jyoti](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/jyoti/32/441_2.png) [@Jyoti](https://forum.codewithmosh.com/u/Jyoti)\
**Post date:** [December 27, 2020, 4:50am UTC](https://forum.codewithmosh.com/t/inserting-hierarchical-rows/1471/1 "2020-12-27T04:50:13Z")

</div>

In Inserting Hierarchical Rows, how we can find out which two tables are connected to each other or multiple table. How to find out which table is parent table and which is children table? 🧐

---

<div class="post-metadata">

**Author:** ![SAM](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/sam/32/167_2.png) [@SAM](https://forum.codewithmosh.com/u/SAM)\
**Post date:** [December 27, 2020, 8:33am UTC](https://forum.codewithmosh.com/t/inserting-hierarchical-rows/1471/2 "2020-12-27T08:33:48Z")

</div>

The child table has a foreign key referencing the parent table.  
 ![foreignkeys](https://us1.discourse-cdn.com/flex020/uploads/codewithmosh/original/1X/fbdc8db9adb2a5efa86a9cfc6ffc96fdde2ee340.png)

You’ll learn about foreign keys in the Designing Databases section.

---

<div class="post-metadata">

**Author:** ![curiouslyso](https://avatars.discourse-cdn.com/v4/letter/c/aeb1de/32.png) [@curiouslyso](https://forum.codewithmosh.com/u/curiouslyso)\
**Post date:** [July 17, 2021, 1:07am UTC](https://forum.codewithmosh.com/t/inserting-hierarchical-rows/1471/3 "2021-07-17T01:07:39Z")

</div>

Hi, I have just completed the section on Inserting Hierarchical Rows.

In the section below are we changing the value of the price of the item by inserting them with a price here? I mean aren’t the item prices for the items in sql\_store.products already?

 ![image](https://us1.discourse-cdn.com/flex020/uploads/codewithmosh/original/2X/f/f01d1b3d291898c5000bf04b542f1557eb24a697.jpeg)

Thanks  
Vivian

---

<div class="post-metadata">

**Author:** ![SAM](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/sam/32/167_2.png) [@SAM](https://forum.codewithmosh.com/u/SAM)\
**Post date:** [July 17, 2021, 8:09am UTC](https://forum.codewithmosh.com/t/inserting-hierarchical-rows/1471/4 "2021-07-17T08:09:35Z")

</div>

One might think it’s redundant to have a unit\_price both in `products` and `order_items`. But in case the price in `products` changes you still want to continue processing orders with the price that was valid by the time they were placed.
