SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Weird interview question


Weird interview question

Author
Message
Eugene Elutin
Eugene Elutin
SSChampion
SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)

Group: General Forum Members
Points: 12316 Visits: 5478
I wonder, if you could discuss questions with interviewer or it was just written test?
Not long ago I was on the interview, where the interviewer asked me to do technical test without any possibility to discuss questions. I have done the test fine, but after it I've told him that I'm not interested in position. If they want to test knowledge this way, they at least must ask some senior SQL expert to validate questions in their tests...
So, some of your questions are also open to wide interpretation.

2. Table Spending has a foreign key reference defined to Customers. Which of the following are true statements?

a. No row can exist in Spending without a corresponding row in Customers with the same key value.
b. No row can exist in Customers without a corresponding row in Spending with the same key value.
c. No row can be deleted in Spending without first deleting corresponding row(s) in Customers.
d. No row can be deleted in Customers without first deleting corresponding row(s) in Spending.
e. There must be one or more rows in Customers with the same key value as each row in Spending.
f. There may be zero but no more than one row in Spending with the same key value as each row in Customers.


a. looks almost right, but not exactly. As it's possible to have row in Spending without a corresponding row in Customers with the same key value, if the key value for Customer in Spending is NULL.
the same goes for d. & e.

9. Which use of subquery is correct and why?

a. where f in (select a from tab1)
b. where f = (select a from tab1)


Try "incorrect" b. sample:
DECLARE @t TABLE (id int, val char(10))
INSERT @t VALUES (1,'acs')
SELECT 'ok' WHERE 1 = (SELECT id FROM @t)


Works fine. So, the right answer will be: "it depends..."

Saying that your questions were much more matured than ones I had.

_____________________________________________
"The only true wisdom is in knowing you know nothing"
"O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
(So many miracle inventions provided by MS to us...)

How to post your question to get the best and quick help
Sean Lange
Sean Lange
SSC Guru
SSC Guru (62K reputation)SSC Guru (62K reputation)SSC Guru (62K reputation)SSC Guru (62K reputation)SSC Guru (62K reputation)SSC Guru (62K reputation)SSC Guru (62K reputation)SSC Guru (62K reputation)

Group: General Forum Members
Points: 62157 Visits: 17954
GilaMonster (5/9/2013)
Sean Lange (5/9/2013)
The difference between delete and truncate is that delete is a dml operation that is fully logged and truncate is DDL operation and is minimally logged. What that means is the rows are logged in a delete but the page deallocation is logged for a truncate.


Technically truncate is a fully logged operation. Minimally logged means that there is a difference in logging behaviour between bulk-logged/simple and full recovery and that in bulk-logged and simple recovery models the operation logs only enough for a roll back, not enough for a roll forward operation, such an operation flips the appropriate bit in the ML map and results in the next log backup copying the affected extents into the log backup.

Minimally logged does not mean that only the page allocation/deallocations are logged. Many operations, including truncate table, drop table, drop index, select into, insert into, alter index .. rebuild, log only page allocations/deallocations in all recovery models.


Thanks for the clarification and correction.

_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Modens splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search