Computer Science BS Journal (CST363) : Week 3

 

1.What is an SQL view.  How is it similar to a table? In what ways is it different (think about primary keys,  insert, update, delete operations) ?

    An SQL view is a virtual table that is created by saving the result of a SELECT query. It does not store data itself but presents data from one or more underlying base tables. A view is similar to a table in that you can query it using SELECT statements, apply filtering, sorting, and even joins, just like with a regular table. However, views differ from tables in several key ways. Unlike tables, views do not physically store data, and they cannot have primary keys defined on them. Additionally, while tables fully support INSERT, UPDATE, and DELETE operations, views only support these operations under certain conditions. For example, a view must be updatable—typically meaning it is based on a single table without joins, aggregations, or GROUP BY clauses—to allow data modifications. Even when a view is updatable, restrictions still apply depending on the database system and the structure of the view. Views are often used to simplify complex queries, encapsulate logic, or restrict access to specific columns or rows of data.


2.We have completed our study of SQL for this course.  This is not to imply that we have studied everything in the language.  There are many specialized features such as calculating rolling averages, query of spatial data (data with latitude and longitude) coordinates, and more. But take a minute to think about how SQL compares to other programming languages such as Java.  What features are similar , and which are present in one language but not in the other?  For example,  Java has conditional if statements which are similar to SQL WHERE predicates,  the SELECT clause is similar to a RETURN statement in that it specifies what data or expression values are to be returned in the query result (although it is strange that a statement should specify the RETURN as the first part of a SELECT. 

    SQL and Java serve different purposes and have different paradigms, but they do share some similarities. SQL is a declarative language used primarily for querying and manipulating relational data, while Java is an imperative, object-oriented programming language used for building general-purpose applications. Both languages feature conditional logic: Java uses if statements and switch cases, while SQL uses WHERE clauses and CASE expressions to apply logic within queries. Similarly, SQL’s SELECT clause determines what data is returned by a query, which is conceptually similar to Java’s return statement in a method, although it's unusual that SQL starts its query with the return specification.
Despite these similarities, many features are unique to one language. SQL excels at operating on sets of data all at once, while Java works with individual objects and gives full control over logic flow, error handling, and program structure. Java supports object-oriented features like classes, inheritance, and polymorphism, which SQL lacks. On the other hand, SQL is uniquely capable of efficiently retrieving, filtering, aggregating, and joining large amounts of data with concise syntax. In practice, SQL and Java are often used together: SQL handles the data retrieval and manipulation, while Java manages the application logic and user interaction.

Comments

Popular posts from this blog

Computer Science BS Journal: Week 4

Computer Science BS Journal: Week 2

Computer Science BS Journal: Week 5