Git, SQL & MongoDB Cheatsheet

A summary of the workflows for A1-1, A1-2, and A1-3, covering Git, Oracle SQL, and MongoDB within VS Code.


A1-1: The Basic Git Workflow (in VS Code)

This is your main cycle for saving and submitting work.

  1. Pull (Start of Day): Always pull before you start working to get the latest files.
    • How: Source Control panel (branch icon) → ... (More Actions) → Pull.
  2. Do Your Work: Edit your files (e.g., applied1_student.sql).
  3. Stage (Add): Tell Git which changes you want to save.
    • How: Source Control panel → Click the + (plus) icon next to your 'M' (Modified) or 'U' (Untracked) files.
  4. Commit (Save Locally): Create a "save point" on your computer.
    • How: Type a meaningful message in the box → Click the ✔️ (checkmark).
    • If it "loops": You forgot the message! Just type your message on line 1 of the COMMIT_EDITMSG file, save it, and close the file tab.
  5. Push (Save to Server): Send your local save point up to GitLab.
    • How: Click the Sync Changes button.
  6. Verify (Crucial!): Log in to the GitLab website to see your files and commits.

A1-2: Oracle (Relational Database)

This is your structured "spreadsheet-style" database.

  • Connect: Go to the SQL Developer icon (🗃️) → Click the plug icon 🔌 next to your connection.
  • Run a Whole .sql File:
    1. Open the .sql file.
    2. Click "No connection" in the bottom status bar and pick your connection.
    3. Click the Run Script icon (▶️📄) in the top-right.
  • Run a Single Command:
    1. Open a new SQL Worksheet (right-click connection → "Open SQL Worksheet").
    2. Type your command.
    3. Click the Run Statement icon (▶️).
  • Refresh View: After you DROP or CREATE a table, right-click "Tables" in the SQL Developer panel and hit Refresh to see the change.

Key SQL Commands

  • SELECT * FROM student; (Get all columns, all rows)
  • WHERE studaddress LIKE '%Moorabbin'; (Filter rows)
  • SELECT studfname, studlname FROM... (Get specific columns)
  • DROP TABLE student CASCADE CONSTRAINTS PURGE; (Delete a table)

A1-3: MongoDB (NoSQL Database)

This is your flexible "document-style" database (like a filing cabinet of JSON files).

  • Connect: Go to the MongoDB icon (🍃) → Click your connection.
  • Create & Run Playground:
    1. Click "Add a new PLAYGROUND".
    2. Save it immediately as your_file.mongodb.js.
    3. Type your commands.
    4. Click the Run icon (▶️) in the top-right to run the whole file.

Key MongoDB Commands

  • use("your_authcate"); (Select your database)
  • db.student.drop(); (Delete a collection)
  • db.student.insertMany( [...] ); (Insert data from a JSON array)
  • db.student.find(); (Get all documents)
  • Query (Filter + Projection): db.student.find( {<filter>} , {<projection>} );
    • Filter: {"address": /.*Moorabbin*./}
    • Projection: {"_id":0, "firstName":1, "lastName":1} (1 = show, 0 = hide)