CST 363 Week 3
An SQL View is a table based on the result of an SQL query or Script. It gets its data from one or multiple tables. An interesting use for views is getting what you want from multiple tables or just one table in a specific way using scripts that can have complex calculations.
An example of would be if you have multiple tables and you want to get the data organized in one place. Even though this can be done without really creating a view, simply by using JPA to create your query or script, but sometimes it's easier to create the logic in SQL and then just read from the view directly into your java service layer.
SQL is an interesting language, it has a lot of similarities to java and other languages that I used in the past like python and swift but it also has its uniqueness. Java is an object oriented general purpose programming language while SQL is table based language. In my opinion writing SQL is a lot easier and more efficient for data processing and getting things done. Normally I always get into this debate at work where some people prefer to manipulate their data in SQL (JPQL) first and get it sorted and ready to use into their objects, vs getting the raw data and using Java to do the work. At the end it's a personal preference but I think SQL is an essential language to learn because it can be very useful in some situations.
Comments
Post a Comment