Chapter 15: Python and Databases Flashcards
One of the values within a tuple. More commonly called a “column” or “field”.
attribute
When we tell the database to enforce a rule on a field or a row in a table. A common one is to insist that there can be no duplicate values in a particular field (i.e., all the values must be unique).
constraint
Allows you to execute SQL commands in a database and retrieve data from the database. Similar to a socket or file handle for network connections and files, respectively.
cursor
A piece of software that allows you to directly connect to a database and manipulate the database directly without writing a program.
database browser
A numeric key that points to the primary key of a row in another table. Establish relationships between rows stored in different tables.
foreign key
eg, artist_id (foreign key) in Track table links to id (primary key) in Artist table
Additional data that the database software maintains as rows and inserts into a table to make lookups very fast.
index
A key that the “outside world” uses to look up a particular row
eg. in a table of user accounts, a person’s email address might be a good candidate as one for the user’s data
logical key
Designing a data model so that no data is replicated. We store each item of data at one place in the database and reference it elsewhere using a foreign key.
normalization
A numeric key assigned to each row that is used to refer to rows in another table. Often the database is configured to automatically assign them as rows are inserted.
primary key
eg. id (primary key) in Artist table links to artist_id (foreign key) in Track table
An area within a database that contains tuples and attributes. More typically called a “table”.
relation
A single entry in a database table that is a set of attributes. More typically called “row”.
tuple
SQL command that deletes the table and all of its contents from the database.
Can’t be undone
DROP TABLE
DROP TABLE IF EXISTS
method to perform commands on database once cursor is implemented
.execute()
cur.execute(‘SQL KEYWORD table’)
SQL command to make a new table
cur.execute(‘CREATE TABLE table (column TYPE)’)
SQL command to query info from a database
SELECT
SQL keyword to rename column or table
AS
return unique values
DISTINCT
filter results based on specified condition
WHERE
use with WHERE
match closely matching names using wildcard characters
LIKE