I provided some SQL questions for an interviewer in Who Do You Hire? to ask of a candidate. I had a couple requests for answers, so I decided to provide some. I would recommend you check the questions first before you read these.
select o.orderid from orders o where o.custid = ( select o1.custid from orders o1 where o1.qty > 1 and o1.orderid = o.orderid )
select distinct c.name, o.orderid from customers c, orders o where c.custid = o.custid
select c.name, o.orderid, count(o.orderid) from customers c, orders o where c.custid = o.custid group by c.name, o.orderid having count( o.orderid) > 1
Normalization is a technique for storing data in a relational database system. There are various levels or normalization, but when most people speak of Normalization, they are referring to third normal form. Under this level, there are no repeating data elements, fields depend on the complete primary key, and no dependencies on non-key columns. Also no derived columns.
Usually third normal form reduces the amount of data storage needed as well as makes OLTP applications quicker by reducing the amount of data necessary for an insert.
Denormalization is often done to reduce the number of joins required for a query. Usually in OLAP applications.
To read the rest of this article, and access thousands of other articles, we ask you to register on the site and subscribe to our newsletters.
We ask you to register on the site and subscribe to our newsletters. Subscribing to our newsletters gets you:
We ask that you give the newsletter a try for a week. Over 200,000 SQL Server Professionals a day find it entertaining and useful. If not, you are welcome to unsubscribe at anytime.
Steve Jones Editor, SQLServerCentral.com