First, load the tables into sqlite3. If you're on Windows or Mac OS X (Mavericks or older), use the following command:
$ ./sqlite3 --init lab12.sql
If you're on Ubuntu or Mac OS X (Yosemite or newer), use:
$ sqlite3 --init lab12.sql
Before we start, inspect the schema of the tables that we've created for you:
sqlite> .schema
A schema tells you the name of each of our tables and their attributes. In general, you can think of a schema as a map that describes the logical entities and relationships of a database. Just as the outline of a book tells a reader the order and category in which content is organized, a schema details the organizational hierarchy of information within a database.
Let's also take a look at some of the entries in our table. There are a lot of entries though, so let's just output the first 20:
sqlite> SELECT * FROM students LIMIT 20;
If you're curious about some of the answers students put into the Google form, open up data.sql in your favorite text editor and take a look!
For each of the SQL queries below, decide to yourself and/or your partner what the query is looking for, then try running the query yourself and see!
sqlite> SELECT * FROM students; -- This is a comment. * is shorthand for all columns!
______
sqlite> SELECT color FROM students WHERE number = 16;
______
sqlite> SELECT song, pet FROM students WHERE color = "blue" AND date = "12/25";
1,sqlite> SELECT color FROM students WHERE number = 16;
Ans: This query will display all the colors in table "students" which have value of number as 16.
2.sqlite> SELECT song, pet FROM students WHERE color = "blue" AND date = "12/25";
Ans: This will display all songs and pet value pair from table students where color is "blue" and date is "12/25"
**If you have any query , please feel free to comment
with details.
**Happy learning :)
First, load the tables into sqlite3. If you're on Windows or Mac OS X (Mavericks or...
Question 5: Sevens Let's take a look at data from both of our tables, students and checkboxes, to find out if students that got the number 7 assigned to them also chose '7' for the obedience question. Specifically, we want to look at the students that fulfill the below conditions and see if they also chose '7' in the question that asked students to choose the number 7 (column seven in students). reported that their favorite number (column number in...
Question 1.Write a SQL statement for each of the following questions based on the above tables (50 Points). 1) Create “Enrollment” table. 2) Change the credits of “Database” course from 2 to 3. 3) List the course titles (not Course_No) and grades John Doe had taken. 4) Calculate average of Café Balance, and name new field as Average Balance. 5) Create a roster for “Database” course (list student ID, last name, first name, major, and status for each student enrolled...
Overview: Database management plays an integral role in nearly every area of business. Databases house customer, accounting, and employee data, and these different data sets must all be efficiently managed in order to make the data accessible. Companies rely on database engineers to ensure that their records are accurate, updated, and tracked in real time. This course covers structured query language (SQL) and how it can be used to manage database schemas, manipulate data, and analyze data. For your final...