Objects vs Table Reference, which one should I use and which direction?

Options

Hiya! Noob here.

I watched some of your YT videos, which were helpful, I had my structure all setup and I understood it, It had Table References, life was great. 😎

Then Objects were thrown in and it all got confusing again 😩. In the application I have in my head I had a products table and a products_type table. I had a table reference between the two but now I'm confused. Let's make the example cars

In products I've got
Car #1
Car #2
Car #3

In products_type I've got
SUV
Hatchback
Coupe

Is it better to have a table reference in products for products_type_id ?

Or is it better to have an object in products_type that lists the items in products ?

Cheers

Best Answer

  • Michael Udinski
    Michael Udinski Administrator

    ADMIN

    Answer βœ“
    Options

    @Toast I'd recommend having the table reference for products_type_id in your products table

    Products

    -id

    -product_name

    -products_type_id

    I recommend this approach because it will be easier to query and update the data. Plus, your products could grow very large so trying to contain these nested lists on the products_type table could become cumbersome.

Answers

  • Toast
    Toast Member ✭
    edited October 2023
    Options

    @Michael Udinski Thank you Michael, i'm so glad you didn't say "it depends"! This was the kind of direct answer I was hoping for because now I can feel comfortable again that Im not creating a problem for myself and I can carry on progressing my build once more, thanks again.