Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I almost done witm my assignment, but i coudn\'t figure the last query out. here

ID: 3733824 • Letter: I

Question

I almost done witm my assignment, but i coudn't figure the last query out. here is what is rquired. (this assignment has to be done by pgadmin4)

Add country, salary column to ‘city’ table and set yearly_salary to 78246.12 for cities in Canada. DEFAULT constraint must be used to add Canada as a default country for cities. [Use DEFAULT Constraint to default your country to Canada, that way you only have to write the countries for cities which are not in Canada, Hint : remember ‘boston’ and ‘new York’ are cities in US, rest all are in Canada, Use ALTER TABLE to add column and default constraint].

1. Answer the questions with respect to the table below users id gender city_id name John Sara Victor Jane age 25 20 31 27 OCC I 4 occupation id name Software Engineer Accountant Pharmachist Library Assistant 4 city id name Halifax Calgary Boston New York Toronto (a) Create the three tables with their SQL queries and paste the code in text format below. Make sure while creating the tables: [6+2+2] .Must have primary keys in all the tables .The attributes which can potentially be foreign keys must have NOT NULL Constraint. Gender attribute in users table should CHECK for 'M' or 'F

Explanation / Answer

Answer)

The way we can set default values for table are as using the SET DEFAULT statement.
The alter table command is used to alter the table to add the new columns to the table.
The country default would be 'Canada', we have to manually change for each cities such as ‘boston’ and ‘new York’ are cities in US. We cannot access the column values in DEFAULT, and thus we cannot do such operation with this.
The salary default would be '78246.12'.

The SQL Statement is as below:

ALTER TABLE city
ADD (country varchar SET DEFAULT 'Canada',
salary varchar SET DEFAULT '78246.12');

//Please like if you like my answer and comment for any further questions on this