Question: 1-create the three tables with their SQL queries and paste the code in text format below. Make sure while creating the tables: Must have

1-create the three tables with their SQL queries and paste the code in text format

below. Make sure while creating the tables: 

• 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'

 

2- Can you please write 2 different types of

sql queries to find the users in city 'Boston'. Write 2

types of queries, one using joins to find the answer and another using

subqueries to find the same answer.

 

3- Can you please write sql query to find how many users are there per occupation.

 

4- Can you please Perform full outer join between users and city.

 

5- Can you please write query to make a copy of 'users' table known as 'users_new'.

CREATE TABLE users_new LIKE users;

 

6-  Can you please write query to insert all columns of 'users' to the 'users_new'.

 

7- Can you please INSERT INTO users_new SELECT * FROM users;

Write CASE query to add one more column with salary values

to the 'users' table. Salary for Software engineer is 80,000, Accountant is 70,000 and

Pharmacist is 90,000.

 

8- Can you please write query to add foreign keys constraints to 'users' table.

 

9-  Can you please add country column to 'city' table.

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 not in Canada,

id 2 3 4 5 City name Halifax Calgary Boston New York Toronto 

id 2 3 4 5 City name Halifax Calgary Boston New York Toronto

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Below are the SQL queries to perform the tasks you described 1 Create Tables Users Table CREATE TABL... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!