0

I couldn't find the answer to this anywhere. Might be because I did not know how to properly search for this...so if anyone has the answer to this or could point me to the right resources to find the answer, that would be much appreciated!

Scenario: I have a small membership database in 3NF with a member, zipcode, phone number and email table. I need to add 3 new members into the database. Using INSERT INTO i know I can add data to 1 table, but because I have data of that member for all tables I am looking for a way to add the data in the most efficient way possible instead

What is the best/fastest way to add a new row (member) into a database made out of multipe tables like this? (in this example, every member to be added has a zipcode, phone number and email)

  • There is nothing special about it. Insert into the member table and use that ID to insert in the other tables. – juergen d Sep 13 '21 at 09:32
  • Four tables = four inserts. Get ID (if autogenerated) of Member and insert into other 3 tables. – Stu Sep 13 '21 at 09:33
  • 1
    If you need to perform some complex operation which consists of a lot of separate operations then create according batch as stored procedure. – Akina Sep 13 '21 at 09:34
  • @Stu The primary keys for Member are 'hand-made'. Just for me to be sure, the queries would look something like this: INSERT INTO member VALUES('123456', 'Dave', '1234 AD') & INSERT INTO zipcode VALUES ('1234 AD, '123456')? The 123456 being the PK of the member table and FK of zipcode table –  Sep 13 '21 at 09:44

0 Answers0