Prepstellar

SQL Fundamentals · Getting started

19 cards

SQL and PostgreSQL Basics

Swipe, scroll or use ← →
  1. Tell the language apart from the system

    Before writing a single statement, settle what each name means. It saves weeks of confusion later.

    SQL is the language used to express work with data. PostgreSQL is an open-source object-relational database system that uses and extends the SQL language: it stores and manages the data and carries out SQL commands.

    Name What it is What it does
    SQL A language Expresses the request: define a structure, store rows, retrieve data, change stored data
    PostgreSQL A database system Holds the managed data and performs the requested action

    Keeping the two apart prevents the most common beginner mistake: a SQL statement is not itself a database server, and PostgreSQL is much more than a collection of statements.

    1 / 19
  2. Tell the language apart from the system

    Picture a team that records orders all day and needs answers from them: which orders shipped late, which customers come back. Two different things are at work.

    • The records live somewhere that keeps them safe and available. That place is PostgreSQL, the database system.
    • The requestgive me last month's late orders, mark this order as shipped — is written in SQL and handed to that system.

    A client program sends the SQL; PostgreSQL performs the database action and returns a result. Neither name can be swapped for the other.

    2 / 19
  3. Quick check

    A team stores changing business records, retrieves selected results, and wants the request language kept separate from the system that manages storage. Which description fits?

    1. ASQL stores the server files, and PostgreSQL is a single clause inside one query statement

      The database system manages stored files; the language does not, and PostgreSQL is far more than one clause.

    2. BPostgreSQL manages the records, and SQL expresses the queries and the changes

      Right. The system owns managed storage and execution, while the language expresses the work that is requested.

    3. CA returned row manages PostgreSQL, and SQL replaces the client program entirely

      A row is returned data, and SQL is a language rather than a substitute for the program that connects.

    3 / 19

  4. What the database system takes responsibility for

    The point of a database system is that you stop looking after the data by hand. PostgreSQL is designed to store and scale data workloads while providing features for reliability, data integrity, and extensibility. Clients then ask it for useful results or request controlled changes.

    That responsibility covers more than saving bytes:

    Responsibility What it means in practice
    Storage and scale The same design holds a hobby project and a workload of many concurrent users.
    Reliability The data survives ordinary failures instead of depending on one careful person.
    Data integrity Rules about valid data are enforced by the system, not by every application separately.
    Extensibility The system can be extended when built-in behavior is not enough.
    4 / 19
  5. What the database system takes responsibility for

    Some capabilities are worth recognizing by name now, even though later lessons explain each one. PostgreSQL supports complex queries, foreign keys, updatable views, and transactional integrity.

    • Complex queries combine and summarize data instead of returning one raw table.
    • Foreign keys tie a row in one table to a row in another and keep that link honest.
    • Updatable views let a saved query behave like a table you can also write through.
    • Transactional integrity makes a group of changes take effect together or not at all.

    Read them for now as responsibilities of the database system that SQL gives you access to.

    5 / 19
  6. Quick check

    Which group lists capabilities that belong to PostgreSQL as a database system?

    1. AComplex queries, foreign keys, updatable views, and transactional integrity

      Right. Query power, table relationships, writable views, and all-or-nothing changes are exactly what the system provides.

    2. BA single immutable row, no integrity rules at all, and no way to extend the system

      The system enforces integrity and can be extended, so a list that denies both describes something else.

    3. CText formatting, screen themes, and removal of operating-system packages

      Those are interface and package-management tasks, not the work of a database system.

    6 / 19

  7. The cycle that SQL expresses

    Almost every piece of database work is a lap around the same short cycle. SQL can create tables, populate them with rows, query stored data, update existing rows, and delete rows.

    Stage Statement The question it answers
    Define CREATE TABLE What shape does this data have?
    Populate INSERT What do we know so far?
    Query SELECT What does the data say?
    Update UPDATE What has changed in reality?
    Delete DELETE What no longer belongs here?

    Define a structure, put data in it, retrieve what a question needs, and change the stored state when reality changes.

    7 / 19
  8. The cycle that SQL expresses

    The cycle is a loop, not a checklist you finish once. A new column arrives, more rows are inserted, yesterday's query is refined, a wrong record is corrected.

    Because the loop repeats, it pays to name each stage precisely. Retrieval never changes stored data; an update never invents a new table. When something behaves unexpectedly, knowing which stage you are in usually points straight at the cause.

    8 / 19
  9. Quick check

    Which sequence describes the core data-work cycle that SQL expresses?

    1. AOpen a client, rename the server, and then discard every table in the database

      Opening a client is how you reach the database; renaming or discarding the system is not the data cycle.

    2. BCreate a network, compile each stored row, and print the server's own files

      Rows are managed data inside tables; they are not compiled into network or file artifacts.

    3. CDefine the tables, store rows inside them, query the stored data, and modify existing rows

      Right. Structure, insertion, retrieval, and change are the four recurring stages of the cycle.

    9 / 19

  10. Keep your progress in the app

    That’s 3 of 7 quick checks. In the app they stay answered, and every lesson remembers where you left off.

  11. Asking a question with SELECT

    A query is a request for data, not a request to open a particular file. You describe what you want, and the database system decides how to get it.

    A SELECT statement retrieves data from a table and can choose columns, restrict rows, compute expressions, sort results, and remove duplicate result rows.

    What you want What SELECT does
    Only some columns Chooses which columns appear in the result
    Only some rows Restricts the rows to those that match a condition
    A derived value Computes an expression, such as an average of two columns
    A readable order Sorts the returned result
    No repetition Removes duplicate result rows

    The neighboring statements have other jobs: INSERT populates a table, UPDATE changes existing rows, and DELETE removes rows. Only SELECT brings data back to you.

    10 / 19
  12. Quick check

    You need to bring existing table data back for inspection without changing anything stored. Which statement is designed for that?

    1. AAn INSERT statement, because it works directly on the table's rows

      INSERT adds new rows to a table; it does not return the stored data you want to inspect.

    2. BA SELECT statement, because retrieval is exactly its purpose

      Right. SELECT retrieves data and can choose columns, restrict rows, compute values, sort, and drop duplicates.

    3. CAn UPDATE statement, because it can also read the rows that it changes

      UPDATE changes values in existing rows, so it modifies stored data rather than simply returning it.

    11 / 19

  13. Standard SQL and PostgreSQL extensions

    Your SQL knowledge is meant to travel, so it matters where the portable part ends. PostgreSQL supports a large part of the SQL standard and also has language features that are PostgreSQL extensions.

    Both halves of that sentence are useful:

    • Because much of the standard is supported, most of what you learn here reads the same in other SQL systems.
    • Because extensions exist, some syntax and behavior are specific to this product and cannot be assumed elsewhere.

    The documentation says so explicitly, which is why this course flags PostgreSQL-specific facilities as it goes rather than hiding them.

    12 / 19
  14. Standard SQL and PostgreSQL extensions

    Treat portable SQL ideas and PostgreSQL-specific facilities as related, not identical.

    Claim Verdict
    PostgreSQL rejects standard SQL and accepts only graphical commands False: it uses and extends the SQL language.
    PostgreSQL implements nothing beyond one standard statement False: complex queries, keys, views, and transactions are all supported.
    Every PostgreSQL feature behaves identically in every other engine False: extensions are precisely the part that does not transfer for free.
    PostgreSQL supports much of the standard and adds its own extensions True, and it is why the dialect boundary is worth marking.

    When a feature is labeled PostgreSQL-specific, that label is part of the lesson rather than a minor footnote.

    13 / 19
  15. Quick check

    How should PostgreSQL's relationship to standard SQL be understood?

    1. AIt rejects the standard and accepts only commands issued from a graphical tool

      PostgreSQL uses and extends SQL, so the language is central rather than rejected.

    2. BIt makes every one of its features behave identically in all other engines

      Product extensions are exactly the reason identical behavior elsewhere cannot be assumed.

    3. CIt supports much of the standard SQL language and also provides its own product extensions

      Right. Broad standard support plus product-specific additions is what keeps the dialect boundary meaningful.

    14 / 19

  16. Carrying your SQL to another engine

    Two goals pull in opposite directions: you want skills that transfer across SQL products, and you also want a concrete system where queries actually run. You can have both.

    Practice general SQL in PostgreSQL and mark the extensions explicitly as you meet them. A real system makes the language executable and gives immediate feedback, while the labels keep the transferable core visible.

    The alternatives are worse. Assuming every PostgreSQL feature works unchanged elsewhere sets up a failure at the worst moment. Studying vocabulary without ever running a statement leaves no way to check whether your understanding is right.

    15 / 19
  17. Carrying your SQL to another engine

    Now suppose a working query has to move to a different engine.

    1. Identify which parts may be PostgreSQL extensions rather than standard SQL.
    2. Check the target engine's documentation for its equivalent, if it has one.
    3. Rewrite only the parts that need it, and confirm the result on the target.

    What not to do: assume that broad standard support makes everything portable without review, or start reinstalling software before the syntax has even been examined. The mix of standard support and extensions is exactly why verification belongs at the dialect boundary.

    16 / 19
  18. Quick check

    A query runs correctly in PostgreSQL, may use a product extension, and must move to another engine without assuming identical behavior. What is the sound next step?

    1. AIdentify the extension and check the target engine's documented equivalent

      Right. Extensions are the part that may not transfer, so the target's own documentation settles the question.

    2. BAssume broad SQL support makes every feature portable, then skip the review

      Standard support is partial; assuming full portability is what causes the query to fail after the move.

    3. CReclassify PostgreSQL as a statement and the target engine as a column

      Those labels are simply wrong: PostgreSQL is a database system, and an engine is not a column.

    17 / 19

  19. Key takeaways

    • SQL is the language used to express data operations; PostgreSQL is the database system that executes them.
    • PostgreSQL stores and scales data workloads with reliability, data integrity, and extensibility, and supports complex queries, foreign keys, updatable views, and transactional integrity.
    • The core cycle is to define structures, store rows, query data, and modify stored data, with SELECT as the statement that brings data back.
    • PostgreSQL supports much of standard SQL and also provides PostgreSQL-specific extensions, so a feature that is labeled product-specific must be verified before it is carried to another engine.
    18 / 19
  20. Quick check

    Which summary keeps the language, the system, and the dialect boundary in their correct places?

    1. AA statement is the database server, retrieval changes stored rows, and extensions transfer automatically

      A statement is input to the server, retrieval does not change stored data, and extensions are the part that does not transfer for free.

    2. BSQL expresses the work, PostgreSQL executes and stores it, and extensions need checking elsewhere

      Right. Those are the three ideas this lesson rests on: language, system, and an explicit dialect boundary.

    3. CPostgreSQL is one SQL clause, SELECT deletes rows, and standard support removes every difference

      PostgreSQL is a full database system, SELECT retrieves rather than deletes, and partial standard support leaves real differences.

    19 / 19

  21. 7 quick checks · then the test

    In the app, finishing the quick checks opens this lesson’s 10-question test, and the ones you miss come back exactly when you’re about to forget them.

The whole course, on your phone

Lessons you can read, audio you can listen to on the way to work, and practice that remembers what you got wrong.