简体   繁体   中英

What normal form does Laravel's Eloquent use?

I've been learning laravel for the past couple of months, but I'm having trouble understanding Eloquent's relationships from a relational database standpoint.

For example, from this laracsts video :

Jeff creates a notes table that is defined as:

table notes
------------------------------------
| id | card_id | body | time_stamps|
------------------------------------

why wouldn't you define the notes table with two tables, so that the second table relates the cards table and the notes table.

Example:

table notes
--------------------------
| id | body | time_stamps|
--------------------------

table card_notes
---------------------
| note_id | card_id |
---------------------

Is this wrong, or am I overthinking this? Any help would be appreciated!

For one-to-many relationship pivot table will be just redundant. In this case you'll use many-to-many relationship for one-to-many one. Of course you can do this, but why would you want it?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM