Question

In: Computer Science

do the following SQL programming tasks: Use the CREATE TABLE statement to build the sample table...

do the following SQL programming tasks:

  • Use the CREATE TABLE statement to build the sample table (MODULE)
  • Use the INSERT INTO statement to populate it - use either the data in the image or your own
  • Write an SQL query to display the whole populated table
  • Write an SQL query to display certain combinations of columns (use your imagination)
  • Write an SQL query to extract certain combinations of columns and rows (imagination again!)

Solutions

Expert Solution

#Use the CREATE TABLE statement to build the sample table
CREATE TABLE EMPLOYEE__(
emp_id INT PRIMARY KEY NOT NULL,
emp_firstName VARCHAR(255) NOT NULL,
emp_lastName VARCHAR(255) NOT NULL,
emp_deptName VARCHAR(255) NOT NULL
);

#Use the INSERT INTO statement to populate it - use either the data in the image or your own
INSERT INTO EMPLOYEE__ VALUES (100, 'John', 'Deo', 'Engineering');
INSERT INTO EMPLOYEE__ VALUES (101, 'Mary', 'Jane', 'HR');
INSERT INTO EMPLOYEE__ VALUES (102, 'James', 'Bind', 'HR');

#Write an SQL query to display the whole populated table
SELECT * FROM EMPLOYEE__;

#Write an SQL query to display certain combinations of columns (use your imagination)
SELECT emp_id, emp_firstName, emp_lastName FROM EMPLOYEE__ WHERE emp_id = 101;

#Write an SQL query to extract certain combinations of columns and rows (imagination again!)
SELECT emp_id, emp_firstName, emp_lastName, emp_deptName FROM EMPLOYEE__ WHERE emp_deptName = 'HR';

#Please provide your feedback by clicking the feedback button, so that i can improve my answering skills


Related Solutions

Use a single SQL statement to create a relational table and to load into the table...
Use a single SQL statement to create a relational table and to load into the table department name, subject code, year of running and session of running that offered by the departments. Note that a running subject offered by a department means a lecturer of the department has been assigned to teach the subject. Next, enforce the appropriate consistency constraints on the new table.    When ready use SELECT statement to list the contents of the relational table created and...
DBMS Create/Insert/Update SQL I need the create, insert, and update SQL statement for this table as...
DBMS Create/Insert/Update SQL I need the create, insert, and update SQL statement for this table as if it were being added to MySQL (please give explanations for each line of SQL code and a copy of the code as it would be entered into the query by itself: Customer PK Customer ID Text Phone Number int name text address ID int email text FK vendor ID int Vendor is the name of the table the FK comes from.
DBMS Create/Insert/Update SQL I need the create, insert, and update SQL statement for this table: Customer...
DBMS Create/Insert/Update SQL I need the create, insert, and update SQL statement for this table: Customer PK Customer ID Text Phone Number int name text address ID int email text FK vendor ID int Vendor is the name of the table the FK comes from.
Use C programming to Implement the breadth-first tree traversal. The tasks are: a) Build the tree....
Use C programming to Implement the breadth-first tree traversal. The tasks are: a) Build the tree. b) Perform breadth first traversal on the tree that you have built at step a). Note: "Please comment the program"
Based on the tables below, write SQL command to perform the following tasks for MySql: Create...
Based on the tables below, write SQL command to perform the following tasks for MySql: Create SALESREP and CUSTOMER tables Create primary and foreign keys as appropriate. The custNo should use a surrogate key as the primary key with auto-increment increase the balance of the Gonzales account by $100 to a total of $450? Find an average customer balance Display the name of the sales representative and the name of the customer for each customer that has a balance greater...
Database questions: USE THE FOLLOWING SQL CODE TO SOLVE NEXT QUESTIONS: CREATE TABLE ROBOT ( Serial_no...
Database questions: USE THE FOLLOWING SQL CODE TO SOLVE NEXT QUESTIONS: CREATE TABLE ROBOT ( Serial_no INT NOT NULL, Model VARCHAR(20) NOT NULL, Manufacturer VARCHAR(20) NOT NULL, Price INT NOT NULL, PRIMARY KEY (Serial_no) ); INSERT INTO ROBOT VALUES (1, 'Scara','Epson', 23200); INSERT INTO ROBOT VALUES (2, 'ASSISTA','Mitsubishi', 17500); INSERT INTO ROBOT VALUES (3, 'Lego Mindstorm','NXT', 650); INSERT INTO ROBOT VALUES (4, 'Yumi','ABB', 40000); INSERT INTO ROBOT VALUES (5, 'Pepper','Foxconn', 1600); INSERT INTO ROBOT VALUES (6, 'Humanoid','Honda', 30000); SELECT *...
1. Use SQL to create a polyinstantiated table including a primary key and a unique constraint...
1. Use SQL to create a polyinstantiated table including a primary key and a unique constraint 2.Use SQL to insert multiple records for each security classification with the same ID. You must have 4 classifications. 3.Use SQL to create 4 schemas, one for each security classification 4.Use SQL to create a view in each schema that restricts the records to those belonging to a particular security classification and restricts the columns to only those columns that have relevant data. 5.Select...
USE SQL CREATE TABLE IF NOT EXISTS football_games ( visitor_name VARCHAR(30),       /* Name of the visiting...
USE SQL CREATE TABLE IF NOT EXISTS football_games ( visitor_name VARCHAR(30),       /* Name of the visiting team                     */ home_score SMALLINT NOT NULL,   /* Final score of the game for the Buffs         */ visitor_score SMALLINT NOT NULL,/* Final score of the game for the visiting team */ game_date DATE NOT NULL,        /* Date of the game                              */ players INT[] NOT NULL,         /* This array consists of the football player ids (basically a foreign key to the football_player.id) */ PRIMARY KEY(visitor_name, game_date)...
Using Triggers (5 pts.) Execute the following SQL to create the customer_audit table in the premier...
Using Triggers (5 pts.) Execute the following SQL to create the customer_audit table in the premier schema. CREATE TABLE IF NOT EXISTS customer_audit ( customer_num CHAR(3) NOT NULL,   customer_name VARCHAR(35) NOT NULL, street VARCHAR(15), city VARCHAR(15), state CHAR(2), zip CHAR(5), credit_limit DECIMAL(8,2), date_changed DATETIME NOT NULL, changed_by VARCHAR(45) NOT NULL); Notice that the audit table does not have a primary key defined. Explain why this might be acceptable. Based on the current attributes in the customer_audit table, suggest a possible...
1. write SQL statements to create the following two tables: a) Department table that contains the...
1. write SQL statements to create the following two tables: a) Department table that contains the following columns(dept_no,deptname,location) set the deptno to be the primary key. b) Employee table contains the following columns(emp_no,empname,deptno,salary)set the emp_no to be the primary key and dept_no to be the foreign key. 2. Write SQL statements to Insert the following 3 rows in Employee table:        (101,’Sami’,’D-101’,5000)        (102,’Yousef’,’D-101’,4000)        (103,’Sami’,’D-102’,7000) 3. Write SQL statements to Insert the following 3 rows in Department table:       ...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT