Project 1
1. Click on the following link to open the Online SQL Editor.
2. Click on File>Open DB and select the file “emptyDb.db” in ClassesICT
3. Create the table celebs
just like in the example, with three columns:
id
that storesINTEGER
;name
that storesTEXT
;age
that storesINTEGER
.
You need to erase the previous query before writing a new one
Once you are happy with your query, you should copy/paste it in the Word document Project 1
and erase it from the Online Editor.
If you just add some queries and run your code, it will execute the previous query again, which can be a problem when you want to only do something once (like creating a table or adding a record).
You can find the history of all your queries on sqliteonline by clicking on this bottom right button:
And then selecting History
:
4. Add 4 celebrities to the celebs
table:
Justin Bieber
who is23
and has theid
of1
.Beyonce Knowles
who is34
and has theid
of2
.Jeremy Lin
who is27
and has theid
of3
.Taylor Swift
who is27
and has theid
of4
.
Important
Each time you change something to your table, use the command:
SELECT * FROM celebs;
to check the result.
5. Use a SELECT
to retrieve all the names from the celebs
table.
6. Add a new column named twitter_handle
to the table.
7. Update the table to include Taylor Swift’s twitter handle: @taylorswift13
.
8. Delete all of the rows that have a NULL
value in the twitter handle column.
9. Create a new table awards
with constraints on the values:
id
should acceptINTEGER
and is aPRIMARY KEY
;recipient
should acceptTEXT
and should beNOT NULL
;award_name
should acceptTEXT
and should have a default value equal toGrammy
.