How to insert data with foreign key? #1683
Answered
by
simolus3
jack24254029
asked this question in
Q&A
-
I have two tables.
I have two ways to insert data;
Which is better or who has the better way? |
Beta Was this translation helpful? Give feedback.
Answered by
simolus3
Feb 15, 2022
Replies: 1 comment 1 reply
-
I would probably go for approach number 1, perhaps in a transaction if you care about atomicity. Approach 2 is not more efficient (any positive effect |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
jack24254029
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I would probably go for approach number 1, perhaps in a transaction if you care about atomicity.
Approach 2 is not more efficient (any positive effect
Future.wait
may have is cancelled out because you still have to run a query afterwards). And IMO approach 1 is more readable.