JDBC Flashcards

1
Q

What is a database?

A

An organized collection of data.

A database management system (DBMS) provides mechanisms for storing, organizing, retrieving, and modifying data.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What does DBMS stand for?

A

Database Management System

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is SQL?

A

Structured Query Language, the international standard language used with relational databases to perform queries and manipulate data.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How is ‘SQL’ pronounced?

A

Either ‘sequel’ or as its individual letters.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is JDBC?

A

Java Database Connectivity, an API for Java programs to interact with databases.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the purpose of a JDBC driver?

A

To enable Java applications to connect to a specific database in a DBMS.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is a relational database?

A

A logical representation of data that allows access without consideration of its physical structure, storing data in tables.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What are SQL queries used for?

A

To specify which subsets of data to select from a table.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the primary key in a database?

A

Uniquely identifies each row/record in a database table.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What does the NOT NULL constraint do?

A

Ensures that a column cannot have a NULL value.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the purpose of database normalization?

A

To efficiently organize data in a database by eliminating redundant data and ensuring data dependencies make sense.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What are the main types of SQL commands?

A
  • DDL - Data Definition Language
  • DML - Data Manipulation Language
  • DCL - Data Control Language
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Fill in the blank: A _______ is used to create and retrieve data from the database very quickly.

A

INDEX

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the purpose of the WHERE clause in SQL?

A

To specify selection criteria for a query.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What do the wildcard characters ‘%’ and ‘_’ represent in SQL?

A
  • ’%’ - zero or more characters
  • ‘_’ - a single wildcard character
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What does the ORDER BY clause do?

A

Sorts the rows in the result of a query into ascending or descending order.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What is an INNER JOIN?

A

A SQL operation that merges rows from two tables by matching values in columns common to both tables.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What is the role of the ON clause in an INNER JOIN?

A

Specifies the columns compared to determine which rows are merged.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What is the default value constraint?

A

Provides a default value for a column when none is specified.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

What is a CHECK constraint?

A

Ensures that all values in a column(s) satisfy certain conditions.

21
Q

What does the UNIQUE constraint ensure?

A

That all the values in a column are different.

22
Q

What is the significance of the ‘Authors’ table in the books database?

A

It stores information about authors including FirstName and LastName.

23
Q

What does the ‘Titles’ table store?

A

Information about book titles including ISBN, Title, EditionNumber, and Copyright.

24
Q

What is the relationship between authors and titles in the books database?

A

Stored in the AuthorISBN table, which links authors to their corresponding titles.

25
Q

What is the purpose of using a primary key in a table?

A

To uniquely identify each record in the table.

26
Q

Fill in the blank: The _______ constraint limits the type of data that can go into a table.

A

Constraints

27
Q

What is the first normal form (1NF) in database normalization?

A

A stage of normalization that ensures the table is organized in a way that eliminates duplicate data.

28
Q

True or False: The SQL command ‘INSERT INTO’ is used to add new records to a database.

A

True

29
Q

What is a foreign key?

A

A column that uniquely identifies a row/record in another database table.

30
Q

What is the purpose of a qualified name in SQL?

A

To specify the columns from each table that should be compared to join the tables.

The syntax is used when columns have the same name in both tables.

31
Q

What is the basic form of an INSERT statement?

A

INSERT INTO tableName (column1, column2, …) VALUES (value1, value2, …)

The list of column names is not required if a value for every column is specified in the correct order.

32
Q

What does an UPDATE statement do?

A

Modifies data in a table.

The basic form is UPDATE tableName SET columnName = value.

33
Q

What is the purpose of a DELETE statement in SQL?

A

Removes rows from a table.

The optional WHERE clause specifies which rows to delete.

34
Q

What is MySQL Connector/J?

A

A JDBC driver for MySQL databases distributed as a .zip or .tar.gz archive.

It includes the JAR archive named mysql-connector-java-version-bin.jar.

35
Q

What does JDBC support in terms of driver discovery?

A

Automatic driver discovery.

It loads the database driver into memory automatically.

36
Q

What method is used to connect to a database using JDBC?

A

DriverManager.getConnection()

It takes the database URL, username, and password as arguments.

37
Q

What is the function of the Statement object in JDBC?

A

To submit SQL statements to the database.

It is obtained using the createStatement() method of the Connection object.

38
Q

What does the executeQuery method of the Statement object do?

A

Submits a query and returns a ResultSet containing the query results.

39
Q

What is a ResultSet in JDBC?

A

An object that contains the results of a SQL query.

It provides methods to manipulate the query result.

40
Q

What is the purpose of the ResultSetTableModel class?

A

To provide a TableModel for displaying query results in a JTable.

41
Q

What class is used to sort rows in a JTable?

A

TableRowSorter

It interacts with the underlying TableModel to reorder rows based on column data.

42
Q

What does filtering rows in a JTable refer to?

A

Showing subsets of the data from the underlying TableModel.

43
Q

What are the two types of RowSet objects?

A
  • Connected RowSet
  • Disconnected RowSet
44
Q

What is a JdbcRowSet?

A

A connected RowSet that acts as a wrapper around a ResultSet object.

45
Q

What is a CachedRowSet?

A

A disconnected RowSet that caches data from a ResultSet in memory.

It is scrollable and updatable by default.

46
Q

What is the role of PreparedStatement in JDBC?

A

To create compiled SQL statements that execute more efficiently and allow parameter specification.

47
Q

What do the question marks (?) in a PreparedStatement represent?

A

Placeholders for values that will be passed as part of the query.

48
Q

What is the function of the CallableStatement interface?

A

To invoke stored procedures in a database.

49
Q

What is a stored procedure?

A

A named collection of SQL statements stored in a database.