F
Fieel
Guest
Hello,
i'm using the basic SqlConnection with C# to make raw queries from an UWP app.
Because i have some relationship in my db i have to populate record from related tables and then use their ID as foreign key in one of the main tables rows. How to best approach this problem? I was thinking about making multiple queries inserting data in the related tables and then making a new querirs, selecting the IDs of the first records inserted and then using such IDs in the insert of the main table and its fk columns. Is it a good idea? Is there a better way to approach this problem?
Inserting a record just to selecting it again to check its identity seems kinda.. redundant?
I'm used to tools such as Eloquent in PHP or EF in .NET where relationships are handled properly without the need of new, direct queries so this is the first time i have to deal with this problem
What is the best way?
Little ER diagrama showing what i mean:
Continue reading...
i'm using the basic SqlConnection with C# to make raw queries from an UWP app.
Because i have some relationship in my db i have to populate record from related tables and then use their ID as foreign key in one of the main tables rows. How to best approach this problem? I was thinking about making multiple queries inserting data in the related tables and then making a new querirs, selecting the IDs of the first records inserted and then using such IDs in the insert of the main table and its fk columns. Is it a good idea? Is there a better way to approach this problem?
Inserting a record just to selecting it again to check its identity seems kinda.. redundant?
I'm used to tools such as Eloquent in PHP or EF in .NET where relationships are handled properly without the need of new, direct queries so this is the first time i have to deal with this problem
What is the best way?
Little ER diagrama showing what i mean:
Continue reading...