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.
- Pull (Start of Day): Always pull before you start working to get the latest files.
- How: Source Control panel (branch icon) →
...(More Actions) → Pull.
- How: Source Control panel (branch icon) →
- Do Your Work: Edit your files (e.g.,
applied1_student.sql). - 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.
- How: Source Control panel → Click the
- 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_EDITMSGfile, save it, and close the file tab.
- How: Type a meaningful message in the box → Click the
- Push (Save to Server): Send your local save point up to GitLab.
- How: Click the Sync Changes button.
- 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
.sqlFile:- Open the
.sqlfile. - Click "No connection" in the bottom status bar and pick your connection.
- Click the Run Script icon (▶️📄) in the top-right.
- Open the
- Run a Single Command:
- Open a new SQL Worksheet (right-click connection → "Open SQL Worksheet").
- Type your command.
- Click the Run Statement icon (▶️).
- Refresh View: After you
DROPorCREATEa 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:
- Click "Add a new PLAYGROUND".
- Save it immediately as
your_file.mongodb.js. - Type your commands.
- 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)
- Filter: