Database Programming
Database Programming
Chapter1 summary
dBase was one of the first database management systems for microcomputers. The four major
components of dBase management systems are the core database engine, form engine, query
system and the programming language that ties it all together.
In 15 years dBase has evolved from a command-driven MS-DOS environment to an
event-driven windows visual IDE.
dBase .dbf file is widely used in applications requiring a simple format to store structured data.
dBase object oriented features can be used to build applications like
1. Server based web application
2. Windows rich client application
3. Middleware application.
Questions
1. Question: What are the four major components of dBase management systems?
a. Data manipulation, form design, query language, programming language
b. Core database engine, form engine, query system, programming language **
c. File storage, user interface, indexing system, scripting language
d. Table structure, form builder, report generator, graphical interface
2. Question: In what environment did dBase initially operate before evolving into an event-driven
Windows visual IDE?
a. Linux command line
b. MS-DOS command-driven environment **
c. macOS graphical interface
d. Unix-based terminal
3. Question: What type of file format is widely used in applications requiring a simple structure to
store structured data in dBase?
a. .csv
b. .txt
c. .dbf **
d. .xml
5. Question: Which technology does dBase utilize to access data in most modern database
engines such as Paradox, MS Access, and FoxPro?
a. Java Database Connectivity (JDBC)
b. File Transfer Protocol (FTP)
c. Open Database Connectivity (ODBC) drivers **
d. Structured Query Language (SQL)
6. Question: In dBase, what is the primary purpose of the core database engine?
a. Generating reports
b. Executing queries
c. Managing the data storage and retrieval **
d. Designing forms
7. Question: What language is used as a standard for accessing data in dBase when using
Open Database Connectivity (ODBC) drivers?
a. Python
b. C++
c. Structured Query Language (SQL) **
d. Java
8. Question: Which component of dBase is responsible for handling the visual design and layout
of user interfaces?
a. Query system
b. Form engine **
c. Programming language
d. Core database engine
10. Question: How has dBase evolved over 15 years in terms of its user interface?
a. It transitioned from a graphical interface to a command-driven environment.
b. It remained a command-driven MS-DOS environment.
c. It evolved from a command-driven MS-DOS environment to an event-driven Windows
visual IDE. **
d. It shifted from a Linux-based terminal to an MS-DOS command-driven environment.
11. Question: Which of the following is NOT a possible use of dBase's object-oriented features?
a. Server-based web application
b. Windows rich client application
c. Mobile application development **
d. Middleware application
12. Question: What role does the programming language in dBase play in the overall system?
a. Managing data storage
b. Form design
c. Tying together core components **
d. Handling visual interface layout
13. Question: Which file format is widely used in applications requiring a simple format to store
structured data in dBase?
a. .xml
b. .csv
c. .txt
d. .dbf **
14. Question: What does dBase use as a standard for accessing data when utilizing Open
Database Connectivity (ODBC) drivers?
a. File Transfer Protocol (FTP)
b. Java Database Connectivity (JDBC)
c. Structured Query Language (SQL) **
d. Python
15. Question: In dBase, what technology does it use to access data in most modern database
engines such as Paradox, MS Access, and FoxPro?
a. Java Database Connectivity (JDBC)
b. Open Database Connectivity (ODBC) drivers **
c. Structured Query Language (SQL)
d. File Transfer Protocol (FTP)
Chapter 6 summary
Data Type
Data types are crucial for informing the compiler or translator about the nature of the data a
variable holds, facilitating proper handling and processing within the program
There are 3 classes of data types and they are COMMON, DATABASE-SPECIFIC, and
PROGRAMMING data types.
1. Common Data Types:
a. Numeric: Represents integer and floating-point numbers.
b. String: A sequence of characters, with the possibility of being empty or null. The
maximum length varies based on storage location.
c. Logical/Boolean: Holds True, False, or Null values.
d. Date: Date data enclosed in curly braces.
e. Null: Represents a non-existent or undefined value, distinct from blank or zero.
Questions
Q5: What is the maximum character limit for Memo fields in dBASE PLUS tables?
A) 128 characters
B) 254 characters **
C) Unlimited characters
D) 512 characters
Q14: Which data type can be assigned to variables or passed as parameters using the
function's name as a pointer?
A) Logical/Boolean
B) Function Pointers **
C) Object Reference
D) Codeblock
Q16: Which data type represents a sequence of characters with the possibility of being empty or
null?
A) Numeric
B) Date
C) String **
D) Logical/Boolean
Q17: What does the Object Reference data type refer to in programming?
A) A data type for handling compiled code
B) A reference to an object **
C) A type for representing dates
D) A data type for storing True or False values
Q18: Which Codeblock data type allows the creation of compiled code without needing a
separate program?
A) Function Codeblocks
B) Expression Codeblocks
C) Statement Codeblocks
D) Object Codeblocks
Q19: In which class of data types would you find the Memo data type?
A) Common Data Types
B) Database-Specific Data Types **
C) Programming Data Types
D) Numeric Data Types
Variables
Variables is a symbolic name that refers to a memory location that is used to store data.
Memory variable is a temporary storage location. It is used to hold data from a table field while it
is altered. It is used to hold values entered by a user until they can be processed, also to hold
data used in many programs and storage of constants frequently in use.
RELEASE, RELEASE ALL and CLEAR ALL are commands used to conserve memory space by
forcing variables that are active to leave the memory.
The CLEAR ALL releases and also closes open files. RELEASE ALL releases variables without
closing files. And the RELEASE is used for specified variables.
Scope of a variable
Private: A private variable can only be accessed in the module where it is initialized and its
subordinate modules. They are available to programs in which they are created and programs
called by the creating program. By default all variables in DBL initialized without a scope are
private. They automatically clear when program execution is complete.
Public: public variables are available to all programs, no matter where they are initialized.They
are sometimes referred to as global variables. they are not automatically cleared when the
program ends, they can be released only by RELEASE and CLEAR ALL commands. By default
all variables initialized in the command window are public.
Local: Local variables are declared as memory variables and they are accessed only in the
subprogram where they are declared.
Static: static variables are memory variables which are declared local in visibility but public in
duration. That is, they are visible only in subprograms where they are declared but are not
automatically cleared when the subprogram ends.they are released using the CLEAR MEMORY
command.
Questions
5. How does CLEAR ALL differ from RELEASE ALL in memory conservation?
- A) CLEAR ALL releases specified variables
- B) RELEASE ALL closes open files
- C) CLEAR ALL releases and closes open files **
- D) RELEASE ALL conserves memory space
7. What is the default scope of variables initialized in dBASE PLUS without specifying a scope?
- A) Public
- B) Local
- C) Private **
- D) Static
8. How are private variables different from public variables in terms of accessibility?
- A) Private variables are accessible globally
- B) Public variables are only accessible in the creating program **
- C) Private variables are accessible in all programs
- D) Public variables are automatically cleared on program completion
13. When is a memory variable used to hold data from a table field?
- A) During memory release
- B) While processing user-entered values **
- C) To alter constants
- D) In global scope only
15. Which command is used to clear memory space in dBASE PLUS and close open files?
- A) CLEAR MEMORY
- B) RELEASE ALL
- C) RELEASE **
- D) CLEAR ALL
17. Which command is used to clear all memory and release specified variables in dBASE
PLUS?
- A) RELEASE
- B) RELEASE ALL
- C) CLEAR ALL
- D) CLEAR MEMORY **
18. In dBASE PLUS, what does a public variable become after program execution is complete?
- A) Cleared automatically **
- B) Local variable
- C) Null variable
- D) Global variable
19. How are local variables different from public variables in terms of accessibility?
- A) Local variables are accessible globally
- B) Public variables are only accessible in the creating program
- C) Local variables are accessible only in the subprogram where declared **
- D) Public variables are accessed in all subprograms
20. When is the CLEAR MEMORY command typically used in dBASE PLUS?
- A) To release public variables
- B) To clear all memory and close open files **
- C) To declare local variables
- D) To alter table fields
Chapter 8 summary
Input and output statements
A major way of data entry in dBASE plus is done using the form-based or the dBASE plus data
objects. Input statements include the GET, INPUT, READ, ACCEPT commands. while READ is
used for reading data from tables, GET, ACCEPT, and INPUT are used for interactive user input,
with ACCEPT and INPUT providing additional capabilities for displaying prompts.
? and ?? commands; the LIST command and DISPLAY command are commands to output
values or write to the command window.
? command is used to display output to the next line of the current output device.
?? command is used to display output to the current cursor location.
LIST command displays records from the current table in the result pane of the
Command window without pausing(continuously until complete). The scope of LIST is ALL.
DISPLAY command displays records from the current table in the result pane of the
command window but pauses after each screenful of information. The scope of DISPLAY is
NEXT 1
Because LIST does not pause between screens, it is more appropriate to use when directing
output to a file or printer.
Questions
1. Which commands are considered input statements in dBASE plus for data entry?
a. ? and ??
b. GET, INPUT, READ, ACCEPT **
c. LIST and DISPLAY
d. WAIT and CLEAR
3. Which command is used to display output to the current cursor location in dBASE plus?
a. LIST
b. DISPLAY
c. ?
d. ?? **
6. Which command is more appropriate for directing output to a file or printer in dBASE plus?
a. LIST **
b. DISPLAY
c. ACCEPT
d. INPUT
8. How does the ? command differ from the ?? command in dBASE plus?
a. ? displays output to the next line, while ?? displays output to the current cursor location. **
b. ?? displays output to the next line, while ? displays output to the current cursor location.
c. Both ? and ?? display output to the next line.
d. Both ? and ?? display output to the current cursor location.
9. Which commands are used for interactive user input in dBASE plus?
a. LIST and DISPLAY
b. ? and ??
c. WAIT and CLEAR
d. GET, INPUT, READ, ACCEPT **
10. What is the primary purpose of the WAIT command in dBASE plus?
a. Displaying output to the next line
b. Clearing the command window
c. Pausing program execution temporarily**
d. Reading data from tables
11. Which command is used to clear the command window in dBASE plus?
a. ??
b. WAIT
c. CLEAR**
d. DISPLAY
12. In dBASE plus, which command is used to display records from the current table
continuously until complete?
a. LIST**
b. DISPLAY
c. ??
d. ACCEPT
14. Which command is suitable for displaying output to the current cursor location in dBASE
plus?
a. LIST
b. DISPLAY
c. ?**
d. ??
15. How does the LIST command behave in terms of pausing between screens in dBASE plus?
a. It pauses after each screenful of information.
b. It does not pause between screens. **
c. It pauses continuously until complete.
d. It pauses only for the first screenful of information.
16. What is the primary purpose of the INPUT command in dBASE plus?
a. Displaying output to the next line
b. Clearing the command window
c. Reading data from tables
d. Providing interactive user input **
17. Which command is used to display output to the next line of the current output device in
dBASE plus?
a. DISPLAY
b. LIST
c. ??
d. ACCEPT
e. None of the above **
Chapter 9 summary
Traditionally, program execution is sequential, that is statements are executed strictly based on
the physical arrangement of the statements in the program.
Questions
1. What is the purpose of the IF ... ENDIF structure in dBASE Plus?
- A) Single-way conditional execution **
- B) Multiple-way conditional execution
- C) Loop iteration
- D) Error handling
3. In dBASE Plus, what does the DO CASE ... ENDCASE structure allow you to do?
- A) Loop through a collection
- B) Execute a block of statements based on a logical expression **
- C) Handle errors
- D) Perform a specific number of iterations
4. Which loop structure in dBASE Plus executes a block of statements as long as a specified
logical expression is true?
- A) FOR ... ENDFOR
- B) DO ... UNTIL
- C) SCAN ... ENDSCAN
- D) DO WHILE ... ENDDO **
5. What is the purpose of the FOR ... ENDFOR loop in dBASE Plus?
- A) Single-way conditional execution
- B) Multiple-way conditional execution
- C) Loop iteration a specific number of times **
- D) Execute statements until a logical expression is true
6. The DO ... UNTIL structure in dBASE Plus executes the statements between DO and UNTIL
as long as the specified logical expression is:
- A) True
- B) False **
- C) Undefined
- D) Both A and B
7. How is the SCAN ... ENDSCAN construct in dBASE Plus commonly used?
- A) Single-way conditional execution
- B) Multiple-way conditional execution
- C) Loop iteration through a collection **
- D) Error handling
8. Which loop structure ensures that the block of statements is executed at least once, even if
the condition is initially true?
- A) DO ... UNTIL **
- B) FOR ... ENDFOR
- C) DO WHILE ... ENDDO
- D) SCAN ... ENDSCAN
11. What is the primary purpose of the DO CASE ... ENDCASE structure in dBASE Plus?
- A) Loop iteration
- B) Single-way conditional execution
- C) Multiple-way conditional execution **
- D) Error handling
12. Which loop structure in dBASE Plus is suitable for iterating through a fixed range of values?
- A) DO WHILE ... ENDDO
- B) FOR ... ENDFOR **
- C) DO ... UNTIL
- D) SCAN ... ENDSCAN
13. The FOR ... ENDFOR structure in dBASE Plus specifies the number of iterations based on:
- A) Logical expression
- B) Fixed range of values **
- C) Error conditions
- D) Dynamic user input
14. In the DO ... UNTIL structure, when does the loop execution stop?
- A) When the specified logical expression is true **
- B) When the specified logical expression is false
- C) When the loop reaches the maximum allowed iterations
- D) When an error occurs
15. What is the primary purpose of the SCAN ... ENDSCAN construct in dBASE Plus?
- A) Loop iteration
- B) Single-way conditional execution
- C) Multiple-way conditional execution **
- D) Error handling