Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Java Programming Chapter 20: How to work with a Derby database 1. Each record in

ID: 3779976 • Letter: J

Question

Java Programming

Chapter 20: How to work with a Derby database

     1.   Each record in a relational database is called a ________________.

     2.   The fields in a relational database are called ______________________.

     3.   The most common type of relationship between tables in a relational database is a _____________________ relationship.

     4.   You use a _________________ statement to retrieve data from a SQL database.

     5.   The data returned from a query is stored in a table called a ___________________.

     6.   The current row pointer is also called the ___________________.

     7.   An ________________ join combines data from two or more tables in which the related fields must match.

     8.   The ________________ tells the JRE where to look for the class files you create.

     9.   To start the interactive JDBC tool, you need to run the __________ class that’s stored in the derbytools.jar file.

   10.   To connect to an existing Derby database named PayablesDB that’s in the current directory when you use the interactive JDBC tool, you supply this connection string after the connect keyword: ___________________________________

   11.   To create a database, you append ____________________ to the end of the connection string.

   12.   To run a SQL script with the ij tool, you enter the ___________________ command followed by the name of the script file.

   13.   Write a SQL statement that queries a table named Movies and retrieves columns named Title and Year. The query should return only the rows where the Director column is equal to “Hitchcock”. The results should be sorted by the Year field, with the most recent movies listed first.

   14.   Suppose that a database contains two tables, named Movies and Directors. The Movies table has columns named Title, Year, and DirectorID. The Directors table has columns named DirectorID and DirectorName. Write a SQL statement that uses a join to return the title, year, and the name of the director for every movie in the database. Sort the rows by the directors’ names.

   15.   Write a SQL statement that changes the DirectorName column in the Directors table for DirectorID 37 to “Hitchcock”.

Explanation / Answer

1.tuple

2.Attributes

3.relational database

4.Statement

Prepared Statement

Callable Statement

5.ResultSet

6.Cursors

7.Inner Join

8.Classpath

9.ojdbc14.jar

10.$ ij
ij version 10.8
ij>
$ java -cp $DERBY_HOME/lib/derbytools.jar org.apache.derby.tools.ij
ij version 10.8
ij>
$ java -jar $DERBY_HOME/lib/derbyrun.jar ij
ij version 10.8
ij>

11.con.close()

12.ij> RUN 'cars.sql';
ij> SET SCHEMA USER12;
0 rows inserted/updated/deleted
ij> CREATE TABLE CARS(ID INT PRIMARY KEY, NAME VARCHAR(30), PRICE INT);
0 rows inserted/updated/deleted
ij> INSERT INTO CARS VALUES(1, 'Audi', 52642);
1 row inserted/updated/deleted
...

13.select title,year, from movies where director='Hitchcock' order by year

14.select title,year,DirectorName from Movies m, Directors d

where m.DirectorID=d.DirectorID group by DirectorName

15.

alter table Director

add column Hitchcock new-DataType

UPDATE DirectorName SET newtype = Hitcock

ALTER TABLE Director DROP COLUMN DirectorName

RENAME COLUMN DirectorName c1_newtype TO Hitcock

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote