Question

In: Computer Science

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.

Solutions

Expert Solution

1) Sql Query for creating vendor table:-

create table Vendor(vendor_ID int primary key , vendor_name varchar(100))

primary key synatx is used to create primary key .

2) Sql Query for creating Customer table:-

create table Customer(Customer_ID varchar(100) primary key, Phone_Number  int,name varchar(100),address_ID int,email   varchar(100),vendor_ID int , CONSTRAINT FK_PersonOrder FOREIGN KEY(vendor_ID) REFERENCES vendor(vendor_ID))

Code CONSTRAINT FK_PersonOrder FOREIGN KEY(vendor_ID) REFERENCES vendor(vendor_ID) is used to create foreign key vendor_ID refering to primary key of vendor_ID in vendor table.

3) Sql Query to insert data into vendor table:-

INSERT INTO `vendor` (`vendor_ID`, `vendor_name`) VALUES ('1', 'mahendra'), ('2', 'rahul');

4) Sql Query to insert data into customer table:-

INSERT INTO `customer` (`Customer_ID`, `Phone_Number`, `name`, `address_ID`, `email`, `vendor_ID`) VALUES ('1', '2222222', 'tom', '1', '[email protected]', '1');

5) Update query to update data in customer table:

UPDATE customer SET Phone_Number =111111 WHERE Customer_ID=1

6)Update query to update data in vendor table:

UPDATE vendor SET `vendor_name`='mohan' WHERE vendor_ID = 2


Related Solutions

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 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...
/* 1. Fix the CREATE and INSERT statements below to create the SHIPMENT table and insert...
/* 1. Fix the CREATE and INSERT statements below to create the SHIPMENT table and insert its data in DB Fiddle*/ CREATE TABLE SHIPMENT ( ShipmentID Int NOT NULL, ShipperName Char(35) NOT NULL, ShipperInvoiceNumber Int NOT NULL DepartureDate Date NULL, ArrivalDate Date NULL, InsuredValue Numeric(12,2) NOT NULL, CONSTRAINT Shipment_PK PRIMARY KEY (ShipmentID)) ); INSERT INTO SHIPMENT VALUES (1,'ABC Trans-Oceanic', 2008651, '10-Dec-14', '15-Mar-18', 15000.00); INSERT INTO SHIPMENT VALUES (2,'ABC Trans-Oceanic', 2009012, '10-Jan-18', '20-Mar-18', 12000.00); INSERT INTO SHIPMENT VALUES (3,'Worldwide', 49100300, '05-May-18',...
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!)
project on hotel management in dbms with er diagram and table (sql) please give answer
project on hotel management in dbms with er diagram and table (sql) please give answer
1) Write an INSERT statement that adds this row to the Invoices table: i nvoice_id: The...
1) Write an INSERT statement that adds this row to the Invoices table: i nvoice_id: The next automatically generated ID vendor_id : 32 invoice_number: AX-014-027 invoice_date: 8/1/2014 invoice_total: $434.58 payment_total: $0.0 credit_total: $0.0 terms_id: 2 invoice_due_date: 8/31/2014 payment_date: null Write this statement without using a column list.: Use DEFAULT to insert the automatically generated ID. 2) Write an INSERT statement that adds these rows to the Invoice_line_Items table: invoice_sequence: 1 2 account_number: 160 527 line_item_amount: $180.23 $254.35 line_item_description: Hard drive...
Using your downloaded DBMS (MS SQL Server), create a new database. Create the database tables based...
Using your downloaded DBMS (MS SQL Server), create a new database. Create the database tables based on your entities defining The attributes within each table The primary and foreign keys within each table *****Show your database tables, tables attributes, primary and foreign keys***** Do not forget to check the lesson slides and videos that show you how to convert an ER/EER into a database schema, and how to create a database and tables using MS SQL Server.
Please write the SQL statement for the following. I am using the Adventurework2014 database. 1. Create...
Please write the SQL statement for the following. I am using the Adventurework2014 database. 1. Create a login for AdventureWorks employees. An employee login should be composed of the first letter of a person's first name combined with their last name. In addition, the login should be all lower case characters. All the required information is located in Person.Person table. Employees can be identified by "EM" value in the PersonType field. The output should include BusinessEntityID, first name (FirstName), last...
Create three MySQL database tables and write SQL scripts to read, insert, and delete data. The...
Create three MySQL database tables and write SQL scripts to read, insert, and delete data. The first database table will contain the names of at least four movies. The second table will be a list of actors who appear in the movies. The third table will be an associative table that describes the relationship between the actors and their movies (which actors appear in which movies). Actors and movies have a “many-to-many relationship,” meaning an actor can be in multiple...
Create three MySQL database tables and write SQL scripts to read, insert, and delete data. The...
Create three MySQL database tables and write SQL scripts to read, insert, and delete data. The first database table will contain the names of at least four movies. The second table will be a list of actors who appear in the movies. The third table will be an associative table that describes the relationship between the actors and their movies (which actors appear in which movies). Actors and movies have a “many-to-many relationship,” meaning an actor can be in multiple...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT