Week 3 learning journal SQL
This week I learned more about how SQL views work and how they compare to regular tables. An SQL view is essentially a saved query that behaves like a virtual table. I can use it to simplify complex queries, provide a layer of security, or just make my code easier to read. Views are similar to tables because I can query them using SELECT statements and treat them like they store data. However, they don’t actually hold physical data the way tables do. Instead, they pull data dynamically from the underlying tables. Another difference is that while I can insert, update, or delete rows in a table, those operations are usually limited or not possible in views, especially if the view is based on multiple tables or includes aggregate functions. Views also don’t have primary keys like tables do, since they aren’t storing unique rows themselves.
Now that we’ve wrapped up SQL, I’ve also been reflecting on how it compares to other programming languages I’ve studied, like Java. One similarity is that both SQL and Java use conditional logic—WHERE clauses in SQL remind me of if statements in Java, since both filter or control what happens based on a condition. Another connection is that SQL’s SELECT statement is a little like Java’s return statement, since both specify what the output should be. At the same time, SQL is really specialized for working with data and databases, while Java is a general-purpose language that lets me build applications. For example, in Java I can use loops, create objects, and control program flow, which aren’t part of SQL. On the other hand, SQL has powerful features for querying large datasets and performing calculations directly on data in a way that would take much more work in Java.
Overall, I see SQL and Java as complementary. SQL gives me the tools to manage and manipulate data efficiently, while Java gives me the structure and logic to build programs around that data. Learning how the two connect helps me understand how applications and databases communicate in the real world.
Comments
Post a Comment