Posts

Showing posts from November, 2021

SQL : PostgreSQL

  Aggregate Functions Like most other relational database products,  PostgreSQL  supports  aggregate functions . An aggregate function computes a single result from multiple input rows. For example, there are aggregates to compute the  count ,  sum ,  avg  (average),  max  (maximum) and  min  (minimum) over a set of rows. As an example, we can find the highest low-temperature reading anywhere with: SELECT max(temp_lo) FROM weather; max ----- 46 (1 row) If we wanted to know what city (or cities) that reading occurred in, we might try: SELECT city FROM weather WHERE temp_lo = max(temp_lo); WRONG but this will not work since the aggregate  max  cannot be used in the  WHERE  clause. (This restriction exists because the  WHERE  clause determines which rows will be included in the aggregate calculation; so obviously it has to be evaluated before aggregate functions are computed.) However, as is o...

SQL : PostgreSQL

  Aggregate Functions Like most other relational database products,  PostgreSQL  supports  aggregate functions . An aggregate function computes a single result from multiple input rows. For example, there are aggregates to compute the  count ,  sum ,  avg  (average),  max  (maximum) and  min  (minimum) over a set of rows. As an example, we can find the highest low-temperature reading anywhere with: SELECT max(temp_lo) FROM weather; max ----- 46 (1 row) If we wanted to know what city (or cities) that reading occurred in, we might try: SELECT city FROM weather WHERE temp_lo = max(temp_lo); WRONG but this will not work since the aggregate  max  cannot be used in the  WHERE  clause. (This restriction exists because the  WHERE  clause determines which rows will be included in the aggregate calculation; so obviously it has to be evaluated before aggregate functions are computed.) However, as is o...

Data model : from IBM

  Data model families: The Fab 5 Now that you’ve got a handle on licenses, let’s talk about another critical consideration when selecting your database—data models. When I first started at IBM, I needed to get up to speed fast, so I turned to Martin Fowler’s  NoSQL Distilled . In his writing, and in the industry at large, people tend to categorize databases into five "data model" families: document, key-value, graph, relational, and wide columnar. Here’s a quick overview of each one, including use cases and database-specific examples. This will help you determine, based on your data sets and business needs, which database you need. 1. Document In this case, data is modeled in JSON-like documents, rather than rows and columns. These databases, by nature, value availability over transactional consistency. Document databases lend themselves to simplicity and scalability, as well as fast iteration in development. Business use cases: Mobile apps that require fast iterations Ev...

Familiarize with the ER diagram : UCDAVIS

Image
  Module 2 Coding Assignment Latest Submission Grade 88.88% 1 . Question 1 All of the questions in this quiz refer to the open source Chinook Database. Please familiarize yourself with the ER diagram to familiarize yourself with the table and column names to write accurate queries and get the appropriate answers. Run Query: Find all the tracks that have a length of 5,000,000 milliseconds or more. 1 2 3 4 SELECT   * FROM  Tracks WHERE  Milliseconds  >=   5000000   Run Reset +---------+-------------------------+---------+-------------+---------+----------+--------------+------------+-----------+ | TrackId | Name | AlbumId | MediaTypeId | GenreId | Composer | Milliseconds | Bytes | UnitPrice | +---------+-------------------------+---------+-------------+---------+----------+--------------+------------+-----------+ | 2820 | Occupation / Precipice | 227 | 3 | 19 | None | 5286953 | 1054423946 | ...