Amazon Interview Question for Software Engineer / Developers






Comment hidden because of low score. Click to expand.
1
of 1 vote

Prepared statements are a capability whereby the SQL queries are compiled into a intermediate form. The server then hands the client a handle for these. After this the only thing that remains to be parsed on query execution are the parameter values. For example if you had a query
select * from Foo where col=?
Where value of col depends upon (say) a user input. If you use prepared statements then the only thing that needs to be parsed by the server before query execution is the value of col. OTOH if you used regular queries the server would need to parse the incoming SQL (select * from ...) as well.
The second advantage of this security. If you send raw user input to the server I can try tricks like entering "10; drop table Users" in the dialog that you are getting the input from. So your final query would become
select * from Foo where col=1; drop table Users;
Now assuming you had a table called Users, I have just deleted that table. This is called SQL injection. With prepared statements this problem simply goes away.

Finally, indexing (in a DB context) is a way of optimizing look up of certain column (or sequence of columns) in a table. The database engine, then creates structures to quickly search for these columns, without requiring to scan the entire table.

- Jasmeet bagga May 12, 2010 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More