CST363 Week 3 May 14th - May 20th
A view is essentially a saved query that you can treat like a table. Under the hood, the database doesn’t necessarily store the view’s data separately; it re-runs the defining SELECT every time you reference it
The similarities to a table are the Rows and Column, you SELECT from a view similar as to how you would do it from a table. Join and filters also looks the same.
The key differences between the two...
Aspect | Tables | View |
---|---|---|
Storage | Physically stores data on disk. | Usually virtual (query results are generated on the fly). Some DBs support materialized views. |
Primary Key | Defined directly on the table; enforced. | No inherent PK—though some systems allow unique indexes on views, most treat them as keyless. |
Updatability | Always updatable (barring triggers/locks). | Only if certain rules are met: |
Comparing SQL with Java there are notable differences and similarities.
Their similarities includes their conditionals, expressions, and returns.
When it comes to differences...
SQL has SQL only features such as UNION, INTERSECT, EXCEPT. You can also declare exactly what you want and the optimizer would decide how to get it versus Java where you would have to go through specific algorithms like loops, indexes, functions, and etc.
Java has Object-Oriented Abstraction such as classes, inheritances, interfaces, and polymorphism. SQL tables and rows aren't objects.
SQL and Java address different domains—data storage & querying versus general-purpose computation but they borrow ideas from each other. Understanding views as “virtual tables” helps bridge the gap, and spotting parallels (and contrasts) with Java deepens my appreciation for both languages.
Java has Object-Oriented Abstraction such as classes, inheritances, interfaces, and polymorphism. SQL tables and rows aren't objects.
SQL and Java address different domains—data storage & querying versus general-purpose computation but they borrow ideas from each other. Understanding views as “virtual tables” helps bridge the gap, and spotting parallels (and contrasts) with Java deepens my appreciation for both languages.
Comments
Post a Comment