Computer science fundamentals · Lesson 47 of 60 · Concept lesson · Optional
Database fundamentals
A relational database stores data in tables of rows and columns, and relationships link rows in one table to rows in another.
SQL is the language for asking questions of a relational database, such as selecting the rows that match a condition.
NoSQL databases store data in other shapes, such as documents or key-value pairs, and trade some structure for flexibility.
Picture it
Code example
import sqlite3
db = sqlite3.connect(":memory:")
db.execute("CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT)")
db.execute("INSERT INTO users (name) VALUES ('Ada'), ('Mia')")
for row in db.execute("SELECT name FROM users WHERE id = 2"):
print(row[0])Output: Mia
SQL creates a table, adds rows and selects the row whose id is 2. Python's built-in sqlite3 runs it.
Check yourself
Pick an answer for each question. You can retry as many times as you like.
Loading the questions…