Professional Documents
Culture Documents
Cala Computers Christiana Nhanga
Cala Computers Christiana Nhanga
What is Database?
A database is a systematic collection of data. They support electronic storage and manipulation
of data. Databases make data management easy.
Let us discuss a database example: An online telephone directory uses a database to store data of
people, phone numbers, and other contact details. Your electricity service provider uses a
database to manage billing, client-related issues, handle fault data, etc.
Databases are useful in many different scenarios for storing data. It is typical to use a database when
different sets of data needs to be linked together, such as:
The three main advantages that databases have over other, simpler data storage systems (such as text
files and spreadsheets) are access, integrity, and security.
They store data and provide facilities (tools) to search for specific records in a given set of data.
They store special information used to manage the data. This information is called metadata and it is not
shown to all the people looking at the data.
They can solve cases where many users want to access (and possibly change) the same entries of data.
They manage access rights (who is allowed to see the data, who can change it)
When there are many users asking questions to the database, the questions must be answered faster. In
this way, the last person to ask a question can get an answer in a reasonable time.
Certain attributes are more important than others and can be used to find other data. This is called
indexing. An index contains all the important data and can be used to find other data.
They ensure that the data always has context. There are a lot of different rules that can be added to tell
the database system if the data makes sense. One of the rules might say November has 30 days. This
means if someone wants to enter November 31 as a date, this change will be rejected.
Databases are used for storing, maintaining and accessing any sort of data. They collect
information on people, places or things. That information is gathered in one place so that it can
be observed and analyzed. Databases can be thought of as an organized collection of
information.
2. In databases, users input different kinds of data. Give any 5 datatypes and
Data type is an attribute associated with a piece of data that tells a computer system how to interpret its
value. Understanding data types ensures that data is collected in the preferred format and the value of
each property is as expected.
A data type, in programming, is a classification that specifies which type of value a variable has and what
type of mathematical, relational or logical operations can be applied to it without causing an error. A
string, for example, is a data type that is used to classify text and an integer is a data type used to
classify whole numbers.
A data type is a classification of data which tells the compiler or interpreter how the programmer
intends to use the data. Most programming languages support various types of data, including integer,
real, character or string, and Boolean
Integer (int)
It is the most common numeric data type used to store numbers without a fractional component (-707,
0, 707).
Floating Point (float)
It is also a numeric data type used to store numbers that may have a fractional component like
monetary values do (707.07, 0.7, 707.00).
Please note that number is often used as a data type that includes both int and float types.
Character (char)
It is used to store a single letter, digit, punctuation mark, symbol, or blank space.
It is a sequence of characters and the most commonly used data type to store text. Additionally, a string
can also include digits and symbols, however, it is always treated as text.
A phone number is usually stored as a string (+1-999-666-3333) but can also be stored as an integer
(9996663333).
Boolean (bool)
It represents the values true and false. When working with the boolean data type, it is helpful to keep in
mind that sometimes a boolean value is also represented as 0 (for false) and 1 (for true).
It contains a small set of predefined unique values (also known as elements or enumerators) that can be
compared and assigned to a variable of enumerated data type.
The values of an enumerated type can be text-based or numerical. In fact, the boolean data type is a
pre-defined enumeration of the values true and false.
For example, if rock and jazz are the enumerators, an enumerated type variable genre can be assigned
either of the two values, but not both.
Assuming that you are asked to fill in your preferences on a music app and are asked to choose either
one of the two genres via a dropdown menu, the variable genre will store either rock or jazz.
With enumerated type, values can be stored and retrieved as numeric indices (0, 1, 2) or strings.
Array
Also known as a list, an array is a data type that stores a number of elements in a specific order, typically
all of the same type.
Since an array stores multiple elements or values, the structure of data stored by an array is referred to
as an array data structure.
Each element of an array can be retrieved using an integer index (0, 1, 2,…), and the total number of
elements in an array represents the length of an array.
For example, an array variable genre can store one or more of the elements rock, jazz, and blues. The
indices of the three values are 0 (rock), 1 (jazz), and 2 (blues), and the length of the array is 3 (since it
contains three elements).
Continuing on the example of the music app, if you are asked to choose one or more of the three genres
and you happen to like all three (cheers to that), the variable genre will store all three elements (rock,
jazz, blues).
Date
Needs no explanation; typically stores a date in the YYYY-MM-DD format (ISO 8601 syntax).
Time
Stores a time in the hh:mm:ss format. Besides the time of the day, it can also be used to store the time
elapsed or the time interval between two events which could be more than 24 hours. For example, the
time elapsed since an event took place could be 72+ hours (72:00:59).
Datetime
Stores a value containing both date and time together in the YYYY-MM-DD hh:mm:ss format.
Query is another word for question. In fact, outside of computing terminology, the words "query" and
"question" can be used interchangeably. For example, if you need additional information from
someone, you might say, "I have a query for you." In computing, queries are also used to retrieve
information. However, computer queries are sent to a computer system and are processed by a
software program rather than a person.
One type of query, which many people perform multiple times a day, is a search query. Each time you
search for something using a search engine, you perform a search query. When you press Enter,
the keywords are sent to the search engine and are processed using an algorithm that retrieves
related results from the search index. The results of your query appear on a search engine results
page, or SERP.
NOTE: The word "query" can be used as either noun or a verb. For example, you can "perform a
search query" or "query a database." Both examples are correct uses of the word "query."
When you want to either quickly delete a lot of data or delete a set of data on a regular basis in an
Access desktop database, a delete or an update query might be useful because the queries make it
possible to specify criteria to quickly find and delete the data. Using a query can also be a timesaver
because you can reuse a saved query.
Note: Before you delete any data or run a delete query, make sure that you have a backup of your
Access desktop database.
If you want to only delete a few records, you don’t need a query. Just open the table in Datasheet view,
select the fields (columns) or records (rows) that you want to delete, and then press DELETE.
Use an To delete individual field values from a Makes it easier to delete values by
update table. updating the existing values to
query either a null value (that is, no data)
or a zero-length string (a pair of
double quotation marks with no
space between them).
Delete Query Option when Designing Queries in MS Access 2013 and 2016
Delete Query Option when Designing Queries in MS Access 2007 and 2010
Delete Queries let you:
Empty a table (delete all its records)
Delete all records with a particular value in a field
Delete all records with a range of values in a field
Delete records based on criteria in multiple fields
Delete records with matching values field(s) in a joined table
When you use a DELETE query, only the data is deleted; the table structure
and all of the table properties, such as field attributes and indexes, remain
intact.
You can use DELETE to remove records from tables that are in a one-to-
many relationship with other tables. Cascade delete operations cause the
records in tables that are on the many side of the relationship to be deleted
when the corresponding record in the one side of the relationship is deleted
in the query. For example, in the relationship between the Customers and
Orders tables, the Customers table is on the one side and the Orders table is
on the many side of the relationship. Deleting a record from Customers
results in the corresponding Orders records being deleted if the cascade
delete option is specified.
A DELETE query deletes entire records, not just data in specific fields. If you
want to delete values in a specific field, create an update query that changes
the values to Null.
Important
After you remove records using a delete query, you cannot undo the
operation. If you want to know which records were deleted, first
examine the results of a select query that uses the same criteria, and
then run the delete query.
Maintain backup copies of your data at all times. If you delete the
wrong records, you can retrieve them from your backup copy.
Delete Queries
Definitely the most dangerous of all queries is a delete query, a query that
deletes a whole bunch of records at a time. Once you have deleted records using
a delete query, you cannot undo the resultsthe records are gone forever!
Creating a delete query is no different than creating a select querywith one very
important difference: While a select query displays the records that match your
criteria, a delete query deletes those records. For this reason, you should always
preview the results of a delete query in Datasheet View to see which records will
be deleted.
A delete query
If you want to delete records from multiple tablesfor example, a customer and all
of that customer's ordersyou need to do a few things first:
LeAnne Chang, one of North Shore Travel's managers, decides to open her own
competing travel agency across the street, and being the vindictive person she is,
takes all her customers with her. In this lesson you will create a delete query to
delete all the tours sold by LeAnne Chang.
1. From the Database window, click the Queries icon in the Objects bar and
click the New button.
The query design window and Show Table dialog box both appear. You
have to select the tables and/or queries you want to use in the delete
query.
A field list for the tblEmployees table appears in the top half of the query
design window.
When you have finished adding the tables and/or queries, you can close
the Show Table dialog box.
5. Click Close.
If the tables are related, Access automatically connects their common fields
with a join line. If the tables aren't related, you will have to manually join
them by dragging a field from one table's field list to the matching field in
the other table's field list.
7. Click the Query Type button list arrow on the toolbar and select
Delete Query from the list.
Another way to change the type of query is to select Query from the menu
and select the type of query from the list.
Access converts the select query to a delete query and displays the Delete
row in the query design grid. Now you have to tell Access what you want
to delete.
8. Drag the asterisk (*) from the top of the tblCustomerTours field list into the
design grid.
Notice that From appears in the Delete cell for the asterisk field, indicating
that the records will be deleted from the tblCustomerTours table. Unless
you want the query to delete each and every record in the
tblCustomerTours table, you will need to add some limiting criteria. You
decide to use the last name Chang as the limiting criteria.
9. Drag the LastName field from the tblEmployees field list into the design
grid.
This time Where appears in the Delete cell for the LastName field,
indicating that the LastName field will be used as the criteria to select
which records will be deleted from the tblCustomerTours table.
Access will add the "quotation marks" around the text string Chang for
you, as shown in figure. That's all there is to creating a delete query.
Before you run a delete query, you should always preview the results in
Datasheet view first. Click the View button on the toolbar to display the
delete query in Datasheet view.
11.Click the View button on the toolbar to preview the results of the delete
query in Datasheet view.
The delete query displays the results of the delete query. Let's switch back
to Design view.
Let's run the delete query and delete the selected records.
Ever-cautious Access asks if you really want the delete query to delete the
records, as shown in figure .
14.Click Yes.
15.Close the query without saving your changes and open the
qryToursByName query.
Notice that all the tours for LeAnne Chang are gone.
or...
Part B
Create a database table. The table should have 5 fields and 10 records. Collect data
Explain