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...
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
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.
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...
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...
Write CREATE TABLE and INSERT INTO statements in order to create and populate five tables in...
Write CREATE TABLE and INSERT INTO statements in order to create and populate five tables in Oracle’s SQL*Plus.The information you need about the database ARE IN THE CHARTS BELOW. Each worksheet includes the following information about its associated table: ➢ Column names (for example, the jr_order table contains the orderID, customerID, orderDate, orderStatus, and orderShippedDate columns); ➢ Column data types (for example, orderID is INT, orderStatus is VARCHAR2(2), etc.); ➢ Column constraints, if any (for example, orderID in the jr_order...
I need to create a multi step income statement and statement of retained earnings with the...
I need to create a multi step income statement and statement of retained earnings with the following information ( assume a 30% tax rate and 500,000 shares of common stock) Accounts Receivable                       $555,000 Accumulated Depr.-equipment          450,000 Accumulated Depr.-buildings            360,000 Allowance for doubtful accts.              36,000 Common Stock                           2,000,000 Depreciation Expense (equipment)      50,000 Depreciation Expense (buildings)         60,000 Dividends (common stock)               120,000 Dividends Payable                            30,000 Insurance Expense                             35,000 Interest Expense                               40,000 Interest Payable                          ...
I need to create a multi step income statement and statement of retained earnings with the...
I need to create a multi step income statement and statement of retained earnings with the following information ( assume a 30% tax rate and 500,000 shares of common stock) Accounts Receivable                       $555,000 Accumulated Depr.-equipment          450,000 Accumulated Depr.-buildings            360,000 Allowance for doubtful accts.              36,000 Common Stock                           2,000,000 Depreciation Expense (equipment)      50,000 Depreciation Expense (buildings)         60,000 Dividends (common stock)               120,000 Dividends Payable                            30,000 Insurance Expense                             35,000 Interest Expense                               40,000 Interest Payable                          ...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT