0% found this document useful (0 votes)
54 views3 pages

Python For Informatics Database Handout Download and Install Firefox and The Sqlite Manager

The document provides instructions and examples for using SQLite to manage a database of music information. It includes SQL commands to insert data into tables for users, artists, albums, genres, and tracks. It also shows how to perform queries to select, update, and delete data from the tables and join tables in queries. The bottom section lists the SQL commands to create each table.

Uploaded by

pkincade
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views3 pages

Python For Informatics Database Handout Download and Install Firefox and The Sqlite Manager

The document provides instructions and examples for using SQLite to manage a database of music information. It includes SQL commands to insert data into tables for users, artists, albums, genres, and tracks. It also shows how to perform queries to select, update, and delete data from the tables and join tables in queries. The bottom section lists the SQL commands to create each table.

Uploaded by

pkincade
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Python for Informatics Database Handout

Download and install FireFox and the SQLite Manager

http://www.mozilla.org/en-US/firefox/new/
https://addons.mozilla.org/en-US/firefox/addon/sqlite-manager/

Queries

insert into Users (name, email) values ('Ted', '[email protected]')

delete from Users where email='[email protected]'

update Users set name="Charles" where email='[email protected]'

select * from Users

select * from Users where email='[email protected]'

select * from Users order by email

insert into Artist (name) values ('Led Zepplin')


insert into Artist (name) values ('AC/DC')

insert into Genre (name) values ('Rock')


insert into Genre (name) values ('Metal')

insert into Album (title, artist_id) values ('Who Made Who', 2)


insert into Album (title, artist_id) values ('IV', 1)

insert into Track (title, rating, len, count, album_id, genre_id) values ('Black Dog', 5, 297, 0, 2, 1)
insert into Track (title, rating, len, count, album_id, genre_id) values ('Stairway', 5, 482, 0, 2, 1)
insert into Track (title, rating, len, count, album_id, genre_id) values ('About to Rock', 5, 313, 0, 1, 2)
insert into Track (title, rating, len, count, album_id, genre_id) values ('Who Made Who', 5, 207, 0, 1, 2)

select Track.title, Genre.name from Track join Genre on Track.genre_id = Genre.id


select Track.title, Artist.name, Album.title, Genre.name from Track join Genre join Album join Artist on
Track.genre_id = Genre.id and Track.album_id = Album.id and Album.artist_id = Artist.id
Create Table Statements:

CREATE TABLE "Users" ("name" TEXT, "email" TEXT)

CREATE TABLE "Artist" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE, "name" TEXT)

CREATE TABLE "Album" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE, artist_id INTEGER,"title"
TEXT)

CREATE TABLE "Genre" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE, "name" TEXT)

CREATE TABLE "Track" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE, album_id INTEGER, genre_id
INTEGER, len INTEGER, rating INTEGER, "title" TEXT, "count" INTEGER)

You might also like