The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Jul 2017 |
| Last Sign in: | 304 Weeks Ago, 2 Days Ago |
| Questions Answered: | 15833 |
| Tutorials Posted: | 15827 |
MBA,PHD, Juris Doctor
Strayer,Devery,Harvard University
Mar-1995 - Mar-2002
Manager Planning
WalMart
Mar-2001 - Feb-2009
Please find the attached files.The questions are related to SQL
Assume you have an SQL Server Database designed with the following schema:
Â
create table customer (id int not null identity,
Â
name nvarchar(50) not null, primary key (id));
Â
create table [order] (id int not null identity,
Â
customerIdint not null,
Â
total decimal not null default (0),
Â
createDate DATETIME not null default(GETDATE()),
Â
primary key (id));
Â
create table lineItem (id int not null identity, orderIdint not null,
Â
productIdint not null, itemPrice decimal not null, quantity int not null,
Â
totalPriceint not null, primary key (id));
Â
Write a query to return the number of customers that have placed 2 or more orders in the
Â
month of January 2016. Feel free to make or define any necessary schema changes if non-
Â
obvious.
Â
Question 2:
Â
From question 1: Execute the following statement
Â
insert into customer ([id], [name]) VALUES (1, 'John Doe');
Â
Unfortunately, you receive an error. Why did you get an error and what can you do to insert
Â
this record with id value 1?
Â
Question 3:
Â
You have created this view
Â
create view good_customers AS
Â
SELECT [id], [name] FROM [dbo].[customer]
Â
What can you do to prevent other developers from changing the name of the columns in the
Â
customer table so the view does not break?
Â
Question 4:
Â
What are some advantages and disadvantages to using SQL Server to store your business
Â
logic and back-end security (stored procedures and functions, etc)?
Â
Question 5:
Â
When is it OK to deviate from third-normal form and higher?
Â
Question 6:
Â
create table foo (id INT, name nvarchar(MAX));
Â
INSERT INTO foo VALUES (1, 'John Doe');
Â
INSERT INTO foo VALUES (2, 'John Smith');
Â
INSERT INTO foo VALUES (3, 'Amy Smith');
Â
INSERT INTO foo VALUES (3, 'Amy Adams');
Â
INSERT INTO foo VALUES (4, 'John Adams');
Â
INSERT INTO foo VALUES (5, 'John Quincy');
Â
Suppose you have created and run the script above. You have accidentally set id value 3
Â
twice. Write the appropriate SQL to correct the data.
----------- Â ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly