CST 363 - Week 3
1. What is an SQL view?
A view in SQL is like a virtual table. It doesn’t actually hold any data itself, it’s more like a saved version of a query that we can reuse. It works like a table since you can select from it just like any regular table, but it has some limits. A good example is that you usually can’t insert, update, or delete rows in a view unless it’s really simple and includes all the necessary columns like a primary key. It’s more useful for organizing or simplifying complex or complicated queries so you don’t have to rewrite them every time.
2. Comparing SQL to Java
SQL and Java are pretty different overall, but they do share some ideas. In SQL, you use the where statement to filter results which is kind of like an if-statement in Java. And the select statement in SQL is like Java’s return statement as it tells the system what data to give back. But the big difference is that SQL is mostly about handling a lot of data like working with entire tables at once, while Java is more about controlling the flow of logic step by step. Java has things like loops and detailed error handling, but SQL doesn’t really work that way. Still, both are powerful in their own way, just depends on what one is trying to do.
Comments
Post a Comment