├── .freeCodeCamp ├── .bashrc ├── .psqlrc ├── pg_hba.conf ├── postgresql.conf └── test │ ├── .cwd │ └── .next_command ├── .gitignore ├── .gitpod.yml ├── .vscode └── settings.json ├── CHANGELOG.md ├── TUTORIAL.md ├── coderoad.yaml └── tutorial.json /.freeCodeCamp/.bashrc: -------------------------------------------------------------------------------- 1 | # ~/.bashrc: executed by bash(1) for non-login shells. 2 | # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) 3 | # for examples 4 | 5 | # If not running interactively, don't do anything 6 | case $- in 7 | *i*) ;; 8 | *) return;; 9 | esac 10 | 11 | # don't put duplicate lines or lines starting with space in the history. 12 | # See bash(1) for more options 13 | # I commented this out 14 | #HISTCONTROL=ignoreboth 15 | 16 | # append to the history file, don't overwrite it 17 | shopt -s histappend 18 | 19 | # for setting history length see HISTSIZE and HISTFILESIZE in bash(1) 20 | HISTSIZE=1000 21 | HISTFILESIZE=2000 22 | 23 | # check the window size after each command and, if necessary, 24 | # update the values of LINES and COLUMNS. 25 | shopt -s checkwinsize 26 | 27 | # If set, the pattern "**" used in a pathname expansion context will 28 | # match all files and zero or more directories and subdirectories. 29 | #shopt -s globstar 30 | 31 | # make less more friendly for non-text input files, see lesspipe(1) 32 | # I commented this out 33 | #[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" 34 | 35 | # set variable identifying the chroot you work in (used in the prompt below) 36 | if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then 37 | debian_chroot=$(cat /etc/debian_chroot) 38 | fi 39 | 40 | # set a fancy prompt (non-color, unless we know we "want" color) 41 | case "$TERM" in 42 | xterm-color|*-256color) color_prompt=yes;; 43 | esac 44 | 45 | # uncomment for a colored prompt, if the terminal has the capability; turned 46 | # off by default to not distract the user: the focus in a terminal window 47 | # should be on the output of commands, not on the prompt 48 | #force_color_prompt=yes 49 | 50 | if [ -n "$force_color_prompt" ]; then 51 | if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then 52 | # We have color support; assume it's compliant with Ecma-48 53 | # (ISO/IEC-6429). (Lack of such support is extremely rare, and such 54 | # a case would tend to support setf rather than setaf.) 55 | color_prompt=yes 56 | else 57 | color_prompt= 58 | fi 59 | fi 60 | 61 | if [ "$color_prompt" = yes ]; then 62 | PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' 63 | else 64 | PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' 65 | fi 66 | unset color_prompt force_color_prompt 67 | 68 | # If this is an xterm set the title to user@host:dir 69 | case "$TERM" in 70 | xterm*|rxvt*) 71 | PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1" 72 | ;; 73 | *) 74 | ;; 75 | esac 76 | 77 | # enable color support of ls and also add handy aliases 78 | if [ -x /usr/bin/dircolors ]; then 79 | test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" 80 | alias ls='ls --color=auto' 81 | #alias dir='dir --color=auto' 82 | #alias vdir='vdir --color=auto' 83 | 84 | # I commented these out 85 | # alias grep='grep --color=auto' 86 | # alias fgrep='fgrep --color=auto' 87 | # alias egrep='egrep --color=auto' 88 | fi 89 | 90 | # colored GCC warnings and errors 91 | #export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01' 92 | 93 | # some more ls aliases - # I commented these out 94 | # alias ll='ls -alF' 95 | # alias la='ls -A' 96 | # alias l='ls -CF' 97 | 98 | # Add an "alert" alias for long running commands. Use like so: 99 | # sleep 10; alert 100 | # I commented this out 101 | #alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"' 102 | 103 | # Alias definitions. 104 | # You may want to put all your additions into a separate file like 105 | # ~/.bash_aliases, instead of adding them here directly. 106 | # See /usr/share/doc/bash-doc/examples in the bash-doc package. 107 | 108 | if [ -f ~/.bash_aliases ]; then 109 | . ~/.bash_aliases 110 | fi 111 | 112 | # enable programmable completion features (you don't need to enable 113 | # this, if it's already enabled in /etc/bash.bashrc and /etc/profile 114 | # sources /etc/bash.bashrc). 115 | if ! shopt -oq posix; then 116 | if [ -f /usr/share/bash-completion/bash_completion ]; then 117 | . /usr/share/bash-completion/bash_completion 118 | elif [ -f /etc/bash_completion ]; then 119 | . /etc/bash_completion 120 | fi 121 | fi 122 | 123 | # I commented this out 124 | #for i in $(ls -A $HOME/.bashrc.d/); do source $HOME/.bashrc.d/$i; done 125 | 126 | # Add RVM to PATH for scripting. Make sure this is the last PATH variable change. 127 | export PATH="$PATH:$HOME/.rvm/bin" 128 | 129 | # stuff I added 130 | PS1='camper: \[\033[01;34m\]/${PWD##*/}\[\033[00m\]\$ ' 131 | HISTFILE=/workspace/.bash_history 132 | PROMPT_COMMAND='echo $PWD >> /workspace/project/.freeCodeCamp/test/.cwd; history -a' 133 | trap 'echo $BASH_COMMAND >> /workspace/project/.freeCodeCamp/test/.next_command' DEBUG -------------------------------------------------------------------------------- /.freeCodeCamp/.psqlrc: -------------------------------------------------------------------------------- 1 | \out | tee /workspace/queryResults.log 2 | \pset border 2 3 | \pset title ' ' 4 | \pset pager off -------------------------------------------------------------------------------- /.freeCodeCamp/pg_hba.conf: -------------------------------------------------------------------------------- 1 | # PostgreSQL Client Authentication Configuration File 2 | # =================================================== 3 | # 4 | # Refer to the "Client Authentication" section in the PostgreSQL 5 | # documentation for a complete description of this file. A short 6 | # synopsis follows. 7 | # 8 | # This file controls: which hosts are allowed to connect, how clients 9 | # are authenticated, which PostgreSQL user names they can use, which 10 | # databases they can access. Records take one of these forms: 11 | # 12 | # local DATABASE USER METHOD [OPTIONS] 13 | # host DATABASE USER ADDRESS METHOD [OPTIONS] 14 | # hostssl DATABASE USER ADDRESS METHOD [OPTIONS] 15 | # hostnossl DATABASE USER ADDRESS METHOD [OPTIONS] 16 | # 17 | # (The uppercase items must be replaced by actual values.) 18 | # 19 | # The first field is the connection type: "local" is a Unix-domain 20 | # socket, "host" is either a plain or SSL-encrypted TCP/IP socket, 21 | # "hostssl" is an SSL-encrypted TCP/IP socket, and "hostnossl" is a 22 | # plain TCP/IP socket. 23 | # 24 | # DATABASE can be "all", "sameuser", "samerole", "replication", a 25 | # database name, or a comma-separated list thereof. The "all" 26 | # keyword does not match "replication". Access to replication 27 | # must be enabled in a separate record (see example below). 28 | # 29 | # USER can be "all", a user name, a group name prefixed with "+", or a 30 | # comma-separated list thereof. In both the DATABASE and USER fields 31 | # you can also write a file name prefixed with "@" to include names 32 | # from a separate file. 33 | # 34 | # ADDRESS specifies the set of hosts the record matches. It can be a 35 | # host name, or it is made up of an IP address and a CIDR mask that is 36 | # an integer (between 0 and 32 (IPv4) or 128 (IPv6) inclusive) that 37 | # specifies the number of significant bits in the mask. A host name 38 | # that starts with a dot (.) matches a suffix of the actual host name. 39 | # Alternatively, you can write an IP address and netmask in separate 40 | # columns to specify the set of hosts. Instead of a CIDR-address, you 41 | # can write "samehost" to match any of the server's own IP addresses, 42 | # or "samenet" to match any address in any subnet that the server is 43 | # directly connected to. 44 | # 45 | # METHOD can be "trust", "reject", "md5", "password", "scram-sha-256", 46 | # "gss", "sspi", "ident", "peer", "pam", "ldap", "radius" or "cert". 47 | # Note that "password" sends passwords in clear text; "md5" or 48 | # "scram-sha-256" are preferred since they send encrypted passwords. 49 | # 50 | # OPTIONS are a set of options for the authentication in the format 51 | # NAME=VALUE. The available options depend on the different 52 | # authentication methods -- refer to the "Client Authentication" 53 | # section in the documentation for a list of which options are 54 | # available for which authentication methods. 55 | # 56 | # Database and user names containing spaces, commas, quotes and other 57 | # special characters must be quoted. Quoting one of the keywords 58 | # "all", "sameuser", "samerole" or "replication" makes the name lose 59 | # its special character, and just match a database or username with 60 | # that name. 61 | # 62 | # This file is read on server startup and when the server receives a 63 | # SIGHUP signal. If you edit the file on a running system, you have to 64 | # SIGHUP the server for the changes to take effect, run "pg_ctl reload", 65 | # or execute "SELECT pg_reload_conf()". 66 | # 67 | # Put your actual configuration here 68 | # ---------------------------------- 69 | # 70 | # If you want to allow non-local connections, you need to add more 71 | # "host" records. In that case you will also need to make PostgreSQL 72 | # listen on a non-local interface via the listen_addresses 73 | # configuration parameter, or via the -i or -h command line switches. 74 | 75 | 76 | 77 | 78 | # DO NOT DISABLE! 79 | # If you change this first entry you will need to make sure that the 80 | # database superuser can access the database using some other method. 81 | # Noninteractive access to all databases is required during automatic 82 | # maintenance (custom daily cronjobs, replication, and similar tasks). 83 | # 84 | # Database administrative login by Unix domain socket 85 | local all postgres trust 86 | 87 | # TYPE DATABASE USER ADDRESS METHOD 88 | 89 | # "local" is for Unix domain socket connections only 90 | local all all trust 91 | # IPv4 local connections: 92 | host all all 127.0.0.1/32 trust 93 | # IPv6 local connections: 94 | host all all ::1/128 trust 95 | # Allow replication connections from localhost, by a user with the 96 | # replication privilege. 97 | local replication all trust 98 | host replication all 127.0.0.1/32 trust 99 | host replication all ::1/128 trust -------------------------------------------------------------------------------- /.freeCodeCamp/postgresql.conf: -------------------------------------------------------------------------------- 1 | # ----------------------------- 2 | # PostgreSQL configuration file 3 | # ----------------------------- 4 | # 5 | # This file consists of lines of the form: 6 | # 7 | # name = value 8 | # 9 | # (The "=" is optional.) Whitespace may be used. Comments are introduced with 10 | # "#" anywhere on a line. The complete list of parameter names and allowed 11 | # values can be found in the PostgreSQL documentation. 12 | # 13 | # The commented-out settings shown in this file represent the default values. 14 | # Re-commenting a setting is NOT sufficient to revert it to the default value; 15 | # you need to reload the server. 16 | # 17 | # This file is read on server startup and when the server receives a SIGHUP 18 | # signal. If you edit the file on a running system, you have to SIGHUP the 19 | # server for the changes to take effect, run "pg_ctl reload", or execute 20 | # "SELECT pg_reload_conf()". Some parameters, which are marked below, 21 | # require a server shutdown and restart to take effect. 22 | # 23 | # Any parameter can also be given as a command-line option to the server, e.g., 24 | # "postgres -c log_connections=on". Some parameters can be changed at run time 25 | # with the "SET" SQL command. 26 | # 27 | # Memory units: kB = kilobytes Time units: ms = milliseconds 28 | # MB = megabytes s = seconds 29 | # GB = gigabytes min = minutes 30 | # TB = terabytes h = hours 31 | # d = days 32 | 33 | 34 | #------------------------------------------------------------------------------ 35 | # FILE LOCATIONS 36 | #------------------------------------------------------------------------------ 37 | 38 | # The default values of these variables are driven from the -D command-line 39 | # option or PGDATA environment variable, represented here as ConfigDir. 40 | 41 | data_directory = '/var/lib/postgresql/12/main' # use data in another directory 42 | # (change requires restart) 43 | hba_file = '/etc/postgresql/12/main/pg_hba.conf' # host-based authentication file 44 | # (change requires restart) 45 | ident_file = '/etc/postgresql/12/main/pg_ident.conf' # ident configuration file 46 | # (change requires restart) 47 | 48 | # If external_pid_file is not explicitly set, no extra PID file is written. 49 | external_pid_file = '/var/run/postgresql/12-main.pid' # write an extra PID file 50 | # (change requires restart) 51 | 52 | 53 | #------------------------------------------------------------------------------ 54 | # CONNECTIONS AND AUTHENTICATION 55 | #------------------------------------------------------------------------------ 56 | 57 | # - Connection Settings - 58 | 59 | #listen_addresses = 'localhost' # what IP address(es) to listen on; 60 | # comma-separated list of addresses; 61 | # defaults to 'localhost'; use '*' for all 62 | # (change requires restart) 63 | port = 5432 # (change requires restart) 64 | max_connections = 100 # (change requires restart) 65 | #superuser_reserved_connections = 3 # (change requires restart) 66 | unix_socket_directories = '/var/run/postgresql' # comma-separated list of directories 67 | # (change requires restart) 68 | #unix_socket_group = '' # (change requires restart) 69 | #unix_socket_permissions = 0777 # begin with 0 to use octal notation 70 | # (change requires restart) 71 | #bonjour = off # advertise server via Bonjour 72 | # (change requires restart) 73 | #bonjour_name = '' # defaults to the computer name 74 | # (change requires restart) 75 | 76 | # - TCP settings - 77 | # see "man 7 tcp" for details 78 | 79 | #tcp_keepalives_idle = 0 # TCP_KEEPIDLE, in seconds; 80 | # 0 selects the system default 81 | #tcp_keepalives_interval = 0 # TCP_KEEPINTVL, in seconds; 82 | # 0 selects the system default 83 | #tcp_keepalives_count = 0 # TCP_KEEPCNT; 84 | # 0 selects the system default 85 | #tcp_user_timeout = 0 # TCP_USER_TIMEOUT, in milliseconds; 86 | # 0 selects the system default 87 | 88 | # - Authentication - 89 | 90 | #authentication_timeout = 1min # 1s-600s 91 | #password_encryption = md5 # md5 or scram-sha-256 92 | #db_user_namespace = off 93 | 94 | # GSSAPI using Kerberos 95 | #krb_server_keyfile = '' 96 | #krb_caseins_users = off 97 | 98 | # - SSL - 99 | 100 | ssl = on 101 | #ssl_ca_file = '' 102 | ssl_cert_file = '/etc/ssl/certs/ssl-cert-snakeoil.pem' 103 | #ssl_crl_file = '' 104 | ssl_key_file = '/etc/ssl/private/ssl-cert-snakeoil.key' 105 | #ssl_ciphers = 'HIGH:MEDIUM:+3DES:!aNULL' # allowed SSL ciphers 106 | #ssl_prefer_server_ciphers = on 107 | #ssl_ecdh_curve = 'prime256v1' 108 | #ssl_min_protocol_version = 'TLSv1' 109 | #ssl_max_protocol_version = '' 110 | #ssl_dh_params_file = '' 111 | #ssl_passphrase_command = '' 112 | #ssl_passphrase_command_supports_reload = off 113 | 114 | 115 | #------------------------------------------------------------------------------ 116 | # RESOURCE USAGE (except WAL) 117 | #------------------------------------------------------------------------------ 118 | 119 | # - Memory - 120 | 121 | shared_buffers = 128MB # min 128kB 122 | # (change requires restart) 123 | #huge_pages = try # on, off, or try 124 | # (change requires restart) 125 | #temp_buffers = 8MB # min 800kB 126 | #max_prepared_transactions = 0 # zero disables the feature 127 | # (change requires restart) 128 | # Caution: it is not advisable to set max_prepared_transactions nonzero unless 129 | # you actively intend to use prepared transactions. 130 | #work_mem = 4MB # min 64kB 131 | #maintenance_work_mem = 64MB # min 1MB 132 | #autovacuum_work_mem = -1 # min 1MB, or -1 to use maintenance_work_mem 133 | #max_stack_depth = 2MB # min 100kB 134 | #shared_memory_type = mmap # the default is the first option 135 | # supported by the operating system: 136 | # mmap 137 | # sysv 138 | # windows 139 | # (change requires restart) 140 | dynamic_shared_memory_type = posix # the default is the first option 141 | # supported by the operating system: 142 | # posix 143 | # sysv 144 | # windows 145 | # mmap 146 | # (change requires restart) 147 | 148 | # - Disk - 149 | 150 | #temp_file_limit = -1 # limits per-process temp file space 151 | # in kB, or -1 for no limit 152 | 153 | # - Kernel Resources - 154 | 155 | #max_files_per_process = 1000 # min 25 156 | # (change requires restart) 157 | 158 | # - Cost-Based Vacuum Delay - 159 | 160 | #vacuum_cost_delay = 0 # 0-100 milliseconds (0 disables) 161 | #vacuum_cost_page_hit = 1 # 0-10000 credits 162 | #vacuum_cost_page_miss = 10 # 0-10000 credits 163 | #vacuum_cost_page_dirty = 20 # 0-10000 credits 164 | #vacuum_cost_limit = 200 # 1-10000 credits 165 | 166 | # - Background Writer - 167 | 168 | #bgwriter_delay = 200ms # 10-10000ms between rounds 169 | #bgwriter_lru_maxpages = 100 # max buffers written/round, 0 disables 170 | #bgwriter_lru_multiplier = 2.0 # 0-10.0 multiplier on buffers scanned/round 171 | #bgwriter_flush_after = 512kB # measured in pages, 0 disables 172 | 173 | # - Asynchronous Behavior - 174 | 175 | #effective_io_concurrency = 1 # 1-1000; 0 disables prefetching 176 | #max_worker_processes = 8 # (change requires restart) 177 | #max_parallel_maintenance_workers = 2 # taken from max_parallel_workers 178 | #max_parallel_workers_per_gather = 2 # taken from max_parallel_workers 179 | #parallel_leader_participation = on 180 | #max_parallel_workers = 8 # maximum number of max_worker_processes that 181 | # can be used in parallel operations 182 | #old_snapshot_threshold = -1 # 1min-60d; -1 disables; 0 is immediate 183 | # (change requires restart) 184 | #backend_flush_after = 0 # measured in pages, 0 disables 185 | 186 | 187 | #------------------------------------------------------------------------------ 188 | # WRITE-AHEAD LOG 189 | #------------------------------------------------------------------------------ 190 | 191 | # - Settings - 192 | 193 | #wal_level = replica # minimal, replica, or logical 194 | # (change requires restart) 195 | #fsync = on # flush data to disk for crash safety 196 | # (turning this off can cause 197 | # unrecoverable data corruption) 198 | #synchronous_commit = on # synchronization level; 199 | # off, local, remote_write, remote_apply, or on 200 | #wal_sync_method = fsync # the default is the first option 201 | # supported by the operating system: 202 | # open_datasync 203 | # fdatasync (default on Linux) 204 | # fsync 205 | # fsync_writethrough 206 | # open_sync 207 | #full_page_writes = on # recover from partial page writes 208 | #wal_compression = off # enable compression of full-page writes 209 | #wal_log_hints = off # also do full page writes of non-critical updates 210 | # (change requires restart) 211 | #wal_init_zero = on # zero-fill new WAL files 212 | #wal_recycle = on # recycle WAL files 213 | #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers 214 | # (change requires restart) 215 | #wal_writer_delay = 200ms # 1-10000 milliseconds 216 | #wal_writer_flush_after = 1MB # measured in pages, 0 disables 217 | 218 | #commit_delay = 0 # range 0-100000, in microseconds 219 | #commit_siblings = 5 # range 1-1000 220 | 221 | # - Checkpoints - 222 | 223 | #checkpoint_timeout = 5min # range 30s-1d 224 | max_wal_size = 1GB 225 | min_wal_size = 80MB 226 | #checkpoint_completion_target = 0.5 # checkpoint target duration, 0.0 - 1.0 227 | #checkpoint_flush_after = 256kB # measured in pages, 0 disables 228 | #checkpoint_warning = 30s # 0 disables 229 | 230 | # - Archiving - 231 | 232 | #archive_mode = off # enables archiving; off, on, or always 233 | # (change requires restart) 234 | #archive_command = '' # command to use to archive a logfile segment 235 | # placeholders: %p = path of file to archive 236 | # %f = file name only 237 | # e.g. 'test ! -f /mnt/server/archivedir/%f && cp %p /mnt/server/archivedir/%f' 238 | #archive_timeout = 0 # force a logfile segment switch after this 239 | # number of seconds; 0 disables 240 | 241 | # - Archive Recovery - 242 | 243 | # These are only used in recovery mode. 244 | 245 | #restore_command = '' # command to use to restore an archived logfile segment 246 | # placeholders: %p = path of file to restore 247 | # %f = file name only 248 | # e.g. 'cp /mnt/server/archivedir/%f %p' 249 | # (change requires restart) 250 | #archive_cleanup_command = '' # command to execute at every restartpoint 251 | #recovery_end_command = '' # command to execute at completion of recovery 252 | 253 | # - Recovery Target - 254 | 255 | # Set these only when performing a targeted recovery. 256 | 257 | #recovery_target = '' # 'immediate' to end recovery as soon as a 258 | # consistent state is reached 259 | # (change requires restart) 260 | #recovery_target_name = '' # the named restore point to which recovery will proceed 261 | # (change requires restart) 262 | #recovery_target_time = '' # the time stamp up to which recovery will proceed 263 | # (change requires restart) 264 | #recovery_target_xid = '' # the transaction ID up to which recovery will proceed 265 | # (change requires restart) 266 | #recovery_target_lsn = '' # the WAL LSN up to which recovery will proceed 267 | # (change requires restart) 268 | #recovery_target_inclusive = on # Specifies whether to stop: 269 | # just after the specified recovery target (on) 270 | # just before the recovery target (off) 271 | # (change requires restart) 272 | #recovery_target_timeline = 'latest' # 'current', 'latest', or timeline ID 273 | # (change requires restart) 274 | #recovery_target_action = 'pause' # 'pause', 'promote', 'shutdown' 275 | # (change requires restart) 276 | 277 | 278 | #------------------------------------------------------------------------------ 279 | # REPLICATION 280 | #------------------------------------------------------------------------------ 281 | 282 | # - Sending Servers - 283 | 284 | # Set these on the master and on any standby that will send replication data. 285 | 286 | #max_wal_senders = 10 # max number of walsender processes 287 | # (change requires restart) 288 | #wal_keep_segments = 0 # in logfile segments; 0 disables 289 | #wal_sender_timeout = 60s # in milliseconds; 0 disables 290 | 291 | #max_replication_slots = 10 # max number of replication slots 292 | # (change requires restart) 293 | #track_commit_timestamp = off # collect timestamp of transaction commit 294 | # (change requires restart) 295 | 296 | # - Master Server - 297 | 298 | # These settings are ignored on a standby server. 299 | 300 | #synchronous_standby_names = '' # standby servers that provide sync rep 301 | # method to choose sync standbys, number of sync standbys, 302 | # and comma-separated list of application_name 303 | # from standby(s); '*' = all 304 | #vacuum_defer_cleanup_age = 0 # number of xacts by which cleanup is delayed 305 | 306 | # - Standby Servers - 307 | 308 | # These settings are ignored on a master server. 309 | 310 | #primary_conninfo = '' # connection string to sending server 311 | # (change requires restart) 312 | #primary_slot_name = '' # replication slot on sending server 313 | # (change requires restart) 314 | #promote_trigger_file = '' # file name whose presence ends recovery 315 | #hot_standby = on # "off" disallows queries during recovery 316 | # (change requires restart) 317 | #max_standby_archive_delay = 30s # max delay before canceling queries 318 | # when reading WAL from archive; 319 | # -1 allows indefinite delay 320 | #max_standby_streaming_delay = 30s # max delay before canceling queries 321 | # when reading streaming WAL; 322 | # -1 allows indefinite delay 323 | #wal_receiver_status_interval = 10s # send replies at least this often 324 | # 0 disables 325 | #hot_standby_feedback = off # send info from standby to prevent 326 | # query conflicts 327 | #wal_receiver_timeout = 60s # time that receiver waits for 328 | # communication from master 329 | # in milliseconds; 0 disables 330 | #wal_retrieve_retry_interval = 5s # time to wait before retrying to 331 | # retrieve WAL after a failed attempt 332 | #recovery_min_apply_delay = 0 # minimum delay for applying changes during recovery 333 | 334 | # - Subscribers - 335 | 336 | # These settings are ignored on a publisher. 337 | 338 | #max_logical_replication_workers = 4 # taken from max_worker_processes 339 | # (change requires restart) 340 | #max_sync_workers_per_subscription = 2 # taken from max_logical_replication_workers 341 | 342 | 343 | #------------------------------------------------------------------------------ 344 | # QUERY TUNING 345 | #------------------------------------------------------------------------------ 346 | 347 | # - Planner Method Configuration - 348 | 349 | #enable_bitmapscan = on 350 | #enable_hashagg = on 351 | #enable_hashjoin = on 352 | #enable_indexscan = on 353 | #enable_indexonlyscan = on 354 | #enable_material = on 355 | #enable_mergejoin = on 356 | #enable_nestloop = on 357 | #enable_parallel_append = on 358 | #enable_seqscan = on 359 | #enable_sort = on 360 | #enable_tidscan = on 361 | #enable_partitionwise_join = off 362 | #enable_partitionwise_aggregate = off 363 | #enable_parallel_hash = on 364 | #enable_partition_pruning = on 365 | 366 | # - Planner Cost Constants - 367 | 368 | #seq_page_cost = 1.0 # measured on an arbitrary scale 369 | #random_page_cost = 4.0 # same scale as above 370 | #cpu_tuple_cost = 0.01 # same scale as above 371 | #cpu_index_tuple_cost = 0.005 # same scale as above 372 | #cpu_operator_cost = 0.0025 # same scale as above 373 | #parallel_tuple_cost = 0.1 # same scale as above 374 | #parallel_setup_cost = 1000.0 # same scale as above 375 | 376 | #jit_above_cost = 100000 # perform JIT compilation if available 377 | # and query more expensive than this; 378 | # -1 disables 379 | #jit_inline_above_cost = 500000 # inline small functions if query is 380 | # more expensive than this; -1 disables 381 | #jit_optimize_above_cost = 500000 # use expensive JIT optimizations if 382 | # query is more expensive than this; 383 | # -1 disables 384 | 385 | #min_parallel_table_scan_size = 8MB 386 | #min_parallel_index_scan_size = 512kB 387 | #effective_cache_size = 4GB 388 | 389 | # - Genetic Query Optimizer - 390 | 391 | #geqo = on 392 | #geqo_threshold = 12 393 | #geqo_effort = 5 # range 1-10 394 | #geqo_pool_size = 0 # selects default based on effort 395 | #geqo_generations = 0 # selects default based on effort 396 | #geqo_selection_bias = 2.0 # range 1.5-2.0 397 | #geqo_seed = 0.0 # range 0.0-1.0 398 | 399 | # - Other Planner Options - 400 | 401 | #default_statistics_target = 100 # range 1-10000 402 | #constraint_exclusion = partition # on, off, or partition 403 | #cursor_tuple_fraction = 0.1 # range 0.0-1.0 404 | #from_collapse_limit = 8 405 | #join_collapse_limit = 8 # 1 disables collapsing of explicit 406 | # JOIN clauses 407 | #force_parallel_mode = off 408 | #jit = on # allow JIT compilation 409 | #plan_cache_mode = auto # auto, force_generic_plan or 410 | # force_custom_plan 411 | 412 | 413 | #------------------------------------------------------------------------------ 414 | # REPORTING AND LOGGING 415 | #------------------------------------------------------------------------------ 416 | 417 | # - Where to Log - 418 | 419 | #log_destination = 'stderr' # Valid values are combinations of 420 | # stderr, csvlog, syslog, and eventlog, 421 | # depending on platform. csvlog 422 | # requires logging_collector to be on. 423 | 424 | # This is used when logging to stderr: 425 | #logging_collector = off # Enable capturing of stderr and csvlog 426 | # into log files. Required to be on for 427 | # csvlogs. 428 | # (change requires restart) 429 | 430 | # These are only used if logging_collector is on: 431 | #log_directory = 'log' # directory where log files are written, 432 | # can be absolute or relative to PGDATA 433 | #log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log' # log file name pattern, 434 | # can include strftime() escapes 435 | #log_file_mode = 0600 # creation mode for log files, 436 | # begin with 0 to use octal notation 437 | #log_truncate_on_rotation = off # If on, an existing log file with the 438 | # same name as the new log file will be 439 | # truncated rather than appended to. 440 | # But such truncation only occurs on 441 | # time-driven rotation, not on restarts 442 | # or size-driven rotation. Default is 443 | # off, meaning append to existing files 444 | # in all cases. 445 | #log_rotation_age = 1d # Automatic rotation of logfiles will 446 | # happen after that time. 0 disables. 447 | #log_rotation_size = 10MB # Automatic rotation of logfiles will 448 | # happen after that much log output. 449 | # 0 disables. 450 | 451 | # These are relevant when logging to syslog: 452 | #syslog_facility = 'LOCAL0' 453 | #syslog_ident = 'postgres' 454 | #syslog_sequence_numbers = on 455 | #syslog_split_messages = on 456 | 457 | # This is only relevant when logging to eventlog (win32): 458 | # (change requires restart) 459 | #event_source = 'PostgreSQL' 460 | 461 | # - When to Log - 462 | 463 | #log_min_messages = warning # values in order of decreasing detail: 464 | # debug5 465 | # debug4 466 | # debug3 467 | # debug2 468 | # debug1 469 | # info 470 | # notice 471 | # warning 472 | # error 473 | # log 474 | # fatal 475 | # panic 476 | 477 | #log_min_error_statement = error # values in order of decreasing detail: 478 | # debug5 479 | # debug4 480 | # debug3 481 | # debug2 482 | # debug1 483 | # info 484 | # notice 485 | # warning 486 | # error 487 | # log 488 | # fatal 489 | # panic (effectively off) 490 | 491 | #log_min_duration_statement = -1 # -1 is disabled, 0 logs all statements 492 | # and their durations, > 0 logs only 493 | # statements running at least this number 494 | # of milliseconds 495 | 496 | #log_transaction_sample_rate = 0.0 # Fraction of transactions whose statements 497 | # are logged regardless of their duration. 1.0 logs all 498 | # statements from all transactions, 0.0 never logs. 499 | 500 | # - What to Log - 501 | 502 | #debug_print_parse = off 503 | #debug_print_rewritten = off 504 | #debug_print_plan = off 505 | #debug_pretty_print = on 506 | #log_checkpoints = off 507 | #log_connections = off 508 | #log_disconnections = off 509 | #log_duration = off 510 | #log_error_verbosity = default # terse, default, or verbose messages 511 | #log_hostname = off 512 | #log_line_prefix = '%m [%p] %q%u@%d ' # special values: 513 | # %a = application name 514 | # %u = user name 515 | # %d = database name 516 | # %r = remote host and port 517 | # %h = remote host 518 | # %p = process ID 519 | # %t = timestamp without milliseconds 520 | # %m = timestamp with milliseconds 521 | # %n = timestamp with milliseconds (as a Unix epoch) 522 | # %i = command tag 523 | # %e = SQL state 524 | # %c = session ID 525 | # %l = session line number 526 | # %s = session start timestamp 527 | # %v = virtual transaction ID 528 | # %x = transaction ID (0 if none) 529 | # %q = stop here in non-session 530 | # processes 531 | # %% = '%' 532 | # e.g. '<%u%%%d> ' 533 | #log_lock_waits = off # log lock waits >= deadlock_timeout 534 | #log_statement = 'none' # none, ddl, mod, all 535 | #log_replication_commands = off 536 | #log_temp_files = -1 # log temporary files equal or larger 537 | # than the specified size in kilobytes; 538 | # -1 disables, 0 logs all temp files 539 | log_timezone = 'Europe/Warsaw' 540 | 541 | #------------------------------------------------------------------------------ 542 | # PROCESS TITLE 543 | #------------------------------------------------------------------------------ 544 | 545 | cluster_name = '12/main' # added to process titles if nonempty 546 | # (change requires restart) 547 | #update_process_title = on 548 | 549 | 550 | #------------------------------------------------------------------------------ 551 | # STATISTICS 552 | #------------------------------------------------------------------------------ 553 | 554 | # - Query and Index Statistics Collector - 555 | 556 | #track_activities = on 557 | #track_counts = on 558 | #track_io_timing = off 559 | #track_functions = none # none, pl, all 560 | #track_activity_query_size = 1024 # (change requires restart) 561 | stats_temp_directory = '/var/run/postgresql/12-main.pg_stat_tmp' 562 | 563 | 564 | # - Monitoring - 565 | 566 | #log_parser_stats = off 567 | #log_planner_stats = off 568 | #log_executor_stats = off 569 | #log_statement_stats = off 570 | 571 | 572 | #------------------------------------------------------------------------------ 573 | # AUTOVACUUM 574 | #------------------------------------------------------------------------------ 575 | 576 | #autovacuum = on # Enable autovacuum subprocess? 'on' 577 | # requires track_counts to also be on. 578 | #log_autovacuum_min_duration = -1 # -1 disables, 0 logs all actions and 579 | # their durations, > 0 logs only 580 | # actions running at least this number 581 | # of milliseconds. 582 | #autovacuum_max_workers = 3 # max number of autovacuum subprocesses 583 | # (change requires restart) 584 | #autovacuum_naptime = 1min # time between autovacuum runs 585 | #autovacuum_vacuum_threshold = 50 # min number of row updates before 586 | # vacuum 587 | #autovacuum_analyze_threshold = 50 # min number of row updates before 588 | # analyze 589 | #autovacuum_vacuum_scale_factor = 0.2 # fraction of table size before vacuum 590 | #autovacuum_analyze_scale_factor = 0.1 # fraction of table size before analyze 591 | #autovacuum_freeze_max_age = 200000000 # maximum XID age before forced vacuum 592 | # (change requires restart) 593 | #autovacuum_multixact_freeze_max_age = 400000000 # maximum multixact age 594 | # before forced vacuum 595 | # (change requires restart) 596 | #autovacuum_vacuum_cost_delay = 2ms # default vacuum cost delay for 597 | # autovacuum, in milliseconds; 598 | # -1 means use vacuum_cost_delay 599 | #autovacuum_vacuum_cost_limit = -1 # default vacuum cost limit for 600 | # autovacuum, -1 means use 601 | # vacuum_cost_limit 602 | 603 | 604 | #------------------------------------------------------------------------------ 605 | # CLIENT CONNECTION DEFAULTS 606 | #------------------------------------------------------------------------------ 607 | 608 | # - Statement Behavior - 609 | 610 | #client_min_messages = notice # values in order of decreasing detail: 611 | # debug5 612 | # debug4 613 | # debug3 614 | # debug2 615 | # debug1 616 | # log 617 | # notice 618 | # warning 619 | # error 620 | #search_path = '"$user", public' # schema names 621 | #row_security = on 622 | #default_tablespace = '' # a tablespace name, '' uses the default 623 | #temp_tablespaces = '' # a list of tablespace names, '' uses 624 | # only default tablespace 625 | #default_table_access_method = 'heap' 626 | #check_function_bodies = on 627 | #default_transaction_isolation = 'read committed' 628 | #default_transaction_read_only = off 629 | #default_transaction_deferrable = off 630 | #session_replication_role = 'origin' 631 | #statement_timeout = 0 # in milliseconds, 0 is disabled 632 | #lock_timeout = 0 # in milliseconds, 0 is disabled 633 | #idle_in_transaction_session_timeout = 0 # in milliseconds, 0 is disabled 634 | #vacuum_freeze_min_age = 50000000 635 | #vacuum_freeze_table_age = 150000000 636 | #vacuum_multixact_freeze_min_age = 5000000 637 | #vacuum_multixact_freeze_table_age = 150000000 638 | #vacuum_cleanup_index_scale_factor = 0.1 # fraction of total number of tuples 639 | # before index cleanup, 0 always performs 640 | # index cleanup 641 | #bytea_output = 'hex' # hex, escape 642 | #xmlbinary = 'base64' 643 | #xmloption = 'content' 644 | #gin_fuzzy_search_limit = 0 645 | #gin_pending_list_limit = 4MB 646 | 647 | # - Locale and Formatting - 648 | 649 | datestyle = 'iso, mdy' 650 | #intervalstyle = 'postgres' 651 | timezone = 'Europe/Warsaw' 652 | #timezone_abbreviations = 'Default' # Select the set of available time zone 653 | # abbreviations. Currently, there are 654 | # Default 655 | # Australia (historical usage) 656 | # India 657 | # You can create your own file in 658 | # share/timezonesets/. 659 | #extra_float_digits = 1 # min -15, max 3; any value >0 actually 660 | # selects precise output mode 661 | #client_encoding = sql_ascii # actually, defaults to database 662 | # encoding 663 | 664 | # These settings are initialized by initdb, but they can be changed. 665 | lc_messages = 'C.UTF-8' # locale for system error message 666 | # strings 667 | lc_monetary = 'C.UTF-8' # locale for monetary formatting 668 | lc_numeric = 'C.UTF-8' # locale for number formatting 669 | lc_time = 'C.UTF-8' # locale for time formatting 670 | 671 | # default configuration for text search 672 | default_text_search_config = 'pg_catalog.english' 673 | 674 | # - Shared Library Preloading - 675 | 676 | #shared_preload_libraries = '' # (change requires restart) 677 | #local_preload_libraries = '' 678 | #session_preload_libraries = '' 679 | #jit_provider = 'llvmjit' # JIT library to use 680 | 681 | # - Other Defaults - 682 | 683 | #dynamic_library_path = '$libdir' 684 | 685 | 686 | #------------------------------------------------------------------------------ 687 | # LOCK MANAGEMENT 688 | #------------------------------------------------------------------------------ 689 | 690 | #deadlock_timeout = 1s 691 | #max_locks_per_transaction = 64 # min 10 692 | # (change requires restart) 693 | #max_pred_locks_per_transaction = 64 # min 10 694 | # (change requires restart) 695 | #max_pred_locks_per_relation = -2 # negative values mean 696 | # (max_pred_locks_per_transaction 697 | # / -max_pred_locks_per_relation) - 1 698 | #max_pred_locks_per_page = 2 # min 0 699 | 700 | 701 | #------------------------------------------------------------------------------ 702 | # VERSION AND PLATFORM COMPATIBILITY 703 | #------------------------------------------------------------------------------ 704 | 705 | # - Previous PostgreSQL Versions - 706 | 707 | #array_nulls = on 708 | #backslash_quote = safe_encoding # on, off, or safe_encoding 709 | #escape_string_warning = on 710 | #lo_compat_privileges = off 711 | #operator_precedence_warning = off 712 | #quote_all_identifiers = off 713 | #standard_conforming_strings = on 714 | #synchronize_seqscans = on 715 | 716 | # - Other Platforms and Clients - 717 | 718 | #transform_null_equals = off 719 | 720 | 721 | #------------------------------------------------------------------------------ 722 | # ERROR HANDLING 723 | #------------------------------------------------------------------------------ 724 | 725 | #exit_on_error = off # terminate session on any error? 726 | #restart_after_crash = on # reinitialize after backend crash? 727 | #data_sync_retry = off # retry or panic on failure to fsync 728 | # data? 729 | # (change requires restart) 730 | 731 | 732 | #------------------------------------------------------------------------------ 733 | # CONFIG FILE INCLUDES 734 | #------------------------------------------------------------------------------ 735 | 736 | # These options allow settings to be loaded from files other than the 737 | # default postgresql.conf. Note that these are directives, not variable 738 | # assignments, so they can usefully be given more than once. 739 | 740 | include_dir = 'conf.d' # include files ending in '.conf' from 741 | # a directory, e.g., 'conf.d' 742 | #include_if_exists = '...' # include file only if it exists 743 | #include = '...' # include file 744 | 745 | 746 | #------------------------------------------------------------------------------ 747 | # CUSTOMIZED OPTIONS 748 | #------------------------------------------------------------------------------ 749 | 750 | # Add settings for extensions here 751 | 752 | # Settings I changed from the defaults above 753 | log_statement = 'all' 754 | log_min_error_statement = INFO 755 | log_min_messages = INFO 756 | logging_collector = on 757 | log_directory = '/workspace/' 758 | log_filename = 'pg.log' 759 | log_connections = on 760 | log_line_prefix = '%u ' -------------------------------------------------------------------------------- /.freeCodeCamp/test/.cwd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/freeCodeCamp/learn-sql-by-building-a-student-database-part-2/2d8816c4ed8b52ba6d9a971668b95d9438daff1f/.freeCodeCamp/test/.cwd -------------------------------------------------------------------------------- /.freeCodeCamp/test/.next_command: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/freeCodeCamp/learn-sql-by-building-a-student-database-part-2/2d8816c4ed8b52ba6d9a971668b95d9438daff1f/.freeCodeCamp/test/.next_command -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .DS_Store 3 | -------------------------------------------------------------------------------- /.gitpod.yml: -------------------------------------------------------------------------------- 1 | image: gitpod/workspace-postgres:2024-01-24-09-19-42 2 | 3 | workspaceLocation: 'project' 4 | checkoutLocation: 'project' 5 | 6 | tasks: 7 | - before: | 8 | sudo cp /workspace/project/.freeCodeCamp/.bashrc ~/.bashrc 9 | sudo cp /workspace/project/.freeCodeCamp/.psqlrc ~/.psqlrc 10 | sudo cp /workspace/project/.freeCodeCamp/postgresql.conf /etc/postgresql/12/main/postgresql.conf 11 | sudo cp /workspace/project/.freeCodeCamp/pg_hba.conf /etc/postgresql/12/main/pg_hba.conf 12 | sudo touch /workspace/.bash_history 13 | sudo touch /workspace/pg.log 14 | sudo touch /workspace/queryResults.log 15 | sudo chmod -R 777 /workspace 16 | sudo chown -R postgres:postgres /var/lib/postgresql/12/main 17 | 18 | command: | 19 | sudo rm /workspace/project/CHANGELOG.md 20 | sudo rm /workspace/project/coderoad.yaml 21 | sudo rm /workspace/project/tutorial.json 22 | sudo rm /workspace/project/TUTORIAL.md 23 | pg_stop && sudo service postgresql start && echo "SELECT 'CREATE USER freecodecamp WITH CREATEDB' WHERE NOT EXISTS (SELECT FROM pg_catalog.pg_roles WHERE rolname='freecodecamp')\gexec" | psql -U postgres -X 24 | exit 25 | 26 | vscode: 27 | extensions: 28 | - CodeRoad.coderoad 29 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "breadcrumbs.enabled": false, 3 | "debug.internalConsoleOptions": "neverOpen", 4 | "debug.showInStatusBar": "never", 5 | "editor.acceptSuggestionOnCommitCharacter": false, 6 | "editor.acceptSuggestionOnEnter": "off", 7 | "editor.autoClosingBrackets": "never", 8 | "editor.codeActionsOnSave": { 9 | "source.fixAll": "explicit" 10 | }, 11 | "editor.hover.enabled": false, 12 | "editor.inlineSuggest.enabled": false, 13 | "editor.minimap.enabled": false, 14 | "editor.parameterHints.enabled": false, 15 | "editor.quickSuggestions": { 16 | "other": false, 17 | "comments": false, 18 | "strings": false 19 | }, 20 | "editor.referenceInfos": false, 21 | "editor.snippetSuggestions": "none", 22 | "editor.suggest.statusBar.visible": false, 23 | "editor.suggestOnTriggerCharacters": false, 24 | "editor.tabSize": 2, 25 | "explorer.autoReveal": false, 26 | "explorer.openEditors.visible": 0, 27 | "extensions.autoCheckUpdates": false, 28 | "extensions.ignoreRecommendations": true, 29 | "files.autoSave": "afterDelay", 30 | "files.exclude": { 31 | "**/.git": true, 32 | "**/.svn": true, 33 | "**/.hg": true, 34 | "**/CVS": true, 35 | "**/.DS_Store": true, 36 | ".vscode": true, 37 | ".gitignore": true, 38 | ".freeCodeCamp": true, 39 | "learn-sql-by-building-a-student-database-part-2": true, 40 | ".gitpod.Dockerfile": true, 41 | ".gitpod.yml": true, 42 | "CHANGELOG.md": true, 43 | "coderoad.yaml": true, 44 | "tutorial.json": true, 45 | "TUTORIAL.md": true 46 | }, 47 | "html.autoClosingTags": false, 48 | "npm.fetchOnlinePackageInfo": false, 49 | "task.slowProviderWarning": false, 50 | "terminal.integrated.allowChords": false, 51 | "terminal.integrated.commandsToSkipShell": ["coderoad.enter"], 52 | "terminal.integrated.enableFileLinks": false, 53 | "terminal.integrated.environmentChangesIndicator": "off", 54 | "terminal.integrated.macOptionIsMeta": true, 55 | "terminal.integrated.showExitAlert": false, 56 | "telemetry.enableTelemetry": false, 57 | "update.mode": "none", 58 | "update.showReleaseNotes": false, 59 | "workbench.enableExperiments": false, 60 | "workbench.startupEditor": "none", 61 | "workbench.colorTheme": "Tomorrow Night Blue", 62 | "workbench.colorCustomizations": { 63 | "[Tomorrow Night Blue]": { 64 | "menu.background": "#0a0a23", 65 | "menu.foreground": "#ffffff", 66 | "activityBar.background": "#0a0a23", 67 | "activityBar.foreground": "#ffffff", 68 | "activityBar.activeBorder": "#ffffff", 69 | "activityBar.border": "#2a2a40", 70 | "editorWidget.background": "#0a0a23", 71 | "editorWidget.foreground": "#ffffff", 72 | "sideBar.background": "#1b1b32", 73 | "sideBarTitle.foreground": "#858591", 74 | "sideBar.foreground": "#f5f6f7", 75 | "sideBar.border": "#2a2a40", 76 | "editor.background": "#2a2a40", 77 | "editor.foreground": "#dfdfe2", 78 | "tab.activeForeground": "#ffffff", 79 | "tab.inactiveBackground": "#1b1b32", 80 | "tab.inactiveForeground": "#d0d0d5", 81 | "tab.border": "#2a2a40", 82 | "editorGroupHeader.tabsBackground": "#0a0a23", 83 | "editorIndentGuide.background": "#3b3b4f", 84 | "terminal.background": "#0a0a23", 85 | "terminal.foreground": "#ffffff", 86 | "terminal.ansiBrightGreen": "#ffffff", 87 | "panel.background": "#1b1b32", 88 | "panelTitle.inactiveForeground": "#858591", 89 | "panelTitle.activeBorder": "#f5f6f7" 90 | } 91 | }, 92 | "workbench.iconTheme": null, 93 | "workbench.statusBar.visible": false, 94 | "workbench.tips.enabled": false, 95 | "workbench.tree.renderIndentGuides": "none", 96 | "zenMode.centerLayout": false 97 | } -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## Contributing 2 | 3 | Please read the guidelines in the [contributing docs](https://contribute.freecodecamp.org/#/how-to-work-on-tutorials-that-use-coderoad) before contributing. Contributions to this project need to follow the correct workflow. 4 | 5 | # Change Log 6 | 7 | Whenever a new version is created, add the new branch name and the changes here 8 | 9 | ## [v1.0.0] 10 | 11 | - Initial release after splitting other SQL tutorial into two parts 12 | 13 | ## [v1.0.1] 14 | 15 | - Add creation of bash history in `reset.sh` 16 | - Add continue commands 17 | 18 | ## [v1.0.2] 19 | 20 | - Only disconnect user `freecodecamp` from db when resetting 21 | 22 | ## [v1.0.3] 23 | 24 | - Fix SQL query and expected result in exercise 2450 - 'Add echo query result' 25 | 26 | ## [v1.0.4] 27 | 28 | - Restructure commits to use new style. Instead of loading a new test file, and commenting out the old one on each commit, this loads all the tests in the `INIT` commit and uses mocha settings to only run tests in a specific file. The commits now just change the test file that should run. 29 | - There was an issue with the last commit not loading after using the reset button in a tutorial. I added a final commit at end that seems to have resolved it. 30 | - Add `exit` flag to mocha so tests can't hang 31 | - Fix wrong hints on steps 1390, 1570, and 1730 32 | - Clarify instructions on 2200, 2230, 2250, and 2270 33 | 34 | ## [v2.0.0] 35 | 36 | - Add Gitpod config 37 | -------------------------------------------------------------------------------- /TUTORIAL.md: -------------------------------------------------------------------------------- 1 | # Learn SQL by Building a Student Database: Part 2 2 | 3 | > Welcome to Part 2 of the Build a Student Database Lessons! 4 | 5 | ## 10. Start the Terminal 6 | 7 | ### 10.1 8 | 9 | **The first thing you need to do is start the terminal.** Do that by clicking the "hamburger" menu at the top left of the screen, going to the "terminal" section, and clicking "new terminal". Once you open a new one, type `echo hello SQL` into the terminal and press enter. 10 | 11 | #### HINTS 12 | 13 | - Capitalization matters 14 | - If the tests don't run automatically, try typing `exit` into the terminal and redoing the instructions 15 | 16 | ## 20. psql login 17 | 18 | ### 20.1 19 | 20 | In Part 1 of this tutorial, you created a `students` database and then a script to insert information about your computer science students into it. Log into the psql interactive terminal with `psql --username=freecodecamp --dbname=postgres` to see if it's here. 21 | 22 | #### HINTS 23 | 24 | - Type `psql --username=freecodecamp --dbname=postgres` into the terminal and press enter 25 | 26 | ## 30. \l 27 | 28 | ### 30.1 29 | 30 | List the databases. 31 | 32 | #### HINTS 33 | 34 | - Use the **l**ist shortcut command 35 | - It's the `\l` command 36 | - Type `\l` into the psql prompt and press enter 37 | - Enter `psql --username=freecodecamp --dbname=postgres` in the terminal to log into the psql prompt if you aren't already 38 | 39 | ## 40. rebuild database 40 | 41 | ### 40.1 42 | 43 | Your database isn't here. You can use the `.sql` file you created at the end of Part 1 to rebuild it. I recommend "splitting" the terminal. You can do that by clicking the "hamburger" menu at the top left of the window, going to the "Terminal" menu, and clicking "Split Terminal". Once you've done that, enter `psql -U postgres < students.sql` in it to rebuild the database. 44 | 45 | #### HINTS 46 | 47 | - Enter the suggested command in the terminal 48 | - Make sure you are in the `project` folder first 49 | 50 | ## 50. \l 51 | 52 | ### 50.1 53 | 54 | A lot of stuff happened in the terminal. That looks promising. In the psql prompt, view the databases again. 55 | 56 | #### HINTS 57 | 58 | - Use the **l**ist shortcut command 59 | - It's the `\l` command 60 | - Type `\l` into the psql prompt and press enter 61 | - Enter `psql --username=freecodecamp --dbname=postgres` in the terminal to log into the psql prompt if you aren't already 62 | 63 | ## 60. \c students 64 | 65 | ### 60.1 66 | 67 | There's your `students` database. Connect to it. 68 | 69 | #### HINTS 70 | 71 | - Use the **c**onnect shortcut command with the database name after it 72 | - It's the `\c` command 73 | - Here's an example `\c ` 74 | - Type `\c students` into the psql prompt and press enter 75 | - Enter `psql --username=freecodecamp --dbname=postgres` in the terminal to log into the psql prompt if you aren't already 76 | 77 | ## 70. \d 78 | 79 | ### 70.1 80 | 81 | Now that you're connected. Display the tables and relations that are here to see if it's all correct. 82 | 83 | #### HINTS 84 | 85 | - Use the **d**isplay shortcut command 86 | - It's the `\d` command 87 | - Type `\d` into the psql prompt and press enter 88 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 89 | 90 | ## 80. \d students 91 | 92 | ### 80.1 93 | 94 | That all looks right. View the details of the `students` table to make sure the stucture is right. 95 | 96 | #### HINTS 97 | 98 | - Use the **d**isplay shortcut command with the table name after it 99 | - It's the `\d` command 100 | - Here's an example: `\d ` 101 | - Type `\d students` into the psql prompt and press enter 102 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 103 | 104 | ## 90. select * from students 105 | 106 | ### 90.1 107 | 108 | Looks good. Make sure all the data is in the table, as well. 109 | 110 | #### HINTS 111 | 112 | - View all the data in the `students` table 113 | - Use the `SELECT` and `FROM` keywords with `*` to view all the columns 114 | - Here's an example: `SELECT FROM `; 115 | - Type `SELECT * FROM students;` into the psql prompt 116 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 117 | 118 | ## 1220. touch student_info.sh 119 | 120 | ### 1220.1 121 | 122 | The data is all there. You should take a look at the details of the other tables and the data in them to make sure they look good. When you are done, use `touch` in the bash terminal to create `student_info.sh`. You are going to make a script to print info about your students. 123 | 124 | #### HINTS 125 | 126 | - Here's an example: `touch ` 127 | - Enter `touch student_info.sh` in the terminal 128 | - The bash terminal, not the psql one 129 | - Make sure you are in the `project` folder first 130 | 131 | ## 1230. chmod +x student_info.sh 132 | 133 | ### 1230.1 134 | 135 | Give your new file executable permissions. 136 | 137 | #### HINTS 138 | 139 | - It's the `chmod` command with the `+x` flag 140 | - Here's an example: `chmod +x ` 141 | - Type `chmod +x student_info.sh` in the terminal and press enter 142 | 143 | ## 1240. Add shebang 144 | 145 | ### 1240.1 146 | 147 | Add a shebang that uses bash at the top of your new script. 148 | 149 | #### HINTS 150 | 151 | - The shebang you want is `#!/bin/bash` 152 | - Add `#!/bin/bash` to your `student_info.sh` file 153 | 154 | ## 1250. Add comment 155 | 156 | ### 1250.1 157 | 158 | Below the shebang, add a comment that says `Info about my computer science students from students database`. 159 | 160 | #### HINTS 161 | 162 | - Make sure it's a single line comment 163 | - A comment look like this: `# ` 164 | - Add `# Info about my computer science students from students database` below the "shebang" in your `student_info.sh` file 165 | 166 | ## 1260. Add echo title 167 | 168 | ### 1260.1 169 | 170 | In the new script, use `echo` to print `~~ My Computer Science Students ~~`. Use the `-e` flag with it to put a new line at the beginning and end of the text. 171 | 172 | #### HINTS 173 | 174 | - The new line character is `\n` 175 | - Here's an example: `echo -e "\n\n"` 176 | - Add `echo -e "\n~~ My Computer Science Students ~~\n"` below the comment in your `student_info.sh` file 177 | 178 | ## 1265. ./student_info.sh 179 | 180 | ### 1265.1 181 | 182 | Run the script to make sure it's working. 183 | 184 | #### HINTS 185 | 186 | - Run your `student_info.sh` script by executing it 187 | - Type `./student_info.sh` in the terminal and press enter 188 | - Make sure you are in the `project` folder first 189 | 190 | ## 1270. Add PSQL Variable 191 | 192 | ### 1270.1 193 | 194 | You will want to query the database again to get info about the students to display. Add the same `PSQL` variable you use in your `insert_data.sh` script. It looked like this: `PSQL="psql -X --username=freecodecamp --dbname=students --no-align --tuples-only -c"` 195 | 196 | #### HINTS 197 | 198 | - Add the suggested variable at the bottom of the `student_info.sh` file 199 | 200 | ## 1280. Add echo students with 4.0 201 | 202 | ### 1280.1 203 | 204 | Below the PSQL variable you just added, use `echo` to print `First name, last name, and GPA of students with a 4.0 GPA:`. Use the `-e` flag to put a new line at the beginning of the sentence. 205 | 206 | #### HINTS 207 | 208 | - The new line character is `\n` 209 | - Here's an example of the command: `echo -e "\n"` 210 | - At the bottom of the `student_info.sh` file, add this: 211 | ```sh 212 | echo -e "\nFirst name, last name, and GPA of students with a 4.0 GPA:" 213 | ``` 214 | 215 | ## 1290. psql SELECT * FROM students 216 | 217 | ### 1290.1 218 | 219 | You will want to print what that sentence is asking for. You should know how to make that query, but lets practice a little first. `SQL` stands for "Structured Query Language". It's the language you have been using to manage your relational databases. In the psql prompt, view all the data in the students table like you have done many times. 220 | 221 | #### HINTS 222 | 223 | - Use the `SELECT` and `FROM` keywords with `*` to view all the data 224 | - Enter `SELECT * FROM students;` in the psql prompt 225 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 226 | 227 | ## 1300. psql SELECT first_name 228 | 229 | ### 1300.1 230 | 231 | You should look at the column titles that were returned. The `*` gets all columns in a table with your query. You can return specific columns by putting the column name in the query instead of `*`. In the psql prompt, view just the `first_name` column from the `students` table. 232 | 233 | #### HINTS 234 | 235 | - Use the `SELECT` and `FROM` keywords 236 | - Here's an example: `SELECT FROM ;` 237 | - Enter `SELECT first_name FROM students;` in the psql prompt 238 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 239 | 240 | ## 1310. psql SELECT first_name, last_name, gpa 241 | 242 | ### 1310.1 243 | 244 | Just the `first_name` column was returned that time. You can specify as many columns you want returned by separating them with commas. View the `first_name`, `last_name` and `gpa` columns from the `students` table. 245 | 246 | #### HINTS 247 | 248 | - Use the `SELECT` and `FROM` keywords 249 | - Here's an example: `SELECT , , FROM ;` 250 | - Enter `SELECT first_name, last_name, gpa FROM students;` in the psql prompt 251 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 252 | - Don't filter any rows 253 | 254 | ## 1320. psql SELECT WHERE gpa < 2.5 255 | 256 | ### 1320.1 257 | 258 | You can return only rows you want by adding `WHERE ` to your query. A condition can consist of a column, an operator, and a value. Use one of these to view the same columns as before but only rows `WHERE gpa < 2.5`. 259 | 260 | #### HINTS 261 | 262 | - Here's an example: `SELECT FROM WHERE ;` 263 | - The previous command you used was `SELECT first_name, last_name, gpa FROM students;` 264 | - The condition you want is `WHERE gpa < 2.5` 265 | - Enter `SELECT first_name, last_name, gpa FROM students WHERE gpa < 2.5;` in the psql prompt 266 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 267 | 268 | ## 1330. psql SELECT WHERE gpa >= 3.8 269 | 270 | ### 1330.1 271 | 272 | The `<` only return rows where the `gpa` column was less than `2.5`. Some other operators are: `<`, `>`, `<=`, `>=`. View the same columns, but only rows for students with a `gpa` greater than or equal to `3.8`. 273 | 274 | #### HINTS 275 | 276 | - The greater than or equal to operator is `>=` 277 | - Here's an example: `SELECT FROM WHERE ;` 278 | - The previous command you used was `SELECT first_name, last_name, gpa FROM students WHERE gpa < 2.5;` 279 | - The condition you want here is `WHERE gpa >= 3.8` 280 | - Enter `SELECT first_name, last_name, gpa FROM students WHERE gpa >= 3.8;` in the psql prompt 281 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 282 | 283 | ## 1340. psql SELECT WHERE != 4.0 284 | 285 | ### 1340.1 286 | 287 | That only returned students with a GPA of 3.8 or better. There's equal (`=`) and not equal (`!=`) operators as well. View the same columns for students that don't have a 4.0 gpa. 288 | 289 | #### HINTS 290 | 291 | - Use the not equal (`!=`) operator 292 | - The previous command you used was `SELECT first_name, last_name, gpa FROM students WHERE gpa >= 3.8;` 293 | - The condition you want here is `WHERE gpa != 4.0` 294 | - Enter `SELECT first_name, last_name, gpa FROM students WHERE gpa != 4.0;` in the psql prompt 295 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 296 | 297 | ## 1360. Add echo query result 298 | 299 | ### 1360.1 300 | 301 | The right query will get you only the data you are looking for. Back in your `student_info.sh` file, add an `echo` command to the bottom that prints what the sentence above it asks for. Place double quotes around it like this: `echo "$($PSQL "")"`. This will make it so the output isn't all on one line. 302 | 303 | #### HINTS 304 | 305 | - Add `echo "$($PSQL "")"` to the bottom of the `student_info.sh` file, except with the correct query in it 306 | - You previously used, `SELECT first_name, last_name, gpa FROM students WHERE gpa != 4.0;` in the psql prompt 307 | - The condition you want here is `WHERE gpa = 4.0` 308 | - Practice the query in the psql prompt to make sure it's getting what you want 309 | - If you run your script, the last echo statement should print: 310 | ```sh 311 | Casares|Hijo|4.0 312 | Vanya|Hassanah|4.0 313 | Dejon|Howell|4.0 314 | ``` 315 | - Add `echo "$($PSQL "SELECT first_name, last_name, gpa FROM students WHERE gpa = 4.0")"` to the bottom of the `student_info.sh` file 316 | 317 | ## 1370. ./student_info.sh 318 | 319 | ### 1370.1 320 | 321 | Run the script to see your students with the highest GPA's. 322 | 323 | #### HINTS 324 | 325 | - Run your `student_info.sh` script by executing it 326 | - Type `./student_info.sh` in the terminal and press enter 327 | - Make sure you are in the `project` folder first 328 | 329 | ## 1380. Add echo courses before D 330 | 331 | ### 1380.1 332 | 333 | Add another `echo` statement at the bottom of the script. Make it print `All course names whose first letter is before 'D' in the alphabet:`. Put a new line in front of it like the first sentence. 334 | 335 | #### HINTS 336 | 337 | - Use `echo` with the `-e` flag and a new line character 338 | - The new line character is `\n` 339 | - Here's an example of the command: `echo -e "\n"` 340 | - At the bottom of the `student_info.sh` file, add this: 341 | ```sh 342 | echo -e "\nAll course names whose first letter is before 'D' in the alphabet:" 343 | ``` 344 | 345 | ## 1390. psql SELECT * FROM majors 346 | 347 | ### 1390.1 348 | 349 | Practice first. In the psql prompt, view all the data in the `majors` table. 350 | 351 | #### HINTS 352 | 353 | - Use the `SELECT` and `FROM` keywords with `*` to view all the data 354 | - Enter `SELECT * FROM majors;` in the psql prompt 355 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 356 | 357 | ## 1400. psql SELECT WHERE major = Game Design 358 | 359 | ### 1400.1 360 | 361 | The operators you used with numbers in the last section can be used on text as well. Use the `=` to view all majors named `Game Design`. Don't forget that You need single quotes around text values. 362 | 363 | #### HINTS 364 | 365 | - Use the `SELECT`, `FROM`, and `WHERE` keywords with `*` to view the suggested rows 366 | - Here's an example: `SELECT FROM WHERE ;` 367 | - The condition you want is `major = 'Game Design'` 368 | - Enter `SELECT * FROM majors WHERE major = 'Game Design';` in the psql prompt 369 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 370 | 371 | ## 1410. psql SELECT WHERE major != Game Design 372 | 373 | ### 1410.1 374 | 375 | Next, view all the rows not equal to `Game Design`. 376 | 377 | #### HINTS 378 | 379 | - The not equal operator is `!=` 380 | - Use the `SELECT`, `FROM`, and `WHERE` keywords with `*` to view the suggested rows 381 | - Here's an example: `SELECT FROM
WHERE ;` 382 | - The condition you want is `major != 'Game Design'` 383 | - Enter `SELECT * FROM majors WHERE major != 'Game Design';` in the psql prompt 384 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 385 | 386 | ## 1420. psql SELECT WHERE major > Game Design 387 | 388 | ### 1420.1 389 | 390 | Use the greater than operator to see majors that come after it alphabetically. 391 | 392 | #### HINTS 393 | 394 | - The greater than operator is `>` 395 | - You want to see what rows are `> 'Game Design'` 396 | - Use the `SELECT`, `FROM`, and `WHERE` keywords with `*` to view the suggested rows 397 | - Here's an example: `SELECT FROM
WHERE ;` 398 | - The condition you want is `major > 'Game Design'` 399 | - Enter `SELECT * FROM majors WHERE major > 'Game Design';` in the psql prompt 400 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 401 | 402 | ## 1430. psql SELECT WHERE major >= Game Design 403 | 404 | ### 1430.1 405 | 406 | `Game Design` was not included in the results because it is not `> 'Game Design'`. Try it with the greater than or equal to operator. 407 | 408 | #### HINTS 409 | 410 | - The greater than or equal to operator is `>=` 411 | - You want to see what rows are `>= 'Game Design'` 412 | - Use the `SELECT`, `FROM`, and `WHERE` keywords with `*` to view the suggested rows 413 | - Here's an example: `SELECT FROM
WHERE ;` 414 | - The condition you want is `major >= 'Game Design'` 415 | - Enter `SELECT * FROM majors WHERE major >= 'Game Design';` in the psql prompt 416 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 417 | 418 | ## 1440. psql SELECT WHERE major < G 419 | 420 | ### 1440.1 421 | 422 | It included `Game Design` in the results that time. So if you want to see results that start with a `G` or after, you could use `major >= 'G'`. View the majors that come before `G`. 423 | 424 | #### HINTS 425 | 426 | - Use the less than (`<`) operator to see rows that come before `G` 427 | - Use the `SELECT`, `FROM`, and `WHERE` keywords with `*` to view the suggested rows 428 | - Here's an example: `SELECT FROM
WHERE ;` 429 | - The condition you want is `major < 'G'` 430 | - Enter `SELECT * FROM majors WHERE major < 'G';` in the psql prompt 431 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 432 | 433 | ## 1450. Add echo query result 434 | 435 | ### 1450.1 436 | 437 | In your script, add an `echo` at the bottom to print all the course names whose first letter is before `D` in the alphabet, as suggested by the previous line in the file. Use a similar pattern that you used earlier to get and print data from the database. Make sure to use double quotes where needed. 438 | 439 | #### HINTS 440 | 441 | - Add `echo "$($PSQL "")"` to the bottom of the `student_info.sh` file, except with the correct query in it 442 | - You previously used, `SELECT * FROM majors WHERE major < 'G';` in the psql prompt 443 | - The condition you want here is `WHERE course < 'D'` 444 | - You only want to get the `course` column from the `courses` table 445 | - Practice the query in the psql prompt to make sure it's getting what you want 446 | - If you run your script, the last echo statement should print: 447 | ```sh 448 | Computer Networks 449 | Computer Systems 450 | Artificial Intelligence 451 | Calculus 452 | Algorithms 453 | ``` 454 | - Add `echo "$($PSQL "SELECT course FROM courses WHERE course < 'D'")"` to the bottom of the `student_info.sh` file 455 | 456 | ## 1460. ./student_info.sh 457 | 458 | ### 1460.1 459 | 460 | Run the script to see what course names come before the letter `D`. 461 | 462 | #### HINTS 463 | 464 | - Run your `student_info.sh` script by executing it 465 | - Type `./student_info.sh` in the terminal and press enter 466 | - Make sure you are in the `project` folder first 467 | 468 | ## 1470. Add echo students after R with gpa above 3.8 or below 2.0 469 | 470 | ### 1470.1 471 | 472 | Looks like there is five of them. Add another sentence like the others that says: `First name, last name, and GPA of students whose last name begins with an 'R' or after and have a GPA greater than 3.8 or less than 2.0:` 473 | 474 | #### HINTS 475 | 476 | - At the bottom of the file, use `echo` with the `-e` flag and a new line character again to print the suggested sentence 477 | - The new line character is `\n` 478 | - Here's an example of the command: `echo -e "\n"` 479 | - At the bottom of the `student_info.sh` file, add this: 480 | ```sh 481 | echo -e "\nFirst name, last name, and GPA of students whose last name begins with an 'R' or after and have a GPA greater than 3.8 or less than 2.0:" 482 | ``` 483 | 484 | ## 1480. psql SELECT * FROM students 485 | 486 | ### 1480.1 487 | 488 | To find that, start by using the psql prompt to view all the data in the `students` table. 489 | 490 | #### HINTS 491 | 492 | - Use the `SELECT` and `FROM` keywords with `*` to view all the data 493 | - Enter `SELECT * FROM students;` in the psql prompt 494 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 495 | 496 | ## 1490. psql SELECT WHERE last_name < M 497 | 498 | ### 1490.1 499 | 500 | It returned 31 rows. Use the same command, but only return the rows for students whose last name comes before `M` in the alphabet. 501 | 502 | #### HINTS 503 | 504 | - Use the less than (`<`) operator to see rows that come before `M` 505 | - Use the `SELECT`, `FROM`, and `WHERE` keywords with `*` to view the suggested rows 506 | - Here's an example: `SELECT FROM
WHERE ;` 507 | - The condition you want is `last_name < 'M'` 508 | - Enter `SELECT * FROM students WHERE last_name < 'M';` in the psql prompt 509 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 510 | 511 | ## 1500. SELECT WHERE last_name < M OR gpa = 3.9 512 | 513 | ### 1500.1 514 | 515 | That returned 18 rows. You can use multiple conditions after `WHERE` with `AND` or `OR`, among others. Just add the keyword and another condition. In the psql prompt, use the same command as before, but add an `OR` to also return rows of students with a 3.9 GPA. 516 | 517 | #### HINTS 518 | 519 | - The previous command was: `SELECT * FROM students WHERE last_name < 'M';` 520 | - Here's an example of the `WHERE` part: `WHERE OR ` 521 | - Add an `OR ` to the previous command 522 | - The condition you want to add is `OR gpa = 3.9` 523 | - The whole condition is `WHERE last_name < 'M' OR gpa = 3.9` 524 | - Enter `SELECT * FROM students WHERE last_name < 'M' OR gpa = 3.9;` in the psql prompt 525 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 526 | 527 | ## 1510. psql SELECT WHERE last_name < M AND gpa = 3.9 528 | 529 | ### 1510.1 530 | 531 | It showed rows where one of the conditions was true, there was one more than last time. Enter the previous command, but use `AND` to view only students that meet both conditions. 532 | 533 | #### HINTS 534 | 535 | - The previous command was: `SELECT * FROM students WHERE last_name < 'M' OR gpa = 3.9;` 536 | - Here's an example of the `WHERE` part: `WHERE AND ` 537 | - Enter `SELECT * FROM students WHERE last_name < 'M' AND gpa = 3.9;` in the psql prompt 538 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 539 | 540 | ## 1520. psql SELECT WHERE last_name < M AND gpa = 3.9 OR gpa < 2.3 541 | 542 | ### 1520.1 543 | 544 | Now it only shows rows where both conditions are true, one person. Enter the previous command, but add a third condition of `OR gpa < 2.3`. 545 | 546 | #### HINTS 547 | 548 | - The previous command was: `SELECT * FROM students WHERE last_name < 'M' OR gpa = 3.9;` 549 | - Here's an example of the `WHERE` part: `WHERE AND OR ` 550 | - The conditions look like this: `WHERE last_name < 'M' AND gpa = 3.9 OR gpa < 2.3;` 551 | - Enter `SELECT * FROM students WHERE last_name < 'M' AND gpa = 3.9 OR gpa < 2.3;` in the psql prompt 552 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 553 | 554 | ## 1530. psql SELECT WHERE last_name < M AND (gpa = 3.9 OR gpa < 2.3) 555 | 556 | ### 1530.1 557 | 558 | This showed all students whose GPA is less than 2.3 because the final `OR` condition was true for them. It didn't matter what their last name started with. You can group conditions together with parenthesis like this: `WHERE AND ( OR )`. This would only return rows where `` is true and one of the others is true. View students whose last name is before `M` that have a GPA of 3.9 or less than 2.3. 559 | 560 | #### HINTS 561 | 562 | - The previous command was: `SELECT * FROM students WHERE last_name < 'M' OR gpa = 3.9 OR gpa < 2.3;` 563 | - Enter the previous command but group your conditions with parenthesis to only view the suggested rows 564 | - Enter `SELECT * FROM students WHERE last_name < 'M' AND (gpa = 3.9 OR gpa < 2.3);` in the psql prompt 565 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 566 | 567 | ## 1540. Add echo query result 568 | 569 | ### 1540.1 570 | 571 | Two students meet those conditions. Back in the student info file, add an echo command at the bottom to print the suggested rows. 572 | 573 | #### HINTS 574 | 575 | - Add `echo "$($PSQL "")"` to the bottom of the `student_info.sh` file, except with the correct query in it 576 | - You previously used `SELECT * FROM students WHERE last_name < 'M' AND (gpa = 3.9 OR gpa < 2.3);` in the psql prompt 577 | - Practice the query in the psql prompt to make sure it's getting what you want 578 | - The conditions should be `last_name >= 'R' AND (gpa > 3.8 OR gpa < 2.0)` 579 | - If you run your script, the last echo statement should print: 580 | ```sh 581 | Efren|Reilly|3.9 582 | Mariana|Russel|1.8 583 | Mehdi|Vandenberghe|1.9 584 | ``` 585 | - Add `echo "$($PSQL "SELECT first_name, last_name, gpa FROM students WHERE last_name >= 'R' AND (gpa > 3.8 OR gpa < 2.0)")"` to the bottom of the `student_info.sh` file 586 | 587 | ## 1550. ./student_info 588 | 589 | ### 1550.1 590 | 591 | Run the script to see the results. 592 | 593 | #### HINTS 594 | 595 | - Run your `student_info.sh` script by executing it 596 | - Type `./student_info.sh` in the terminal and press enter 597 | - Make sure you are in the `project` folder first 598 | 599 | ## 1560. Add echo students containing sa or r as second to last letter 600 | 601 | ### 1560.1 602 | 603 | Moving along. Add another `echo` command, like the others, with a sentence that says: `Last name of students whose last name contains a case insensitive 'sa' or have an 'r' as the second to last letter:` 604 | 605 | #### HINTS 606 | 607 | - At the bottom of the file, use `echo` with the `-e` flag and a new line character again to print the suggested sentence 608 | - The new line character is `\n` 609 | - Here's an example of the command: `echo -e "\n"` 610 | - At the bottom of the `student_info.sh` file, add this: 611 | ```sh 612 | echo -e "\nLast name of students whose last name contains a case insensitive 'sa' or have an 'r' as the second to last letter:" 613 | ``` 614 | 615 | ## 1570. psql SELECT * FROM courses 616 | 617 | ### 1570.1 618 | 619 | Start by viewing everything from the `courses` table in the psql prompt to see how you might be able to find this out. 620 | 621 | #### HINTS 622 | 623 | - Use the `SELECT` and `FROM` keywords with `*` to view all the data 624 | - Enter `SELECT * FROM courses;` in the psql prompt 625 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 626 | 627 | ## 1580. psql SELECT WHERE course LIKE _lgorithms 628 | 629 | ### 1580.1 630 | 631 | There's a few that contain the word `Algorithms`. You can use `LIKE` to find patterns in text like this: `WHERE LIKE ''`. An underscore (`_`) in a pattern will return rows that have any character in that spot. View the rows in this table with a course name that matches the pattern `'_lgorithms'`. 632 | 633 | #### HINTS 634 | 635 | - Here's an example: `SELECT * FROM courses WHERE course LIKE '';` 636 | - Enter `SELECT * FROM courses WHERE course LIKE '_lgorithms';` in the psql prompt 637 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 638 | 639 | ## 1590. psql SELECT WHERE course LIKE %lgorithms 640 | 641 | ### 1590.1 642 | 643 | That pattern matched only rows that had exactly one character, followed by `lgorithms`. Another pattern character is `%`. It means anything can be there. To find names that start with `W`, you could use `W%`. View the courses that end in `lgorithms`. 644 | 645 | #### HINTS 646 | 647 | - Use `LIKE` and a pattern with `%` to view the courses ending in `lgorithms` 648 | - Here's an example: `SELECT * FROM courses WHERE course LIKE '';` 649 | - The pattern you want is `%lgorithms` 650 | - Enter `SELECT * FROM courses WHERE course LIKE '%lgorithms';` in the psql prompt 651 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 652 | 653 | ## 1600. psql SELECT WHERE course LIKE Web% 654 | 655 | ### 1600.1 656 | 657 | It found two that time. Try viewing courses that start with `Web`. 658 | 659 | #### HINTS 660 | 661 | - Use `LIKE` and a pattern with `%` to view the courses starting with `Web` 662 | - Here's an example: `SELECT * FROM courses WHERE course LIKE '';` 663 | - The pattern you want is `Web%` 664 | - Enter `SELECT * FROM courses WHERE course LIKE 'Web%';` in the psql prompt 665 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 666 | 667 | ## 1610. psql SELECT WHERE course LIKE _e% 668 | 669 | ### 1610.1 670 | 671 | Combine the two pattern matching characters to show courses that have a second letter of `e`. 672 | 673 | #### HINTS 674 | 675 | - Use `LIKE` and a pattern with `_` and `%` to view the courses whose second letter is `e` 676 | - Here's an example: `SELECT * FROM courses WHERE course LIKE '';` 677 | - Remember that the `_` will match any single character and `%` will match any number of characters 678 | - The pattern you want is `_e%` 679 | - Enter `SELECT * FROM courses WHERE course LIKE '_e%';` in the psql prompt 680 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 681 | 682 | ## 1620. psql SELECT WHERE course LIKE % % 683 | 684 | ### 1620.1 685 | 686 | Nice job! Try viewing the courses with a space in their names. 687 | 688 | #### HINTS 689 | 690 | - Use `LIKE` and a pattern with two `%` to view the courses with a space 691 | - Here's an example: `SELECT * FROM courses WHERE course LIKE '';` 692 | - The pattern you want is `% %` 693 | - Enter `SELECT * FROM courses WHERE course LIKE '% %';` in the psql prompt 694 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 695 | 696 | ## 1630. psql SELECT WHERE course NOT LIKE % % 697 | 698 | ### 1630.1 699 | 700 | There they are. You can use `NOT LIKE` to find things that don't match a pattern. View courses that don't contain a space. 701 | 702 | #### HINTS 703 | 704 | - Use `NOT LIKE` and a pattern with two `%`'s to view the courses without a space 705 | - Here's an example: `SELECT * FROM courses WHERE course NOT LIKE '';` 706 | - The pattern you want is `% %` 707 | - Enter `SELECT * FROM courses WHERE course NOT LIKE '% %';` in the psql prompt 708 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 709 | 710 | ## 1640. psql SELECT WHERE course LIKE %A% 711 | 712 | ### 1640.1 713 | 714 | Five courses without a space. Try finding the ones that contain an `A`. 715 | 716 | #### HINTS 717 | 718 | - Use `LIKE` and a pattern with two `%`'s to view the courses containing `A` 719 | - Here's an example: `SELECT * FROM courses WHERE course LIKE '';` 720 | - The pattern you want is `%A%` 721 | - Enter `SELECT * FROM courses WHERE course LIKE '%A%';` in the psql prompt 722 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 723 | 724 | ## 1650. psql SELECT WHERE course ILIKE %A% 725 | 726 | ### 1650.1 727 | 728 | 6 rows. This showed all the courses with a capital `A`. `ILIKE` will ignore the case of the letters when matching. Use it to see the courses with an `A` or `a`. 729 | 730 | #### HINTS 731 | 732 | - Use `ILIKE` and a pattern with two `%`'s to view the courses containing `A` in any case 733 | - Here's an example: `SELECT * FROM courses WHERE course ILIKE '';` 734 | - The pattern you want is `%A%` 735 | - Enter `SELECT * FROM courses WHERE course ILIKE '%A%';` in the psql prompt 736 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 737 | 738 | ## 1670. psql SELECT WHERE course NOT ILIKE %a% 739 | 740 | ### 1670.1 741 | 742 | It found 11 rows that time. You can put `NOT` in front of `ILIKE` as well. Use it to see the courses that don't contain an `A` or `a`. 743 | 744 | #### HINTS 745 | 746 | - Use `NOT ILIKE` and a pattern with two `%`'s to view the courses not containing `A` in any case 747 | - Here's an example: `SELECT * FROM courses WHERE course NOT ILIKE '';` 748 | - The pattern you want is `%A%` 749 | - Enter `SELECT * FROM courses WHERE course NOT ILIKE '%A%';` in the psql prompt 750 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 751 | 752 | ## 1680. psql SELECT WHERE course NOT ILIKE %A% AND LIKE % % 753 | 754 | ### 1680.1 755 | 756 | You combine these like any other conditions. View the courses that don't have a capital or lowercase `A` and have a space. 757 | 758 | #### HINTS 759 | 760 | - Use two conditions, one with `NOT ILIKE` and one with `LIKE` 761 | - Here's an example: `SELECT * FROM courses WHERE course NOT ILIKE '' AND course LIKE ;` 762 | - The two patterns you want are `%A%` and `% %` 763 | - Enter `SELECT * FROM courses WHERE course NOT ILIKE '%A%' AND course LIKE '% %';` in the psql prompt 764 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 765 | 766 | ## 1690. Add echo query result 767 | 768 | ### 1690.1 769 | 770 | In your student info script, add an `echo` statement at the bottom like the other to print the results of the suggested query. 771 | 772 | #### HINTS 773 | 774 | - Add `echo "$($PSQL "")"` to the bottom of the `student_info.sh` file, except with the correct query in it 775 | - You previously used `SELECT * FROM courses WHERE course NOT ILIKE '%A%' AND course LIKE '% %';` in the psql prompt 776 | - Practice the query in the psql prompt to make sure it's getting what you want 777 | - The conditions should be `last_name ILIKE '%sa%' OR last_name LIKE %r_` 778 | - If you run your script, the last echo statement should print: 779 | ```sh 780 | Gilbert 781 | Savage 782 | Saunders 783 | Hilpert 784 | Hassanah 785 | ``` 786 | - Add `echo "$($PSQL "SELECT last_name FROM students WHERE last_name ILIKE '%sa%' OR last_name LIKE '%r_'")"` to the bottom of the `student_info.sh` file 787 | 788 | ## 1700. ./student_info.sh 789 | 790 | ### 1700.1 791 | 792 | Run the script to see the results. 793 | 794 | #### HINTS 795 | 796 | - Run your `student_info.sh` script by executing it 797 | - Type `./student_info.sh` in the terminal and press enter 798 | - Make sure you are in the `project` folder first 799 | 800 | ## 1710. Add echo students without major begin with D or gpa > 3.0 801 | 802 | ### 1710.1 803 | 804 | Looks like five students meet those conditions. Add another `echo` command at the bottom, like the others. Make this one say: `First name, last name, and GPA of students who have not selected a major and either their first name begins with 'D' or they have a GPA greater than 3.0:` 805 | 806 | #### HINTS 807 | 808 | - At the bottom of the file, use `echo` with the `-e` flag and a new line character again to print the suggested sentence 809 | - The new line character is `\n` 810 | - Here's an example of the command: `echo -e "\n"` 811 | - At the bottom of the `student_info.sh` file, add this: 812 | ```sh 813 | echo -e "\nFirst name, last name, and GPA of students who have not selected a major and either their first name begins with 'D' or they have a GPA greater than 3.0:" 814 | ``` 815 | 816 | ## 1715. psql SELECT * FROM students 817 | 818 | ### 1715.1 819 | 820 | Start by looking at all the data in the students table. 821 | 822 | #### HINTS 823 | 824 | - Use the `SELECT` and `FROM` keywords with `*` to view all the data 825 | - Enter `SELECT * FROM students;` in the psql prompt 826 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 827 | 828 | ## 1720. psql SELECT * FROM students WHERE gpa IS NULL 829 | 830 | ### 1720.1 831 | 832 | All the fields that are empty or blank are `null`. You can access them using `IS NULL` as a condition like this: `WHERE IS NULL`. View the students who don't have a GPA. 833 | 834 | #### HINTS 835 | 836 | - Use the `SELECT`, `FROM`, `WHERE`, and `IS NULL` keywords with `*` to view the suggested rows 837 | - Here's an example: `SELECT FROM
WHERE ;` 838 | - The condition you want is `gpa IS NULL` 839 | - Enter `SELECT * FROM students WHERE gpa IS NULL;` in the psql prompt 840 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 841 | 842 | ## 1730. psql SELECT WHERE gpa IS NOT NULL 843 | 844 | ### 1730.1 845 | 846 | Inversely, you can use `IS NOT NULL` to see rows that aren't null. View all the info on students that do have a GPA. 847 | 848 | #### HINTS 849 | 850 | - Use the `SELECT`, `FROM`, `WHERE`, and `IS NOT NULL` keywords with `*` to view the suggested rows 851 | - Here's an example: `SELECT FROM
WHERE ;` 852 | - The condition you want is `gpa IS NOT NULL` 853 | - Enter `SELECT * FROM students WHERE gpa IS NOT NULL;` in the psql prompt 854 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 855 | 856 | ## 1740. psql SELECT WHERE major IS NULL 857 | 858 | ### 1740.1 859 | 860 | View all the info on students who haven't chosen a major. 861 | 862 | #### HINTS 863 | 864 | - A null `major_id` field means that student hasn't chosen a major 865 | - Use the `SELECT`, `FROM`, `WHERE`, and `IS NULL` keywords with `*` to view the suggested rows 866 | - Here's an example: `SELECT FROM
WHERE ;` 867 | - The condition you want is `major_id IS NULL` 868 | - Enter `SELECT * FROM students WHERE major_id IS NULL;` in the psql prompt 869 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 870 | 871 | ## 1750. psql SELECT WHERE major IS NULL and gpa IS NOT NULL 872 | 873 | ### 1750.1 874 | 875 | View the students who don't have a major, but don't include students without a GPA. 876 | 877 | #### HINTS 878 | 879 | - Use the `SELECT`, `FROM`, `WHERE`, `IS NULL`, `AND` and `IS NOT NULL` keywords with `*` to view the suggested rows 880 | - Here's an example: `SELECT FROM
WHERE AND ;` 881 | - The condition you want is `major_id IS NULL AND gpa IS NOT NULL` 882 | - Enter `SELECT * FROM students WHERE major_id IS NULL AND gpa IS NOT NULL;` in the psql prompt 883 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 884 | 885 | ## 1760. psql SELECT WHERE major_id IS NULL AND gpa IS NULL 886 | 887 | ### 1760.1 888 | 889 | One more. View the students who don't have a major and gpa. 890 | 891 | #### HINTS 892 | 893 | - Use the `SELECT`, `FROM`, `WHERE`, `IS NULL`, and `AND` keywords with `*` to view the suggested rows 894 | - Here's an example: `SELECT FROM
WHERE AND ;` 895 | - The condition you want is `major_id IS NULL AND gpa IS NULL` 896 | - Enter `SELECT * FROM students WHERE major_id IS NULL AND gpa IS NULL;` in the psql prompt 897 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 898 | 899 | ## 1770. Add echo query result 900 | 901 | ### 1770.1 902 | 903 | In your script, add an `echo` command at the bottom to print the results the sentence is looking for. 904 | 905 | #### HINTS 906 | 907 | - Add `echo "$($PSQL "")"` to the bottom of the `student_info.sh` file, except with the correct query in it 908 | - Practice the query in the psql prompt to make sure it's getting what you want 909 | - You will need to use the `SELECT`, `FROM`, `WHERE`, `IS NULL`, `AND`, `LIKE`, and `OR` keywords 910 | - If you run your script, the last echo statement should print: 911 | ```sh 912 | Noe|Savage|3.6 913 | Danh|Nhung|2.4 914 | Hugo|Duran|3.8 915 | ``` 916 | - You previously used `SELECT * FROM students WHERE last_name < 'M' AND (gpa = 3.9 OR gpa < 2.3);` in the psql prompt 917 | - Here's an example of the conditions you want: `WHERE AND ( OR )` 918 | - The conditions should look like this: `WHERE major_id IS NULL AND (first_name LIKE 'D%' OR gpa > 3.0)` 919 | - Add `echo "$($PSQL "SELECT first_name, last_name, gpa FROM students WHERE major_id IS NULL AND (first_name LIKE 'D%' OR gpa > 3.0)")"` to the bottom of the `student_info.sh` file 920 | 921 | ## 1780. ./student_info.sh 922 | 923 | ### 1780.1 924 | 925 | Run the script to see the students that meet those conditions. 926 | 927 | #### HINTS 928 | 929 | - Run your `student_info.sh` script by executing it 930 | - Type `./student_info.sh` in the terminal and press enter 931 | - Make sure you are in the `project` folder first 932 | 933 | ## 1790. Add echo first five courses 934 | 935 | ### 1790.1 936 | 937 | There's three of them. Add another sentence, like the others that says `Course name of the first five courses, in reverse alphabetical order, that have an 'e' as the second letter or end with an 's':` 938 | 939 | #### HINTS 940 | 941 | - At the bottom of the file, use `echo` with the `-e` flag and a new line character again to print the suggested sentence 942 | - The new line character is `\n` 943 | - Here's an example of the command: `echo -e "\n"` 944 | - At the bottom of the `student_info.sh` file, add this: 945 | ```sh 946 | echo -e "\nCourse name of the first five courses, in reverse alphabetical order, that have an 'e' as the second letter or end with an 's':" 947 | ``` 948 | 949 | ## 1800. psql SELECT students ORDER BY gpa 950 | 951 | ### 1800.1 952 | 953 | You can specify the order you want your results to be in by adding `ORDER BY ` at the end of a query. In the psql prompt, view all the info in the `students` table in order by the GPA's. 954 | 955 | #### HINTS 956 | 957 | - Use the `SELECT`, `FROM`, `WHERE`, and `ORDER BY` keywords with `*` to view the suggested rows 958 | - Here's an example: `SELECT FROM
ORDER BY ;` 959 | - You want to use `ORDER BY gpa` at the end of the query 960 | - Enter `SELECT * FROM students ORDER BY gpa;` in the psql prompt 961 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 962 | 963 | ## 1810. psql SELECT students ORDER BY gpa DESC 964 | 965 | ### 1810.1 966 | 967 | That put the lowest GPA's at the top. When using `ORDER BY`, it will be in ascending (`ASC`) order by default. Add `DESC` (descending) at the end of the last query to put the highest ones at the top. 968 | 969 | #### HINTS 970 | 971 | - The last command was `SELECT * FROM students ORDER BY gpa;` 972 | - Add `DESC` to the end of the last command 973 | - Enter `SELECT * FROM students ORDER BY gpa DESC;` in the psql prompt 974 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 975 | 976 | ## 1820. psql SELECT students ORDER BY gpa DESC, first_name 977 | 978 | ### 1820.1 979 | 980 | Now, the highest GPA's are at the top. You can add more columns to the order by separating them with a comma like this: `ORDER BY , `. Any matching values in the first ordered column will then be ordered by the next. View all the student info with the highest GPA's at the top, and in alphabetical order by `first_name` if the GPA's match. 981 | 982 | #### HINTS 983 | 984 | - Here's an example: `SELECT FROM
ORDER BY DESC, ;` 985 | - You want to use `ORDER BY gpa DESC, first_name` for the order 986 | - Enter `SELECT * FROM students ORDER BY gpa DESC, first_name;` in the psql prompt 987 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 988 | 989 | ## 1830. psql SELECT students ORDER BY gpa DESC, first_name LIMIT 10 990 | 991 | ### 1830.1 992 | 993 | Many times, you only want to return a certain number of rows. You can add `LIMIT ` at the end of the query to only get the amount you want. View the students in the same order as the last command, but only return the first 10 rows. 994 | 995 | #### HINTS 996 | 997 | - The last command was `SELECT * FROM students ORDER BY gpa DESC, first_name;` 998 | - Add `LIMIT 10` to the end of the last command 999 | - Enter `SELECT * FROM students ORDER BY gpa DESC, first_name LIMIT 10;` in the psql prompt 1000 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 1001 | 1002 | ## 1835. psql SELECT students WHERE gpa IS NOT NULL ORDER BY gpa DESC, first_name LIMIT 10 1003 | 1004 | ### 1835.1 1005 | 1006 | The order of the keywords in your query matters. You cannot put `LIMIT` before `ORDER BY`, or either of them before `WHERE`. View the same number of students, in the same order, but don't get the ones who don't have a GPA. 1007 | 1008 | #### HINTS 1009 | 1010 | - The last command was `SELECT * FROM students ORDER BY gpa DESC, first_name LIMIT 10;` 1011 | - The keywords you want are `SELECT`, `FROM`, `WHERE`, `IS NOT NULL`, `ORDER BY`, and `LIMIT`, in that order 1012 | - Here's an example: `SELECT FROM
WHERE ORDER BY LIMIT ;` 1013 | - The condition you want is `gpa IS NOT NULL` 1014 | - Enter `SELECT * FROM students WHERE gpa IS NOT NULL ORDER BY gpa DESC, first_name LIMIT 10;` in the psql prompt 1015 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 1016 | 1017 | ## 1840. Add echo query result 1018 | 1019 | ### 1840.1 1020 | 1021 | In your script, add the `echo` command to print the rows the sentence is asking for. 1022 | 1023 | #### HINTS 1024 | 1025 | - Add `echo "$($PSQL "")"` to the bottom of the `student_info.sh` file, except with the correct query in it 1026 | - If you run your script, the last echo statement should print: 1027 | ```sh 1028 | Web Programming 1029 | Web Applications 1030 | Server Administration 1031 | Network Security 1032 | Database Systems 1033 | ``` 1034 | - Practice the query in the psql prompt to make sure it's getting what you want 1035 | - You will need the `SELECT`, `FROM`, `WHERE`, `LIKE`, `OR`, `ORDER BY`, `DESC`, and `LIMIT` keywords 1036 | - Add `echo "$($PSQL "SELECT course FROM courses WHERE course LIKE '_e%' OR course LIKE '%s' ORDER BY course DESC LIMIT 5")"` to the bottom of the `student_info.sh` file 1037 | 1038 | ## 1850. ./student_info.sh 1039 | 1040 | ### 1850.1 1041 | 1042 | Run the script to see the courses. 1043 | 1044 | #### HINTS 1045 | 1046 | - Run your `student_info.sh` script by executing it 1047 | - Type `./student_info.sh` in the terminal and press enter 1048 | - Make sure you are in the `project` folder first 1049 | 1050 | ## 1860. Add echo average GPA to two decimal places 1051 | 1052 | ### 1860.1 1053 | 1054 | :sunglasses: Add another `echo` command at the bottom of the script like the others. Make this one say, `Average GPA of all students rounded to two decimal places:` 1055 | 1056 | #### HINTS 1057 | 1058 | - At the bottom of the file, use `echo` with the `-e` flag and a new line character again to print the suggested sentence 1059 | - The new line character is `\n` 1060 | - Here's an example of the command: `echo -e "\n"` 1061 | - At the bottom of the `student_info.sh` file, add this: 1062 | ```sh 1063 | echo -e "\nAverage GPA of all students rounded to two decimal places:" 1064 | ``` 1065 | 1066 | ## 1870. psql SELECT MIN(gpa) 1067 | 1068 | ### 1870.1 1069 | 1070 | There's a number of mathematic functions to use with numerical columns. One of them is `MIN`, you can use it when selecting a column like this: `SELECT MIN() FROM
`. It will find the lowest value in the column. In the psql prompt, view the lowest value in the `gpa` column of the `students` table. 1071 | 1072 | #### HINTS 1073 | 1074 | - Enter `SELECT MIN(gpa) FROM students;` in the psql prompt 1075 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 1076 | 1077 | ## 1880. psql SELECT MAX(gpa) 1078 | 1079 | ### 1880.1 1080 | 1081 | Another one is `MAX`, use it to see the largest `gpa` of the same table. 1082 | 1083 | #### HINTS 1084 | 1085 | - You previously used `SELECT MIN(gpa) FROM students;` 1086 | - Enter `SELECT MAX(gpa) FROM students;` in the psql prompt 1087 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 1088 | 1089 | ## 1890. psql SELECT SUM major_id 1090 | 1091 | ### 1890.1 1092 | 1093 | In the same fashion, use a `SUM` function find out what all the values of the `major_id` column in the `students` table add up to. 1094 | 1095 | #### HINTS 1096 | 1097 | - Use `SUM` like you used `MIN` and `MAX` 1098 | - You previously used `SELECT MAX(gpa) FROM students;` 1099 | - Enter `SELECT SUM(major_id) FROM students;` in the psql prompt 1100 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 1101 | 1102 | ## 1900. psql SELECT AVG(major_id) 1103 | 1104 | ### 1900.1 1105 | 1106 | `AVG` will give you the average of all the values in a column. Use it to see the average of the same column. 1107 | 1108 | #### HINTS 1109 | 1110 | - It's the `major_id` column in the `students` table 1111 | - Use `AVG` like you used `SUM`, `MIN` and `MAX` 1112 | - You previously used `SELECT SUM(major_id) FROM students;` 1113 | - Enter `SELECT AVG(major_id) FROM students;` in the psql prompt 1114 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 1115 | 1116 | ## 1910. psql SELECT CEIL(AVG(major_id)) 1117 | 1118 | ### 1910.1 1119 | 1120 | You can round decimals up or down to the nearest whole number with `CEIL` and `FLOOR`, respectively. Use `CEIL` to round the average `major_id` up to the nearest whole number. Here's an example: `CEIL()`. 1121 | 1122 | #### HINTS 1123 | 1124 | - Here's another example: `CEIL()` 1125 | - You previously used `SELECT AVG(major_id) FROM students;` to get the average 1126 | - Put `AVG(major_id)` inside the parenthesis of the `CEIL` function 1127 | - Enter `SELECT CEIL(AVG(major_id)) FROM students;` in the psql prompt 1128 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 1129 | 1130 | ## 1920. psql SELECT ROUND(AVG(major_id)) 1131 | 1132 | ### 1920.1 1133 | 1134 | Or, you can round a number to the nearest whole number with `ROUND`. Use it to round the average of the `major_id` column to the nearest whole number. 1135 | 1136 | #### HINTS 1137 | 1138 | - Here's an example: `ROUND()` 1139 | - You previously used `SELECT CEIL(AVG(major_id)) FROM students;` to round a number up 1140 | - Put `AVG(major_id)` inside the parenthesis of the `ROUND` function 1141 | - Enter `SELECT ROUND(AVG(major_id)) FROM students;` in the psql prompt 1142 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 1143 | 1144 | ## 1930. psql SELECT ROUND(AVG(major_id),5) 1145 | 1146 | ### 1930.1 1147 | 1148 | You can round to a specific number of decimal places by adding a comma and number to `ROUND`, like this: `ROUND(, )`. Round the average of the `major_id` to five decimal places. 1149 | 1150 | #### HINTS 1151 | 1152 | - You previously used `SELECT ROUND(AVG(major_id)) FROM students;` to get the average 1153 | - Put `AVG(major_id), 5` inside the parenthesis of the `ROUND` function 1154 | - Enter `SELECT ROUND(AVG(major_id), 5) FROM students;` in the psql prompt 1155 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 1156 | 1157 | ## 1940. Add echo query result 1158 | 1159 | ### 1940.1 1160 | 1161 | You should be able to find what your script is asking for now. Add the command to print it. 1162 | 1163 | #### HINTS 1164 | 1165 | - Add `echo "$($PSQL "")"` to the bottom of the `student_info.sh` file, except with the correct query in it 1166 | - If you run your script, the last echo statement should print: 1167 | ```sh 1168 | 3.09 1169 | ``` 1170 | - Practice the query in the psql prompt to make sure it's getting what you want 1171 | - You previously used `SELECT ROUND(AVG(major_id), 5) FROM students;` in the psql prompt 1172 | - Add `echo "$($PSQL "SELECT ROUND(AVG(gpa), 2) FROM students")"` to the bottom of the `student_info.sh` file 1173 | 1174 | ## 1950. ./student_info.sh 1175 | 1176 | ### 1950.1 1177 | 1178 | Run the script to see the average GPA of all your students. 1179 | 1180 | #### HINTS 1181 | 1182 | - Run your `student_info.sh` script by executing it 1183 | - Type `./student_info.sh` in the terminal and press enter 1184 | - Make sure you are in the `project` folder first 1185 | 1186 | ## 1960. Add echo count of students per major with more than one student 1187 | 1188 | ### 1960.1 1189 | 1190 | They're doing pretty good. Add another command to print `Major ID, total number of students in a column named 'number_of_students', and average GPA rounded to two decimal places in a column name 'average_gpa', for each major ID in the students table having a student count greater than 1:` 1191 | 1192 | #### HINTS 1193 | 1194 | - At the bottom of the file, use `echo` with the `-e` flag and a new line character again to print the suggested sentence 1195 | - The new line character is `\n` 1196 | - Here's an example of the command: `echo -e "\n"` 1197 | - At the bottom of the `student_info.sh` file, add this: 1198 | ```sh 1199 | echo -e "\nMajor ID, total number of students in a column named 'number_of_students', and average GPA rounded to two decimal places in a column name 'average_gpa', for each major ID in the students table having a student count greater than 1:" 1200 | ``` 1201 | 1202 | ## 1970. psql SELECT COUNT(*) FROM majors 1203 | 1204 | ### 1970.1 1205 | 1206 | Another function is `COUNT`. You can use it like this: `COUNT()`. It will tell you how many entries are in a table for the column. Try it out in the psql prompt by using `COUNT(*)` to see how many majors there are. 1207 | 1208 | #### HINTS 1209 | 1210 | - Use the `SELECT`, `COUNT`, and `FROM` keywords 1211 | - Here's an example `SELECT COUNT() FROM
;` 1212 | - Use `*` for the column and `majors` for the table 1213 | - Enter `SELECT COUNT(*) FROM majors;` in the psql prompt 1214 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 1215 | 1216 | ## 1980. psql SELECT COUNT(*) FROM students 1217 | 1218 | ### 1980.1 1219 | 1220 | Using the same method, check how many students you have. 1221 | 1222 | #### HINTS 1223 | 1224 | - You previously used: `SELECT COUNT(*) FROM majors;` 1225 | - Use the `SELECT`, `COUNT`, and `FROM` keywords 1226 | - Here's an example `SELECT COUNT() FROM
;` 1227 | - Use `*` for the column and `students` for the table 1228 | - Enter `SELECT COUNT(*) FROM students;` in the psql prompt 1229 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 1230 | 1231 | ## 1990. psql SELECT COUNT(major_id) FROM students 1232 | 1233 | ### 1990.1 1234 | 1235 | Using `*` like that told you how many total rows are in the table. View the count of the `major_id` column in the `students` table to see how many of your students have picked a major. 1236 | 1237 | #### HINTS 1238 | 1239 | - Use the `SELECT`, `COUNT`, and `FROM` keywords 1240 | - Here's an example `SELECT COUNT() FROM
;` 1241 | - Use `major_id` for the column and `students` for the table 1242 | - Enter `SELECT COUNT(major_id) FROM students;` in the psql prompt 1243 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 1244 | 1245 | ## 2000. psql SELECT DISTINCT(major_id) FROM students 1246 | 1247 | ### 2000.1 1248 | 1249 | Using `major_id` didn't count the `null` values in that column. 23 students have a major. `DISTINCT` is a function that will show you only unique values. You can use it like this: `DISTINCT()`. View the unique `major_id` values in the `students` table. 1250 | 1251 | #### HINTS 1252 | 1253 | - Use the `SELECT`, `COUNT`, and `FROM` keywords 1254 | - Here's an example `SELECT DISTINCT() FROM
;` 1255 | - Use `major_id` for the column and `students` for the table 1256 | - Enter `SELECT DISTINCT(major_id) FROM students;` in the psql prompt 1257 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 1258 | 1259 | ## 2010. psql SELECT FROM students GROUP BY major_id 1260 | 1261 | ### 2010.1 1262 | 1263 | There's six unique `major_id` values in the `students` table. You can get the same results with `GROUP BY`. Here's an example of how to use it: `SELECT FROM
GROUP BY `. Use this method to view the unique `major_id` values in the `students` table again. 1264 | 1265 | #### HINTS 1266 | 1267 | - You want to **select** and **group** the `major_id` column 1268 | - Use the `SELECT`, `FROM`, and `GROUP BY` keywords 1269 | - Here's an example `SELECT COUNT() FROM
;` 1270 | - Use `major_id` for the column and `students` for the table 1271 | - Enter `SELECT major_id FROM students GROUP BY major_id;` in the psql prompt 1272 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 1273 | 1274 | ## 2020. psql SELECT major_id, count(*) FROM students GROUP BY major_id 1275 | 1276 | ### 2020.1 1277 | 1278 | The output was the same as `DISTINCT`, but with `GROUP BY` you can add any of the aggregate functions (`MIN`, `MAX`, `COUNT`, etc) to it to find more information. For instance, if you wanted to see how many students were in each major you could use `SELECT COUNT(*) FROM students GROUP BY major_id`. View the `major_id` column **and** number of students in each `major_id`. 1279 | 1280 | #### HINTS 1281 | 1282 | - You want to `SELECT` two columns, `major_id` and the `COUNT` of all (`*`) the rows 1283 | - Use the `SELECT`, `COUNT`, `FROM`, and `GROUP BY` keywords 1284 | - Here's an example `SELECT , COUNT() FROM
GROUP BY ;` 1285 | - Enter `SELECT major_id, COUNT(*) FROM students GROUP BY major_id;` in the psql prompt 1286 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 1287 | 1288 | ## 2030. psql SELECT major_id, MIN(gpa) FROM students GROUP BY major_id 1289 | 1290 | ### 2030.1 1291 | 1292 | When using `GROUP BY`, any columns in the `SELECT` area must be included in the `GROUP BY` area. Other columns must be used with any of the aggregate functions (`MAX`, `AVG`, `COUNT`, etc). View the unique `major_id` values with `GROUP BY` again, but see what the lowest GPA is in each of them. 1293 | 1294 | #### HINTS 1295 | 1296 | - The last query was `SELECT major_id, COUNT(*) FROM students GROUP BY major_id;` 1297 | - Use the `SELECT`, `MIN`, `FROM`, and `GROUP BY` keywords 1298 | - Here's an example `SELECT , MIN() FROM
GROUP BY ;` 1299 | - Enter `SELECT major_id, MIN(gpa) FROM students GROUP BY major_id;` in the psql prompt 1300 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 1301 | 1302 | ## 2040. psql SELECT MIN(gpa), MAX(gpa) FROM students GROUP BY major_id 1303 | 1304 | ### 2040.1 1305 | 1306 | Nice job. Enter the same query, but add a column that shows you the highest GPA in each major as well. 1307 | 1308 | #### HINTS 1309 | 1310 | - The last query was: `SELECT major_id, MIN(gpa) FROM students GROUP BY major_id;` 1311 | - Use the `SELECT`, `MIN`, `MAX`, `FROM`, and `GROUP BY` keywords 1312 | - Enter `SELECT major_id, MIN(gpa), MAX(gpa) FROM students GROUP BY major_id;` in the psql prompt 1313 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 1314 | 1315 | ## 2050. psql SELECT MIN(gpa), MAX(gpa) FROM students GROUP BY major_id HAVING MAX(gpa) = 4 1316 | 1317 | ### 2050.1 1318 | 1319 | Another option with `GROUP BY` is `HAVING`. You can add it at the end like this: `SELECT FROM
GROUP BY HAVING `. The condition must be an aggregate function with a test. An example to might be to use `HAVING COUNT(*) > 0` to only show what whatever column is grouped that have at least one row. Use `HAVING` to only show rows from the last query that have a maximum GPA of 4.0. 1320 | 1321 | #### HINTS 1322 | 1323 | - The last query was: `SELECT major_id, MIN(gpa), MAX(gpa) FROM students GROUP BY major_id;` 1324 | - Use the `SELECT`, `MIN`, `MAX`, `FROM`, `GROUP BY`, and `HAVING` keywords 1325 | - Here's an example `SELECT , MIN(), MAX() FROM
GROUP BY HAVING ;` 1326 | - The condition you want is `HAVING MAX(gpa) = 4.0` 1327 | - Enter `SELECT major_id, MIN(gpa), MAX(gpa) FROM students GROUP BY major_id HAVING MAX(gpa) = 4.0;` in the psql prompt 1328 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 1329 | 1330 | ## 2060. psql SELECT MIN(gpa) AS, MAX(gpa) FROM students GROUP BY major_id HAVING MAX(gpa) = 4 1331 | 1332 | ### 2060.1 1333 | 1334 | Two of your majors have at least one student with a 4.0 GPA. Looking at the results, the column is named `min`. You can rename a column with `AS` like this: `SELECT AS ` Enter the same command, but rename the `min` column to `min_gpa`. 1335 | 1336 | #### HINTS 1337 | 1338 | - The last query was: `SELECT major_id, MIN(gpa), MAX(gpa) FROM students GROUP BY major_id HAVING MAX(gpa) = 4.0;` 1339 | - Use the `SELECT`, `MIN`, `AS`, `FROM`, and `GROUP BY` keywords 1340 | - Rename the `MIN(gpa)` column like this: `MIN(gpa) AS min_gpa` 1341 | - Enter `SELECT major_id, MIN(gpa) AS min_gpa, MAX(gpa) FROM students GROUP BY major_id HAVING MAX(gpa) = 4.0;` in the psql prompt 1342 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 1343 | 1344 | ## 2070. psql SELECT MIN(gpa) AS, MAX(gpa) AS FROM students GROUP BY major_id HAVING MAX(gpa) = 4 1345 | 1346 | ### 2070.1 1347 | 1348 | Now the column has a better name. Enter the same command, but rename the `max` column to `max_gpa` as well. 1349 | 1350 | #### HINTS 1351 | 1352 | - The last query was: `SELECT major_id, MIN(gpa) AS min_gpa, MAX(gpa) FROM students GROUP BY major_id HAVING MAX(gpa) = 4.0;` 1353 | - Use the `SELECT`, `MIN`, `AS`, `FROM`, and `GROUP BY` keywords 1354 | - Rename the `MAX(gpa)` column like this: `MAX(gpa) AS max_gpa` 1355 | - Enter `SELECT major_id, MIN(gpa) AS min_gpa, MAX(gpa) AS max_gpa FROM students GROUP BY major_id HAVING MAX(gpa) = 4.0;` in the psql prompt 1356 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 1357 | 1358 | ## 2075. psql - SELECT major_id, COUNT() AS number_of_students FROM students GROUP BY major_id 1359 | 1360 | ### 2075.1 1361 | 1362 | That's more descriptive. View the `major_id` and number of students in each `major_id` in a column named `number_of_students`. 1363 | 1364 | #### HINTS 1365 | 1366 | - Use the `SELECT`, `COUNT`, `AS`, `FROM`, and `GROUP BY` keywords 1367 | - Here's an example: `SELECT , COUNT(*) AS FROM
GROUP BY ;` 1368 | - You want to `COUNT(*) AS number_of_students` and `GROUP BY major_id` 1369 | - Enter `SELECT major_id, COUNT(*) AS number_of_students FROM students GROUP BY major_id;` in the psql prompt 1370 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 1371 | 1372 | ## 2080. psql SELECT COUNT(*) AS FROM students GROUP BY major_id HAVING COUNT(*) < 8 1373 | 1374 | ### 2080.1 1375 | 1376 | Use `HAVING` with the last query to only show the rows with less than eight students in the major. 1377 | 1378 | #### HINTS 1379 | 1380 | - The last query was: `SELECT major_id, COUNT(*) AS number_of_students FROM students GROUP BY major_id;` 1381 | - Here's an example: `SELECT , COUNT(*) AS FROM
GROUP BY HAVING ;` 1382 | - The condition you want is `COUNT(*) < 8` 1383 | - Enter `SELECT major_id, COUNT(*) AS number_of_students FROM students GROUP BY major_id HAVING COUNT(*) < 8;` in the psql prompt 1384 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 1385 | 1386 | ## 2090. Add echo query result 1387 | 1388 | ### 2090.1 1389 | 1390 | Well done. Back in your script, add the command the print the suggested results. 1391 | 1392 | #### HINTS 1393 | 1394 | - Add `echo "$($PSQL "")"` to the bottom of the `student_info.sh` file, except with the correct query in it 1395 | - If you run your script, the last echo statement should print: 1396 | ```sh 1397 | |8|2.97 1398 | 37|6|3.38 1399 | 36|6|2.92 1400 | 41|6|3.53 1401 | 38|4|2.73 1402 | ``` 1403 | - Practice the query in the psql prompt to make sure it's getting what you want 1404 | - You previously used `SELECT major_id, COUNT(*) AS number_of_students FROM students GROUP BY major_id HAVING COUNT(*) < 8;` in the psql prompt 1405 | - Add `echo "$($PSQL "SELECT major_id, COUNT(*) AS number_of_students, ROUND(AVG(gpa),2) AS average_gpa FROM students GROUP BY major_id HAVING COUNT(*) > 1")"` to the bottom of the `student_info.sh` file 1406 | 1407 | ## 2100. ./student_info.sh 1408 | 1409 | ### 2100.1 1410 | 1411 | Run the script to see the output. 1412 | 1413 | #### HINTS 1414 | 1415 | - Run your `student_info.sh` script by executing it 1416 | - Type `./student_info.sh` in the terminal and press enter 1417 | - Make sure you are in the `project` folder first 1418 | 1419 | ## 2110. Add echo majors with no students or student with ma 1420 | 1421 | ### 2110.1 1422 | 1423 | Add an echo command to your script like the others that prints `List of majors, in alphabetical order, that either no student is taking or has a student whose first name contains a case insensitive 'ma':` 1424 | 1425 | #### HINTS 1426 | 1427 | - At the bottom of the file, use `echo` with the `-e` flag and a new line character again to print the suggested sentence 1428 | - The new line character is `\n` 1429 | - Here's an example of the command: `echo -e "\n"` 1430 | - At the bottom of the `student_info.sh` file, add this: 1431 | ```sh 1432 | echo -e "\nList of majors, in alphabetical order, that either no student is taking or has a student whose first name contains a case insensitive 'ma':" 1433 | ``` 1434 | 1435 | ## 2120. psql students FULL JOIN majors 1436 | 1437 | ### 2120.1 1438 | 1439 | The `majors` and `students` table are linked with the `major_id` foreign key. If you want to see the name of a major that a student is taking, you need to `JOIN` the two tables into one. Here's an example of how to do that: 1440 | `SELECT * FROM FULL JOIN ON . = .;` 1441 | 1442 | In the psql prompt, join the two tables together with the above method. 1443 | 1444 | #### HINTS 1445 | 1446 | - Join the `students` and `majors` table with the method in the example. Use the `students` table first where applicable 1447 | - Enter `SELECT * FROM students FULL JOIN majors ON students.major_id = majors.major_id;` in the psql prompt 1448 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 1449 | 1450 | ## 2130. psql students LEFT JOIN majors 1451 | 1452 | ### 2130.1 1453 | 1454 | It's showing all the columns from both tables, the two `major_id` columns are the same in each row for the ones that have it. You can see that there are some students without a major, and some majors without any students. The `FULL JOIN` you used will include **all** rows from both tables, whether or not they have a row using that foreign key in the other. From there, you could use any of the previous methods to narrow down, group, order, etc. Use a `LEFT JOIN` to join the same two tables in the same way. 1455 | 1456 | #### HINTS 1457 | 1458 | - Join the `students` and `majors` table with a `LEFT JOIN`. Use the `students` table first where applicable 1459 | - You previously entered: `SELECT * FROM students FULL JOIN majors ON students.major_id = majors.major_id;` 1460 | - Replace `FULL JOIN` from the previous command with `LEFT JOIN` 1461 | - Enter `SELECT * FROM students LEFT JOIN majors ON students.major_id = majors.major_id;` in the psql prompt 1462 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 1463 | 1464 | ## 2140. psql students RIGHT JOIN majors 1465 | 1466 | ### 2140.1 1467 | 1468 | There's a few less rows than the last query. In the `LEFT JOIN` you used, the `students` table was the left table since it was on the left side of the `JOIN`. `majors` was the right table. A `LEFT JOIN` gets all rows from the left table, but only rows from the right table that are linked to from the left one. Looking at the data, you can see that every student was returned, but the majors without any students were not. Join the same two tables with a `RIGHT JOIN` this time. 1469 | 1470 | #### HINTS 1471 | 1472 | - Join the `students` and `majors` table with a `RIGHT JOIN`. Use the `students` table first where applicable 1473 | - You previously entered: `SELECT * FROM students LEFT JOIN majors ON students.major_id = majors.major_id;` 1474 | - Replace `LEFT JOIN` from the previous command with `RIGHT JOIN` 1475 | - Enter `SELECT * FROM students RIGHT JOIN majors ON students.major_id = majors.major_id;` in the psql prompt 1476 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 1477 | 1478 | ## 2150. psql students INNER JOIN majors 1479 | 1480 | ### 2150.1 1481 | 1482 | The right join showed all the rows from the right table (`majors`), but only rows from the left table (`students`) if they have a major. There's one more type you should know about. Join the two tables with an `INNER JOIN`. 1483 | 1484 | #### HINTS 1485 | 1486 | - Join the `students` and `majors` table with an `INNER JOIN`. Use the `students` table first where applicable 1487 | - You previously entered: `SELECT * FROM students RIGHT JOIN majors ON students.major_id = majors.major_id;` 1488 | - Replace `RIGHT JOIN` from the previous command with `INNER JOIN` 1489 | - Enter `SELECT * FROM students INNER JOIN majors ON students.major_id = majors.major_id;` in the psql prompt 1490 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 1491 | 1492 | ## 2160. psql majors LEFT JOIN students 1493 | 1494 | ### 2160.1 1495 | 1496 | The `INNER JOIN` only returned students if they have a major and majors that have a student. In other words, it only returned rows if they have a value in the foreign key column (`major_id`) of the opposite table. You should know a little about the four main types of joins now. Try using a `LEFT JOIN` to show **all the majors** but only students that have a major. 1497 | 1498 | #### HINTS 1499 | 1500 | - You want to join the `students` and `majors` tables again 1501 | - The left table is the on the left side of `LEFT JOIN`. 1502 | - A `LEFT JOIN` will show all rows from the left table. 1503 | - You previously entered: `SELECT * FROM students INNER JOIN majors ON students.major_id = majors.major_id;` 1504 | - Enter `SELECT * FROM majors LEFT JOIN students ON majors.major_id = students.major_id;` in the psql prompt 1505 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 1506 | 1507 | ## 2170. psql majors INNER JOIN students 1508 | 1509 | ### 2170.1 1510 | 1511 | Excellent. All the majors are there. Next, use the appropriate join to show only students that are enrolled in a major, and only majors that have a student enrolled in it. 1512 | 1513 | #### HINTS 1514 | 1515 | - You want to join the `students` and `majors` tables again 1516 | - Join them with the join that only shows rows if they have a value in the foreign key column of the other table 1517 | - The types of joins you learned are `FULL JOIN`, `LEFT JOIN`, `RIGHT JOIN`, and `INNER JOIN` 1518 | - The previous query was: `SELECT * FROM majors RIGHT JOIN students ON majors.major_id = students.major_id;` 1519 | - You want to use an `INNER JOIN` with the two tables 1520 | - Enter `SELECT * FROM majors INNER JOIN students ON majors.major_id = students.major_id;` in the psql prompt 1521 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 1522 | 1523 | ## 2180. psql majors RIGHT JOIN students 1524 | 1525 | ### 2180.1 1526 | 1527 | :thumbsup: Try using a right join to show all students but only majors if a student is enrolled in it. 1528 | 1529 | #### HINTS 1530 | 1531 | - You want to join the `students` and `majors` tables again 1532 | - The left table is the on the left side of `RIGHT JOIN`. 1533 | - A `RIGHT JOIN` will show all rows from the right table. 1534 | - You previously entered: `SELECT * FROM students INNER JOIN majors ON students.major_id = majors.major_id;` 1535 | - Enter `SELECT * FROM majors RIGHT JOIN students ON majors.major_id = students.major_id;` in the psql prompt 1536 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 1537 | 1538 | ## 2190. psql majors FULL JOIN students 1539 | 1540 | ### 2190.1 1541 | 1542 | That showed all the students since it was the right table of the `RIGHT JOIN`. Use the appropriate join with the same two table to show all rows in both tables whether they have a value in the foreign key column or not. 1543 | 1544 | #### HINTS 1545 | 1546 | - You want to join the `students` and `majors` tables again 1547 | - Join them with the join that only shows rows if they have a value in the foreign key column of the other table 1548 | - The previous query was: `SELECT * FROM majors INNER JOIN students ON majors.major_id = students.major_id;` 1549 | - You want to use an `INNER JOIN` with the two tables 1550 | - Enter `SELECT * FROM majors FULL JOIN students ON majors.major_id = students.major_id;` in the psql prompt 1551 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 1552 | 1553 | ## 2200. psql SELECT * students INNER JOIN majors 1554 | 1555 | ### 2200.1 1556 | 1557 | Lets do some more experiments with joins. Say you wanted to find a list of majors that students are taking. Use the most efficient `JOIN` to join the two tables you need. Only join the tables for now, don't use any other conditions. 1558 | 1559 | #### HINTS 1560 | 1561 | - You want to join the `students` and `majors` tables again 1562 | - Use the join that shows you only students that have a major and only majors that have a student. 1563 | - Only use the join, don't use a `WHERE`, `HAVING`, or any other filters 1564 | - You previously used: `SELECT * FROM students FULL JOIN majors ON students.major_id = majors.major_id;` 1565 | - You want to use an `INNER JOIN` 1566 | - Enter `SELECT * FROM students INNER JOIN majors ON students.major_id = majors.major_id;` in the psql prompt 1567 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 1568 | 1569 | ## 2210. psql SELECT major students INNER JOIN majors 1570 | 1571 | ### 2210.1 1572 | 1573 | Good. To get the list, you don't need all the columns, though. Enter the same command, but just get the column you need. 1574 | 1575 | #### HINTS 1576 | 1577 | - The previous query was `SELECT * FROM students INNER JOIN majors ON students.major_id = majors.major_id;` 1578 | - Enter the previous query, but only get the column you need 1579 | - You only need the `major` column 1580 | - Enter `SELECT major FROM students INNER JOIN majors ON students.major_id = majors.major_id;` in the psql prompt 1581 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 1582 | 1583 | ## 2220. psql SELECT DISTINCT(major) students INNER JOIN majors 1584 | 1585 | ### 2220.1 1586 | 1587 | You also don't want any duplicates. Use `DISTINCT` to only return the unique ones to see the list of majors who have students. 1588 | 1589 | #### HINTS 1590 | 1591 | - The previous query was `SELECT major FROM students INNER JOIN majors ON students.major_id = majors.major_id;` 1592 | - Enter the previous query, but only get the `DISTINCT` majors 1593 | - Here's an example: `DISTINCT()` 1594 | - You want to change `major` from the previous query to `DISTINCT(major)` 1595 | - Enter `SELECT DISTINCT(major) FROM students INNER JOIN majors ON students.major_id = majors.major_id;` in the psql prompt 1596 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 1597 | 1598 | ## 2230. psql SELECT * students RIGHT JOIN majors 1599 | 1600 | ### 2230.1 1601 | 1602 | There's your list of majors that students are taking :smile: Next, say you wanted a list of majors that students aren't taking. Use the most efficient `JOIN` to join the two tables you need. Only join the tables for now, don't use any other conditions. 1603 | 1604 | #### HINTS 1605 | 1606 | - You want to join the `students` and `majors` tables again 1607 | - Use the join that shows you all majors, but only students that have a major 1608 | - Only use the join, don't use a `WHERE`, `HAVING`, or any other filters 1609 | - You previously used: `SELECT * FROM students FULL JOIN majors ON students.major_id = majors.major_id;` 1610 | - You want to use a `RIGHT JOIN` with the `majors` table on the right of it 1611 | - Enter `SELECT * FROM students RIGHT JOIN majors ON students.major_id = majors.major_id;` in the psql prompt 1612 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 1613 | 1614 | ## 2240. psql SELECT * students RIGHT JOIN majors WHERE student_id IS NULL 1615 | 1616 | ### 2240.1 1617 | 1618 | That got you all the majors, you can see the ones that don't have any students. Add a `WHERE` condition to only see the majors without students, use `student_id` in it's condition. 1619 | 1620 | #### HINTS 1621 | 1622 | - The previous query was `SELECT * FROM students RIGHT JOIN majors ON students.major_id = majors.major_id;` 1623 | - Enter the previous query, but add a `WHERE ` at the end to only get the rows you need 1624 | - Use `IS NULL` with the condition 1625 | - The keywords you want are `SELECT`, `FROM`, `RIGHT JOIN`, `ON`, `WHERE` and `IS NULL` 1626 | - Use `student_id IS NULL` as the condition 1627 | - Enter `SELECT * FROM students RIGHT JOIN majors ON students.major_id = majors.major_id WHERE student_id IS NULL;` in the psql prompt 1628 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 1629 | 1630 | ## 2245. psql SELECT major students RIGHT JOIN majors WHERE student_id IS NULL 1631 | 1632 | ### 2245.1 1633 | 1634 | Now you only have the rows you need. Only get the columns you need with it to see the list of majors without students. 1635 | 1636 | #### HINTS 1637 | 1638 | - The previous query was `SELECT * FROM students LEFT JOIN majors ON students.major_id = majors.major_id WHERE student_id IS NULL;` 1639 | - Enter the previous query, but only get the column you need 1640 | - The column you need is the `major` column 1641 | - Enter `SELECT major FROM students RIGHT JOIN majors ON students.major_id = majors.major_id WHERE student_id IS NULL;` in the psql prompt 1642 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 1643 | 1644 | ## 2250. psql SELECT * students LEFT JOIN majors 1645 | 1646 | ### 2250.1 1647 | 1648 | You're doing great. Next, use the most efficient 'JOIN' to join the tables you would need if you were asked to get the first name, last name, major, and GPA of students who are taking Data Science or have a gpa of 3.8 or greater. Only join the tables for now, don't use any other conditions. 1649 | 1650 | #### HINTS 1651 | 1652 | - Use the join to get all students but only majors that have a student 1653 | - Only use the join, don't use a `WHERE`, `HAVING`, or any other conditional expressions. 1654 | - You previously used: `SELECT * FROM students RIGHT JOIN majors ON students.major_id = majors.major_id;` 1655 | - You want to use a `LEFT JOIN` with `students` as the left table 1656 | - Enter `SELECT * FROM students LEFT JOIN majors ON students.major_id = majors.major_id;` in the psql prompt 1657 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 1658 | 1659 | ## 2260. psql SELECT students LEFT JOIN majors WHERE major = Data Science OR gpa >= 3.8 1660 | 1661 | ### 2260.1 1662 | 1663 | Enter the same command, but use `WHERE` to only get the students that meet the requirements. As a reminder, the goal was to find students who are taking Data Science or have a gpa of 3.8 or greater. 1664 | 1665 | #### HINTS 1666 | 1667 | - The previous query was `SELECT * FROM students LEFT JOIN majors ON students.major_id = majors.major_id;` 1668 | - You want to add two conditions one testing the `major` column, and another testing the `gpa` column 1669 | - Here's an example `SELECT * FROM LEFT JOIN ON . = . WHERE OR ;` 1670 | - The two conditions you want are `major = 'Data Science'` and `gpa >= 3.8` 1671 | - Enter `SELECT * FROM students LEFT JOIN majors ON students.major_id = majors.major_id WHERE major='Data Science' OR gpa >= 3.8;` in the psql prompt 1672 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 1673 | 1674 | ## 2265. psql SELECT columns LEFT JOIN WHERE major = Data Science OR gpa >= 3.8 1675 | 1676 | ### 2265.1 1677 | 1678 | Now, you have narrowed it down the rows you are looking for. Enter the same command, but only get the columns you need. There was four of them, the students first name, last name, their major, and GPA. Get them in that order. 1679 | 1680 | #### HINTS 1681 | 1682 | - The previous query was `SELECT * FROM students LEFT JOIN majors ON students.major_id = majors.major_id WHERE major='Data Science' OR gpa >= 3.8;` 1683 | - Enter the previous query, but only get the columns you need 1684 | - Get the `first_name`, `last_name`, `major`, and `gpa` columns in that order 1685 | - Enter `SELECT first_name, last_name, major, gpa FROM students LEFT JOIN majors ON students.major_id = majors.major_id WHERE major='Data Science' OR gpa >= 3.8;` in the psql prompt 1686 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 1687 | 1688 | ## 2270. psql SELECT * students FULL JOIN majors 1689 | 1690 | ### 2270.1 1691 | 1692 | From there, you could put them in a specific order if you wanted or limit the results to a certain number among other things. Lastly, use the most efficient 'JOIN' to join the tables you would need if you were asked to get the first name and major for students whose `first_name`, or the `major`, contains `ri`. Only join the tables for now, don't use any other conditions. 1693 | 1694 | #### HINTS 1695 | 1696 | - Use the join that gets all students and majors 1697 | - You previously used: `SELECT * FROM students LEFT JOIN majors ON students.major_id = majors.major_id;` 1698 | - You want to use a `FULL JOIN` 1699 | - Enter `SELECT * FROM students FULL JOIN majors ON students.major_id = majors.major_id;` in the psql prompt 1700 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 1701 | 1702 | ## 2280. psql SELECT * students FULL JOIN majors WHERE first_name || major LIKE ri 1703 | 1704 | ### 2280.1 1705 | 1706 | Add a `WHERE` to the previous query so you only get the rows you need. The rows you wanted were the ones with a first name or major containing `ri`. 1707 | 1708 | #### HINTS 1709 | 1710 | - The previous query was `SELECT * FROM students FULL JOIN majors ON students.major_id = majors.major_id;` 1711 | - You want to add two conditions one testing the `first_name` column, and another testing the `major` column 1712 | - Here's an example `SELECT * FROM LEFT JOIN ON . = . WHERE OR ;` 1713 | - The two conditions you want should use the `LIKE` or `ILIKE` keywords 1714 | - They conditions are `WHERE first_name LIKE '%ri%' OR major LIKE '%ri%'` 1715 | - Enter `SELECT * FROM students FULL JOIN majors ON students.major_id = majors.major_id WHERE first_name LIKE '%ri%' OR major LIKE '%ri%';` in the psql prompt 1716 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 1717 | 1718 | ## 2290. psql SELECT major FROM students FULL JOIN majors WHERE WHERE first_name || major LIKE ri 1719 | 1720 | ### 2290.1 1721 | 1722 | Finally, you only wanted to display the `first_name` and `major` columns. Enter the previous query, but only get the columns you need. 1723 | 1724 | #### HINTS 1725 | 1726 | - The previous query was `SELECT * FROM students LEFT JOIN majors ON students.major_id = majors.major_id WHERE first_name LIKE '%ri%' OR major LIKE '%ri%';` 1727 | - The two columns you want are `first_name` and `major` 1728 | - Enter `SELECT first_name, major FROM students FULL JOIN majors ON students.major_id = majors.major_id WHERE first_name LIKE '%ri%' OR major LIKE '%ri%';` in the psql prompt 1729 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 1730 | 1731 | ## 2310. Add echo query result 1732 | 1733 | ### 2310.1 1734 | 1735 | In your script, add the command to print what the sentence is asking for. 1736 | 1737 | #### HINTS 1738 | 1739 | - Add `echo "$($PSQL "")"` to the bottom of the `student_info.sh` file, except with the correct query in it 1740 | - If you run your script, the last echo statement should print: 1741 | ```sh 1742 | Computer Programming 1743 | Database Administration 1744 | Network Engineering 1745 | Web Development 1746 | ``` 1747 | - Practice the query in the psql prompt to make sure it's getting what you want 1748 | - You previously used `SELECT first_name, major FROM students FULL JOIN majors ON students.major_id = majors.major_id WHERE first_name LIKE '%ri%' OR major LIKE '%ri%';` in the psql prompt 1749 | - Add `echo "$($PSQL "SELECT major FROM students FULL JOIN majors ON students.major_id = majors.major_id WHERE major IS NOT NULL AND (student_id IS NULL OR first_name ILIKE '%ma%') ORDER BY major")"` to the bottom of the `student_info.sh` file 1750 | 1751 | ## 2320. ./student_info.sh 1752 | 1753 | ### 2320.1 1754 | 1755 | Run the script to see the majors described. 1756 | 1757 | #### HINTS 1758 | 1759 | - Run your `student_info.sh` script by executing it 1760 | - Type `./student_info.sh` in the terminal and press enter 1761 | - Make sure you are in the `project` folder first 1762 | 1763 | ## 2330. Add echo courses with no students or Obie Hilpert 1764 | 1765 | ### 2330.1 1766 | 1767 | :smile: Almost done. In your script, add a command to print this sentence like the others: `List of unique courses, in reverse alphabetical order, that no student or 'Obie Hilpert' is taking:` 1768 | 1769 | #### HINTS 1770 | 1771 | - At the bottom of the file, use `echo` with the `-e` flag and a new line character again to print the suggested sentence 1772 | - The new line character is `\n` 1773 | - Here's an example of the command: `echo -e "\n"` 1774 | - At the bottom of the `student_info.sh` file, add this: 1775 | ```sh 1776 | echo -e "\nList of unique courses, in reverse alphabetical order, that no student or 'Obie Hilpert' is taking:" 1777 | ``` 1778 | 1779 | ## 2340. psql SELECT * FROM students FULL JOIN majors 1780 | 1781 | ### 2340.1 1782 | 1783 | Lets go over a few more things before you figure out how to see the courses a student is taking. Start by doing a `FULL JOIN` on your `students` and `majors` tables. 1784 | 1785 | #### HINTS 1786 | 1787 | - Join the `students` and `majors` table with a `FULL JOIN`. Use the `students` table first where applicable 1788 | - Enter `SELECT * FROM students FULL JOIN majors ON students.major_id = majors.major_id;` in the psql prompt 1789 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 1790 | 1791 | ## 2350. psql SELECT students.major_id students FULL JOIN majors 1792 | 1793 | ### 2350.1 1794 | 1795 | If you look at the column names, it shows two `major_id` columns. One from the `students` table and one from the `majors` table. If you were to try and query it using `major_id`, you would get an error. You would need to specify what table you want the column from like this: `
.`. Enter the same join but only get the `major_id` column from the `students` table. 1796 | 1797 | #### HINTS 1798 | 1799 | - The previous query was `SELECT * FROM students FULL JOIN majors ON students.major_id = majors.major_id;` 1800 | - You can get the column you want with `students.major_id` 1801 | - Enter `SELECT students.major_id FROM students FULL JOIN majors ON students.major_id = majors.major_id;` in the psql prompt 1802 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 1803 | 1804 | ## 2360. psql SELECT students.major_id FROM students FULL JOIN majors AS m 1805 | 1806 | ### 2360.1 1807 | 1808 | Earlier, you used `AS` to rename columns. You can use it to rename tables, or give them aliases, as well. Here's an example: `SELECT * FROM
AS ;`. Enter the same query you just entered, but rename the `majors` table to `m`. Anywhere the `majors` table is referenced, you will need to use `m` instead of `majors`. 1809 | 1810 | #### HINTS 1811 | 1812 | - The previous query was `SELECT students.major_id FROM students FULL JOIN majors ON students.major_id = majors.major_id;` 1813 | - You want to join `majors AS m` and use `m.major_id` when referencing the joining column 1814 | - Enter `SELECT students.major_id FROM students FULL JOIN majors AS m ON students.major_id = m.major_id;` in the psql prompt 1815 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 1816 | 1817 | ## 2370. psql SELECT s.major_id FROM students AS s FULL JOIN majors AS m 1818 | 1819 | ### 2370.1 1820 | 1821 | This doesn't affect the output. It can just make some queries easier to read. Enter the same query, but rename the `students` table to `s` as well. 1822 | 1823 | #### HINTS 1824 | 1825 | - The previous query was `SELECT students.major_id FROM students FULL JOIN majors AS m ON students.major_id = m.major_id;` 1826 | - You want to rename `students AS s` and use `s.` when referencing columns from the `students` table 1827 | - Enter `SELECT s.major_id FROM students AS s FULL JOIN majors AS m ON s.major_id = m.major_id;` in the psql prompt 1828 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 1829 | 1830 | ## 2390. psql SELECT * FROM students FULL JOIN majors USING 1831 | 1832 | ### 2390.1 1833 | 1834 | There's a shortcut keyword, `USING` to join tables if the foreign key column has the same name in both tables. Here's an example: `SELECT * FROM FULL JOIN USING();`. Use this method to see **all** the columns in the `students` and `majors` table. Don't use any aliases. 1835 | 1836 | #### HINTS 1837 | 1838 | - Enter `SELECT * FROM students FULL JOIN majors USING(major_id);` in the psql prompt 1839 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 1840 | 1841 | ## 2400. psql SELECT * FROM students FULL JOIN majors USING FULL JOIN major_courses USING 1842 | 1843 | ### 2400.1 1844 | 1845 | Note that the two `major_id` columns were turned into one with `USING`. In order to find out what courses a student is taking, you will need to join all the tables together. You can add a third table to a join like this: `SELECT * FROM FULL JOIN USING() FULL JOIN USING()`. This example will join the first two tables into one, turning it into the left table for the second join. Use this method to join the two tables from the previous query with the `majors_courses` table. 1846 | 1847 | #### HINTS 1848 | 1849 | - The previous query was `SELECT * FROM students FULL JOIN majors USING(major_id);` 1850 | - View the details of the `majors_courses` table with `\d majors_courses` to find the foreign key to join on 1851 | - It's the `major_id` column 1852 | - Enter `SELECT * FROM students FULL JOIN majors USING(major_id) FULL JOIN majors_courses USING(major_id);` in the psql prompt 1853 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 1854 | 1855 | ## 2410. psql SELECT * students FULL JOIN majors USING JOIN major_courses USING JOIN courses USING 1856 | 1857 | ### 2410.1 1858 | 1859 | You may need to adjust the terminal size to align the output. What you're seeing is every unique combination of rows in the database. Students with a major are listed multiple times, one for each course included in the major. The majors without any students are there along with the courses for them. The students without a major are included, they have no courses and are only listed once. You can join as many tables together as you want. Join the last table to the previous command to get the names of the courses with all this info. 1860 | 1861 | #### HINTS 1862 | 1863 | - The previous query was `SELECT * FROM students FULL JOIN majors USING(major_id) FULL JOIN majors_courses USING(major_id);` 1864 | - The last table is the `courses` table 1865 | - View the details of the `courses` table with `\d courses` to find the foreign key to join on 1866 | - Enter `SELECT * FROM students FULL JOIN majors USING(major_id) FULL JOIN majors_courses USING(major_id) FULL JOIN courses USING(course_id);` in the psql prompt 1867 | - Enter `psql --username=freecodecamp --dbname=students` in the terminal to log into the psql prompt if you aren't already 1868 | 1869 | ## 2420. Add echo query result 1870 | 1871 | ### 2420.1 1872 | 1873 | Same amount of rows, but you get the course names now. In your script, add the command to print the suggested info. 1874 | 1875 | #### HINTS 1876 | 1877 | - Add `echo "$($PSQL "")"` to the bottom of the `student_info.sh` file, except with the correct query in it 1878 | - If you run your script, the last echo statement should print: 1879 | ```sh 1880 | Web Programming 1881 | Web Applications 1882 | Python 1883 | Object-Oriented Programming 1884 | Network Security 1885 | Data Structures and Algorithms 1886 | Computer Systems 1887 | Computer Networks 1888 | Algorithms 1889 | ``` 1890 | - Practice the query in the psql prompt to make sure it's getting what you want 1891 | - You previously used `SELECT * FROM students FULL JOIN majors USING(major_id) FULL JOIN majors_courses USING(major_id) FULL JOIN courses USING(course_id);` in the psql prompt 1892 | - Add `echo "$($PSQL "SELECT DISTINCT(course) FROM students RIGHT JOIN majors USING(major_id) INNER JOIN majors_courses USING(major_id) INNER JOIN courses USING(course_id) WHERE (first_name = 'Obie' AND last_name = 'Hilpert') OR student_id IS NULL ORDER BY course DESC")"` to the bottom of the `student_info.sh` file 1893 | 1894 | ## 2430. ./student_info.sh 1895 | 1896 | ### 2430.1 1897 | 1898 | Run the script to see courses described. 1899 | 1900 | #### HINTS 1901 | 1902 | - Run your `student_info.sh` script by executing it 1903 | - Type `./student_info.sh` in the terminal and press enter 1904 | - Make sure you are in the `project` folder first 1905 | 1906 | ## 2440. Add echo courses with only one student 1907 | 1908 | ### 2440.1 1909 | 1910 | Last one. Add a command that prints `List of courses, in alphabetical order, with only one student enrolled:`. 1911 | 1912 | #### HINTS 1913 | 1914 | - At the bottom of the file, use `echo` with the `-e` flag and a new line character again to print the suggested sentence 1915 | - The new line character is `\n` 1916 | - Here's an example of the command: `echo -e "\n"` 1917 | - At the bottom of the `student_info.sh` file, add this: 1918 | ```sh 1919 | echo -e "\nList of courses, in alphabetical order, with only one student enrolled:" 1920 | ``` 1921 | 1922 | ## 2450. Add echo query result 1923 | 1924 | ### 2450.1 1925 | 1926 | Go for it. 1927 | 1928 | #### HINTS 1929 | 1930 | - Add a command at the bottom of the script to print the suggested information 1931 | - Add `echo "$($PSQL "")"` to the bottom of the `student_info.sh` file, except with the correct query in it 1932 | - If you run your script, the last echo statement should print: 1933 | ```sh 1934 | Computer Networks 1935 | Computer Systems 1936 | Server Administration 1937 | UNIX 1938 | ``` 1939 | - Practice the query in the psql prompt to make sure it's getting what you want 1940 | - You can do this 1941 | - Give it another try 1942 | - I don't know how to get it either 1943 | - So there's no answers here 1944 | - :confused: 1945 | - Try entering this in the psql prompt: `SELECT COUNT(course), COURSE FROM students INNER JOIN majors USING(major_id) INNER JOIN majors_courses USING(major_id) INNER JOIN courses USING(course_id) GROUP BY course;` 1946 | - Add `echo "$($PSQL "SELECT course FROM students INNER JOIN majors_courses USING(major_id) INNER JOIN courses USING(course_id) GROUP BY course HAVING COUNT(student_id) = 1 ORDER BY course")"` to the bottom of the `student_info.sh` file 1947 | 1948 | ## 2460. ./student_info.sh 1949 | 1950 | ### 2460.1 1951 | 1952 | This is the last step, you have done really well. Run the script one last time. :wave: 1953 | 1954 | #### HINTS 1955 | 1956 | - Run your `student_info.sh` script by executing it 1957 | - Type `./student_info.sh` in the terminal and press enter 1958 | - Make sure you are in the `project` folder first 1959 | -------------------------------------------------------------------------------- /coderoad.yaml: -------------------------------------------------------------------------------- 1 | id: 'freeCodeCamp/learn-sql-by-building-a-student-database-part-2:v1.0.0' 2 | version: '2.0.0' 3 | config: 4 | setup: 5 | commands: 6 | - ./.freeCodeCamp/reset.sh 7 | - cd .freeCodeCamp && npm install 8 | testRunner: 9 | command: npm run programmatic-test 10 | args: 11 | tap: --reporter=mocha-tap-reporter 12 | directory: .freeCodeCamp 13 | repo: 14 | uri: https://github.com/freeCodeCamp/learn-sql-by-building-a-student-database-part-2 15 | branch: v2.0.0 16 | continue: 17 | commands: 18 | - './.freeCodeCamp/reset.sh' 19 | reset: 20 | commands: 21 | - './.freeCodeCamp/reset.sh' 22 | dependencies: 23 | - name: node 24 | version: '>=10' 25 | webhook: 26 | url: 'https://api.freecodecamp.org/coderoad-challenge-completed' 27 | events: 28 | init: false 29 | reset: false 30 | step_complete: false 31 | level_complete: false 32 | tutorial_complete: true 33 | levels: 34 | - id: '10' 35 | steps: 36 | - id: '10.1' 37 | setup: 38 | watchers: 39 | - ../.bash_history 40 | - id: '20' 41 | steps: 42 | - id: '20.1' 43 | setup: 44 | watchers: 45 | - ../pg.log 46 | - id: '30' 47 | steps: 48 | - id: '30.1' 49 | setup: 50 | watchers: 51 | - ../pg.log 52 | - id: '40' 53 | steps: 54 | - id: '40.1' 55 | setup: 56 | watchers: 57 | - ../.bash_history 58 | - id: '50' 59 | steps: 60 | - id: '50.1' 61 | setup: 62 | watchers: 63 | - ../pg.log 64 | - id: '60' 65 | steps: 66 | - id: '60.1' 67 | setup: 68 | watchers: 69 | - ../pg.log 70 | - id: '70' 71 | steps: 72 | - id: '70.1' 73 | setup: 74 | watchers: 75 | - ../pg.log 76 | - id: '80' 77 | steps: 78 | - id: '80.1' 79 | setup: 80 | watchers: 81 | - ../pg.log 82 | - id: '90' 83 | steps: 84 | - id: '90.1' 85 | setup: 86 | watchers: 87 | - ../pg.log 88 | - id: '1220' 89 | steps: 90 | - id: '1220.1' 91 | setup: 92 | watchers: 93 | - ../.bash_history 94 | - id: '1230' 95 | steps: 96 | - id: '1230.1' 97 | setup: 98 | watchers: 99 | - ../.bash_history 100 | - id: '1240' 101 | steps: 102 | - id: '1240.1' 103 | setup: 104 | watchers: 105 | - ./student_info.sh 106 | - id: '1250' 107 | steps: 108 | - id: '1250.1' 109 | setup: 110 | watchers: 111 | - ./student_info.sh 112 | - id: '1260' 113 | steps: 114 | - id: '1260.1' 115 | setup: 116 | watchers: 117 | - ./student_info.sh 118 | - id: '1265' 119 | steps: 120 | - id: '1265.1' 121 | setup: 122 | watchers: 123 | - ../.bash_history 124 | - id: '1270' 125 | steps: 126 | - id: '1270.1' 127 | setup: 128 | watchers: 129 | - ./student_info.sh 130 | - id: '1280' 131 | steps: 132 | - id: '1280.1' 133 | setup: 134 | watchers: 135 | - ./student_info.sh 136 | - id: '1290' 137 | steps: 138 | - id: '1290.1' 139 | setup: 140 | watchers: 141 | - ../pg.log 142 | - id: '1300' 143 | steps: 144 | - id: '1300.1' 145 | setup: 146 | watchers: 147 | - ../pg.log 148 | - id: '1310' 149 | steps: 150 | - id: '1310.1' 151 | setup: 152 | watchers: 153 | - ../pg.log 154 | - id: '1320' 155 | steps: 156 | - id: '1320.1' 157 | setup: 158 | watchers: 159 | - ../pg.log 160 | - id: '1330' 161 | steps: 162 | - id: '1330.1' 163 | setup: 164 | watchers: 165 | - ../pg.log 166 | - id: '1340' 167 | steps: 168 | - id: '1340.1' 169 | setup: 170 | watchers: 171 | - ../pg.log 172 | - id: '1360' 173 | steps: 174 | - id: '1360.1' 175 | setup: 176 | watchers: 177 | - ./student_info.sh 178 | - id: '1370' 179 | steps: 180 | - id: '1370.1' 181 | setup: 182 | watchers: 183 | - ../.bash_history 184 | - id: '1380' 185 | steps: 186 | - id: '1380.1' 187 | setup: 188 | watchers: 189 | - ./student_info.sh 190 | - id: '1390' 191 | steps: 192 | - id: '1390.1' 193 | setup: 194 | watchers: 195 | - ../pg.log 196 | - id: '1400' 197 | steps: 198 | - id: '1400.1' 199 | setup: 200 | watchers: 201 | - ../pg.log 202 | - id: '1410' 203 | steps: 204 | - id: '1410.1' 205 | setup: 206 | watchers: 207 | - ../pg.log 208 | - id: '1420' 209 | steps: 210 | - id: '1420.1' 211 | setup: 212 | watchers: 213 | - ../pg.log 214 | - id: '1430' 215 | steps: 216 | - id: '1430.1' 217 | setup: 218 | watchers: 219 | - ../pg.log 220 | - id: '1440' 221 | steps: 222 | - id: '1440.1' 223 | setup: 224 | watchers: 225 | - ../pg.log 226 | - id: '1450' 227 | steps: 228 | - id: '1450.1' 229 | setup: 230 | watchers: 231 | - ./student_info.sh 232 | - id: '1460' 233 | steps: 234 | - id: '1460.1' 235 | setup: 236 | watchers: 237 | - ../.bash_history 238 | - id: '1470' 239 | steps: 240 | - id: '1470.1' 241 | setup: 242 | watchers: 243 | - ./student_info.sh 244 | - id: '1480' 245 | steps: 246 | - id: '1480.1' 247 | setup: 248 | watchers: 249 | - ../pg.log 250 | - id: '1490' 251 | steps: 252 | - id: '1490.1' 253 | setup: 254 | watchers: 255 | - ../pg.log 256 | - id: '1500' 257 | steps: 258 | - id: '1500.1' 259 | setup: 260 | watchers: 261 | - ../pg.log 262 | - id: '1510' 263 | steps: 264 | - id: '1510.1' 265 | setup: 266 | watchers: 267 | - ../pg.log 268 | - id: '1520' 269 | steps: 270 | - id: '1520.1' 271 | setup: 272 | watchers: 273 | - ../pg.log 274 | - id: '1530' 275 | steps: 276 | - id: '1530.1' 277 | setup: 278 | watchers: 279 | - ../pg.log 280 | - id: '1540' 281 | steps: 282 | - id: '1540.1' 283 | setup: 284 | watchers: 285 | - ./student_info.sh 286 | - id: '1550' 287 | steps: 288 | - id: '1550.1' 289 | setup: 290 | watchers: 291 | - ../.bash_history 292 | - id: '1560' 293 | steps: 294 | - id: '1560.1' 295 | setup: 296 | watchers: 297 | - ./student_info.sh 298 | - id: '1570' 299 | steps: 300 | - id: '1570.1' 301 | setup: 302 | watchers: 303 | - ../pg.log 304 | - id: '1580' 305 | steps: 306 | - id: '1580.1' 307 | setup: 308 | watchers: 309 | - ../pg.log 310 | - id: '1590' 311 | steps: 312 | - id: '1590.1' 313 | setup: 314 | watchers: 315 | - ../pg.log 316 | - id: '1600' 317 | steps: 318 | - id: '1600.1' 319 | setup: 320 | watchers: 321 | - ../pg.log 322 | - id: '1610' 323 | steps: 324 | - id: '1610.1' 325 | setup: 326 | watchers: 327 | - ../pg.log 328 | - id: '1620' 329 | steps: 330 | - id: '1620.1' 331 | setup: 332 | watchers: 333 | - ../pg.log 334 | - id: '1630' 335 | steps: 336 | - id: '1630.1' 337 | setup: 338 | watchers: 339 | - ../pg.log 340 | - id: '1640' 341 | steps: 342 | - id: '1640.1' 343 | setup: 344 | watchers: 345 | - ../pg.log 346 | - id: '1650' 347 | steps: 348 | - id: '1650.1' 349 | setup: 350 | watchers: 351 | - ../pg.log 352 | - id: '1670' 353 | steps: 354 | - id: '1670.1' 355 | setup: 356 | watchers: 357 | - ../pg.log 358 | - id: '1680' 359 | steps: 360 | - id: '1680.1' 361 | setup: 362 | watchers: 363 | - ../pg.log 364 | - id: '1690' 365 | steps: 366 | - id: '1690.1' 367 | setup: 368 | watchers: 369 | - ./student_info.sh 370 | - id: '1700' 371 | steps: 372 | - id: '1700.1' 373 | setup: 374 | watchers: 375 | - ../.bash_history 376 | - id: '1710' 377 | steps: 378 | - id: '1710.1' 379 | setup: 380 | watchers: 381 | - ./student_info.sh 382 | - id: '1715' 383 | steps: 384 | - id: '1715.1' 385 | setup: 386 | watchers: 387 | - ../pg.log 388 | - id: '1720' 389 | steps: 390 | - id: '1720.1' 391 | setup: 392 | watchers: 393 | - ../pg.log 394 | - id: '1730' 395 | steps: 396 | - id: '1730.1' 397 | setup: 398 | watchers: 399 | - ../pg.log 400 | - id: '1740' 401 | steps: 402 | - id: '1740.1' 403 | setup: 404 | watchers: 405 | - ../pg.log 406 | - id: '1750' 407 | steps: 408 | - id: '1750.1' 409 | setup: 410 | watchers: 411 | - ../pg.log 412 | - id: '1760' 413 | steps: 414 | - id: '1760.1' 415 | setup: 416 | watchers: 417 | - ../pg.log 418 | - id: '1770' 419 | steps: 420 | - id: '1770.1' 421 | setup: 422 | watchers: 423 | - ./student_info.sh 424 | - id: '1780' 425 | steps: 426 | - id: '1780.1' 427 | setup: 428 | watchers: 429 | - ../.bash_history 430 | - id: '1790' 431 | steps: 432 | - id: '1790.1' 433 | setup: 434 | watchers: 435 | - ./student_info.sh 436 | - id: '1800' 437 | steps: 438 | - id: '1800.1' 439 | setup: 440 | watchers: 441 | - ../pg.log 442 | - id: '1810' 443 | steps: 444 | - id: '1810.1' 445 | setup: 446 | watchers: 447 | - ../pg.log 448 | - id: '1820' 449 | steps: 450 | - id: '1820.1' 451 | setup: 452 | watchers: 453 | - ../pg.log 454 | - id: '1830' 455 | steps: 456 | - id: '1830.1' 457 | setup: 458 | watchers: 459 | - ../pg.log 460 | - id: '1835' 461 | steps: 462 | - id: '1835.1' 463 | setup: 464 | watchers: 465 | - ../pg.log 466 | - id: '1840' 467 | steps: 468 | - id: '1840.1' 469 | setup: 470 | watchers: 471 | - ./student_info.sh 472 | - id: '1850' 473 | steps: 474 | - id: '1850.1' 475 | setup: 476 | watchers: 477 | - ../.bash_history 478 | - id: '1860' 479 | steps: 480 | - id: '1860.1' 481 | setup: 482 | watchers: 483 | - ./student_info.sh 484 | - id: '1870' 485 | steps: 486 | - id: '1870.1' 487 | setup: 488 | watchers: 489 | - ../pg.log 490 | - id: '1880' 491 | steps: 492 | - id: '1880.1' 493 | setup: 494 | watchers: 495 | - ../pg.log 496 | - id: '1890' 497 | steps: 498 | - id: '1890.1' 499 | setup: 500 | watchers: 501 | - ../pg.log 502 | - id: '1900' 503 | steps: 504 | - id: '1900.1' 505 | setup: 506 | watchers: 507 | - ../pg.log 508 | - id: '1910' 509 | steps: 510 | - id: '1910.1' 511 | setup: 512 | watchers: 513 | - ../pg.log 514 | - id: '1920' 515 | steps: 516 | - id: '1920.1' 517 | setup: 518 | watchers: 519 | - ../pg.log 520 | - id: '1930' 521 | steps: 522 | - id: '1930.1' 523 | setup: 524 | watchers: 525 | - ../pg.log 526 | - id: '1940' 527 | steps: 528 | - id: '1940.1' 529 | setup: 530 | watchers: 531 | - ./student_info.sh 532 | - id: '1950' 533 | steps: 534 | - id: '1950.1' 535 | setup: 536 | watchers: 537 | - ../.bash_history 538 | - id: '1960' 539 | steps: 540 | - id: '1960.1' 541 | setup: 542 | watchers: 543 | - ./student_info.sh 544 | - id: '1970' 545 | steps: 546 | - id: '1970.1' 547 | setup: 548 | watchers: 549 | - ../pg.log 550 | - id: '1980' 551 | steps: 552 | - id: '1980.1' 553 | setup: 554 | watchers: 555 | - ../pg.log 556 | - id: '1990' 557 | steps: 558 | - id: '1990.1' 559 | setup: 560 | watchers: 561 | - ../pg.log 562 | - id: '2000' 563 | steps: 564 | - id: '2000.1' 565 | setup: 566 | watchers: 567 | - ../pg.log 568 | - id: '2010' 569 | steps: 570 | - id: '2010.1' 571 | setup: 572 | watchers: 573 | - ../pg.log 574 | - id: '2020' 575 | steps: 576 | - id: '2020.1' 577 | setup: 578 | watchers: 579 | - ../pg.log 580 | - id: '2030' 581 | steps: 582 | - id: '2030.1' 583 | setup: 584 | watchers: 585 | - ../pg.log 586 | - id: '2040' 587 | steps: 588 | - id: '2040.1' 589 | setup: 590 | watchers: 591 | - ../pg.log 592 | - id: '2050' 593 | steps: 594 | - id: '2050.1' 595 | setup: 596 | watchers: 597 | - ../pg.log 598 | - id: '2060' 599 | steps: 600 | - id: '2060.1' 601 | setup: 602 | watchers: 603 | - ../pg.log 604 | - id: '2070' 605 | steps: 606 | - id: '2070.1' 607 | setup: 608 | watchers: 609 | - ../pg.log 610 | - id: '2075' 611 | steps: 612 | - id: '2075.1' 613 | setup: 614 | watchers: 615 | - ../pg.log 616 | - id: '2080' 617 | steps: 618 | - id: '2080.1' 619 | setup: 620 | watchers: 621 | - ../pg.log 622 | - id: '2090' 623 | steps: 624 | - id: '2090.1' 625 | setup: 626 | watchers: 627 | - ./student_info.sh 628 | - id: '2100' 629 | steps: 630 | - id: '2100.1' 631 | setup: 632 | watchers: 633 | - ../.bash_history 634 | - id: '2110' 635 | steps: 636 | - id: '2110.1' 637 | setup: 638 | watchers: 639 | - ./student_info.sh 640 | - id: '2120' 641 | steps: 642 | - id: '2120.1' 643 | setup: 644 | watchers: 645 | - ../pg.log 646 | - id: '2130' 647 | steps: 648 | - id: '2130.1' 649 | setup: 650 | watchers: 651 | - ../pg.log 652 | - id: '2140' 653 | steps: 654 | - id: '2140.1' 655 | setup: 656 | watchers: 657 | - ../pg.log 658 | - id: '2150' 659 | steps: 660 | - id: '2150.1' 661 | setup: 662 | watchers: 663 | - ../pg.log 664 | - id: '2160' 665 | steps: 666 | - id: '2160.1' 667 | setup: 668 | watchers: 669 | - ../pg.log 670 | - id: '2170' 671 | steps: 672 | - id: '2170.1' 673 | setup: 674 | watchers: 675 | - ../pg.log 676 | - id: '2180' 677 | steps: 678 | - id: '2180.1' 679 | setup: 680 | watchers: 681 | - ../pg.log 682 | - id: '2190' 683 | steps: 684 | - id: '2190.1' 685 | setup: 686 | watchers: 687 | - ../pg.log 688 | - id: '2200' 689 | steps: 690 | - id: '2200.1' 691 | setup: 692 | watchers: 693 | - ../pg.log 694 | - id: '2210' 695 | steps: 696 | - id: '2210.1' 697 | setup: 698 | watchers: 699 | - ../pg.log 700 | - id: '2220' 701 | steps: 702 | - id: '2220.1' 703 | setup: 704 | watchers: 705 | - ../pg.log 706 | - id: '2230' 707 | steps: 708 | - id: '2230.1' 709 | setup: 710 | watchers: 711 | - ../pg.log 712 | - id: '2240' 713 | steps: 714 | - id: '2240.1' 715 | setup: 716 | watchers: 717 | - ../pg.log 718 | - id: '2245' 719 | steps: 720 | - id: '2245.1' 721 | setup: 722 | watchers: 723 | - ../pg.log 724 | - id: '2250' 725 | steps: 726 | - id: '2250.1' 727 | setup: 728 | watchers: 729 | - ../pg.log 730 | - id: '2260' 731 | steps: 732 | - id: '2260.1' 733 | setup: 734 | watchers: 735 | - ../pg.log 736 | - id: '2265' 737 | steps: 738 | - id: '2265.1' 739 | setup: 740 | watchers: 741 | - ../pg.log 742 | - id: '2270' 743 | steps: 744 | - id: '2270.1' 745 | setup: 746 | watchers: 747 | - ../pg.log 748 | - id: '2280' 749 | steps: 750 | - id: '2280.1' 751 | setup: 752 | watchers: 753 | - ../pg.log 754 | - id: '2290' 755 | steps: 756 | - id: '2290.1' 757 | setup: 758 | watchers: 759 | - ../pg.log 760 | - id: '2310' 761 | steps: 762 | - id: '2310.1' 763 | setup: 764 | watchers: 765 | - ./student_info.sh 766 | - id: '2320' 767 | steps: 768 | - id: '2320.1' 769 | setup: 770 | watchers: 771 | - ../.bash_history 772 | - id: '2330' 773 | steps: 774 | - id: '2330.1' 775 | setup: 776 | watchers: 777 | - ./student_info.sh 778 | - id: '2340' 779 | steps: 780 | - id: '2340.1' 781 | setup: 782 | watchers: 783 | - ../pg.log 784 | - id: '2350' 785 | steps: 786 | - id: '2350.1' 787 | setup: 788 | watchers: 789 | - ../pg.log 790 | - id: '2360' 791 | steps: 792 | - id: '2360.1' 793 | setup: 794 | watchers: 795 | - ../pg.log 796 | - id: '2370' 797 | steps: 798 | - id: '2370.1' 799 | setup: 800 | watchers: 801 | - ../pg.log 802 | - id: '2390' 803 | steps: 804 | - id: '2390.1' 805 | setup: 806 | watchers: 807 | - ../pg.log 808 | - id: '2400' 809 | steps: 810 | - id: '2400.1' 811 | setup: 812 | watchers: 813 | - ../pg.log 814 | - id: '2410' 815 | steps: 816 | - id: '2410.1' 817 | setup: 818 | watchers: 819 | - ../pg.log 820 | - id: '2420' 821 | steps: 822 | - id: '2420.1' 823 | setup: 824 | watchers: 825 | - ./student_info.sh 826 | - id: '2430' 827 | steps: 828 | - id: '2430.1' 829 | setup: 830 | watchers: 831 | - ../.bash_history 832 | - id: '2440' 833 | steps: 834 | - id: '2440.1' 835 | setup: 836 | watchers: 837 | - ./student_info.sh 838 | - id: '2450' 839 | steps: 840 | - id: '2450.1' 841 | setup: 842 | watchers: 843 | - ./student_info.sh 844 | - id: '2460' 845 | steps: 846 | - id: '2460.1' 847 | setup: 848 | watchers: 849 | - ../.bash_history 850 | --------------------------------------------------------------------------------