Database Flashcards
What is a database?
A database is a large collection of data items and links between them, structured in a way that allows it to be accessed by a number of different application programs.
The term is also used loosely to describe any collection of data.
What is a Database Table?
A table is the name for each group of similar data with rows for each instance of an entity and columns for each attribute.
What is a Record?
“[A] Record is the basic unit of data stored in a data file. It is a collection of data items, which may be of different data types, all relating to the individual or object that the record describes and is treated as a unit for processing.”
A record is really a row of data from a database table.
What is a key field?
“[A] Key is the field within a record used to identify the record.”
What is a Field?
[A] Field is part of a record designed to hold a single data item of a specified type.
A record is really a column of data from a database table.
What is a primary key?
A field that uniquely identifies an individual record in a table can be chosen as the Primary Key of the table.
What is a composite key?
A composite key is one that consists of two or more fields
What is a foreign key?
When the primary key from one table appears as a field in a second table, it is known as a Foreign Key of the second table.
Explain how relationships are used in databases.
The way relationships are represented in a relational database involves the use of primary and foreign keys. If the primary key of one table appears as a foreign key in a second table, then we say that there is a relationship or a link between the two tables.
We can see which individual athletes are related to which individual events by cross referencing the values in the respective foreign and primary key fields
Definition of a data type
“[A] data type is a formal description of the kind of data being stored or manipulated within a program or system, for example CHAR (N), REAL or DATE
Explain the data type - CHAR(N)
CHAR(N) is string data type, whose values are constrained to have exactly N
characters. For example the following are all CHAR(4): “Fred”, “Fre ”, “Fr d”, “1234”.
Explain the data type - TEXT
TEXT is a string data type, whose values may have a variable numer of characters.
For example: “Fred”, Fre”, “Fr”, “F”, “Fred12345”.
Explain the data type - ENUM
ENUM is a string data type, whose values are constrained to be one of a list of
permitted values
Explain the data type -INT
INT is a numeric data type that can store whole numbers – which may be either
positive or negative. For example: 0, 1, 2, -99.
Explain the data type - REAL
REAL is a numeric data type that can store numbers with decimal places. For example:
1, 2.718, 3.141, -2.718, -3.141
Explain the data type - TIME
Time is a data type that can store time values (hours, minutes & seconds). For
example, 03:15:00 (quarter past 3 am)
Explain the data type - DATE
DATE is a data type that can store dates. The display format can be specified – e.g.
1/1/2017, 1 Jan 2017.
Explain the data type - BOOLE
BOOLE is a data type that can store the values TRUE and FALSE
What is data validation?
If incorrect data is entered into a database, the system will be less useful: in some instances it may even be dangerous.
For example, a well designed system ought to be able to prevent a user entering text data into a field that has been designed to store numeric data.
Validation is the automatic checking of data entered into a computer system.
Validation uses the properties of the data to identify any inputs that are obviously wrong.
Explain the validation check- Presence Checks
It would be meaningless, for example, to attempt a bank withdrawal without specifying an account number. Consequently any form that enables the user to make such a withdrawal must ensure that the account number field is not left blank. This is an example of a presence check.
Explain the validation check- Format Checks
Some data values are required to conform to given patterns. For example, UK post codes consist of two letters followed by three digits, followed by two letters. Consequently any relevant data entry form should check for this, and reject ill-formed postcodes. This is an example of a format check
Explain the validation check- Length Checks
The number of characters in a name can vary, but it is difficult to imagine one that is less than three
characters long – or one that is more than twenty characters long. It would be reasonable to reject any
attempted data entry that contains a name that is outside these limits. This is an example of a length check.
Explain the validation check- Type Checks
In a database that records the number of books in a bookstore, it would be strange to record a fractional number such as 36.4. Consequently any relevant data entry form should ensure that no fractional values are accepted. This is an example of a type check
Explain the validation check- Range Checks
Human adults come in a range of heights, but it is difficult to imagine anyone shorter than (say) two feet or taller than (say) ten feet. It would be reasonable to reject any attempted data entry contains a height that falls outside of this range. This is an example of a range check
What is a logical operator?
Comparing a value against other data is a typical operation when data is queried in a database.
Comparison operators allow this to be done. e.g. the comparison operator < indicates that the data entered must be less than a specified value for the result to be correct.
Also used to analyse to values and return a true or false result.
What is a form?
Forms are a common way to collect data from people, they can be used to enter a new record, modify an existing record or view records already stored in the table.
When data is entered into a form, it is automatically added into the specified table and stored as part of the database.
Advantages of forms
When there are a number of different tables in a database, forms make it easier to enter data as one form may include fields from different tables.
When the user enters data into the form the database software will ensure the data is stored in the correct table.
They can be used to control the type and format of the data ensuring that it is kept consistent and accurate.
Forms can also be customised to include a logo and colour.
What is a Query?
A query is a way of searching and extracting data from a database to find the answer to a question.
The query/search checks each record and produces a list of data that satisfies the query criteria.
To create a query, criteria are added to one or more fields in the table.
What is a Report?
A report allows tables and results from queries to be presented in user-friendly way.
The layout of the report can be customised, making it visually attractive and easy to read for the intended person or organisation.
The data can also be presented by grouping similar data or sorting it in ascending or descending order.
What is a Macro?
A macro is a small program written to perform a repetitive database task automatically.
What is a data dictionary?
Used by system designers to plan formatting for databases. They store : contents, format, structure and relationships.
Typically it will include names, descriptions, fields, record info on data types, length of each field and validation used