Periodic Table Database

I have a doubt on the following points

1: Your properties table should have a type_id foreign key column that references the type_id column from the types table. It should be an INT with the NOT NULL constraint

I used the query

alter table properties add column type_id int not null references types(type_id);

it shows me some error about null values, so I break the problem into mini problems as

  • add the column type_id to the table properties
  • insert the values manually one by one into each cell of type_id column (boring task)
  • add the constraint NOT NULL to column type_id
  • make it foreign key with reference from types(type)

Q: since the table has only few rows of data i completed the task in few minutes, and I don`t think it is a feasible solution.
what`s the correct way to do it?

2:The schema of the 3 tables is as
image

image

the data given to enter into tables is

Q : Is it possible to enter data into all three tables simultaneously using single query or I have to enter the data separately specific to that table?

Im sticking around since i have a similar doubt but for this question:

Your properties table should have a type_id foreign key column that references the type_id column from the types table. It should be an INT with the NOT NULL constraint

I wonder if there’s a way to make the reference to the other table and automatically fill in this values with the type_id of the types table.

About this part: it doesn’t need to be completed in one command. The way I resolved it was to add the column to the properties table, then fill it with data using UPDATE. Lastly, I added the NOT NULL constraint and the foreign key.

You can enter data into multiple columns with one command, but I don’t believe this is true for multiple tables.

@zaira_h can you please help?

Thanks for the reply, i know question does not need to be completed in one step and I indeed completed the way you said but I was wondering if there was a more optimal way to solve this question.

Hi, what do you need help with? Yes, you can simultaneously enter data in a table using INSERT.

yeah,we can simultaneously enter data into 1 table using INSERT ,can we enter data simultaneously into more 2 tables?