SME Database Notes
SME Database Notes
Database structure
A database can be stored on remote servers so multiple users can access it at the same time,
useful for online systems
An example of a record in the cars table is '2, Mazda, MX5, Blue, 17995'
Relational databases
o is easier to maintain
A primary key is a unique field that can be used to identify a record in a table
A foreign key is a field in a table that refers to the primary key in another table.
A foreign key is used to link tables and create relationships
In the orders table customer_id is a foreign key - it links an order back to the customer that
made the order in the customer table
o Date/Time
o Currency
o car_id: numerical
o make: alphanumerical
o model: alphanumerical
o colour: alphanumerical
o price: currency
cars
o Length check
o Type check
o Range check
o Presence check
There can be occasions where more than one type of validation will be used
on a field
Type check
Check the data type of a field
Range check
Ensures the data entered as a number falls within a particular range
An example is checking a user's age has been entered and falls between the
digits of 0-100
Presence check
Looks to see if any data has been entered in a field
An example is checking that a user has entered a name when registering for a
website
What is sorting?
Sorting is a crucial function in databases that helps organise and present data in a meaningful
way
You can sort data based on a single criterion - such as by name, date, or numerical value
For example, you might sort a list of customers in ascending order by their last names
o Click on the "Sort Ascending" or "Sort Descending" button in the toolbar at the top of
the screen
For instance, you might want to sort a list of customers first by LastName (ascending), and
within each LastName, by City (descending)
To sort the customer's table first by City, and then by LastName within each city:
o Click on the 'Advanced' button in the Sort & Filter section above
o Add the first column to sort data by, by dragging in to the QBE grid and from the sort
row choose ascending or descending
Ascending Order - Data is sorted from smallest to largest (e.g., from A to Z, or from 1 to 100)
Descending Order - Data is sorted from largest to smallest (e.g., from Z to A, or from 100 to 1)
Searching
What is searching?
Searching is the process of using keywords, phrases or criteria to find specific
information within a database
For example, you might want to select all customers from a specific county
o For instance, if you're looking for customers from a specific county, drag
the County field
o In the Criteria row under this field, type the value you're looking for (e.g., 'Devon')
E.g. to return all customers from London who purchased in the last 30 days:
o Follow the steps above to start a new query and add the City field with 'London' as the
criteria
o For example, if you're looking for customers who purchased in the last month, drag
the LastPurchaseDate field
o Hit run
LIKE - Returns true if the value matches a pattern (used with wildcards)
>, <, =, >=, <=, <> - These are comparison operators, they return true if the comparison between
the values is correct
Wildcards are used with the LIKE operator to search for patterns
o * - Represents all
o Start a new query and drag the field you want to query to the QBE grid
o For example, if you're looking for customers whose names start with 'L', drag
the LastName field
o Hit run
Searching a database using a wildcard function
Outputs
Database outputs
What is a database output?
A database output is often done through reports
Reports should display all the required data and labels in full
For example, if you're creating a sales report, it should include all relevant fields,
like product name, quantity sold, and total sales
o This is typically where you would put the report title and other introductory
information
Report footer
o This appears at the end of the report
Page header
Page footer
o This might also contain the page number and the date
For example, you might choose a tabular format, where data is arranged in rows
and columns, or a columnar format, where each data field is listed vertically
For example, a total sales field might be displayed with two decimal places and a
currency symbol