View
225
Download
0
Tags:
Embed Size (px)
Citation preview
DataBase Creating
- create an empty db- add a table- define columns (name and data type)- input data to the table
- define forms, queries
Designing - processing
• the DB is a collection of tables, queries, forms and other• Every elements of a DB has his own „project”. The table
has the project of columns and data type. The query has columns and conditions. The form has fields.
• Every element of a DB participates in data processing. Tables collect data elements as numbers, string, OLE.
• Another elements collect the processed data.• When DB elements are designed the DB can not be
processed ! The processing require to complete the design
Process of DB creating
Define a source table- columns,- data type (numbers, string, date, logical)
Query on the table
[parameters]
conditions
The query produces a virtual table
Forms are defined on tables
The designer
the OLE data type in the table
The table
COL1 COL2 IMG1
Flower Rose Link to the image „rose”
Tree Oak Link to the image „oak”
COL1 COL2 IMG1
The form
The navigation bar
Flower Rose
The bmp or jpg or other file
Processing the data
• create DB of tables, queries and forms• input data to tables• call the forms or queries• test if the output data fulfill yours requirements• add a new feature to the DB design
The table
• the table is a collection of rows,
• the row consist of fields, which reflects the properties of some real entity,
• the field can be a number, text or link,
• the field has a format, used for input – output a data in field,
• the rows has the same fields, collected in columns of a table
The table reflects real objects (an example)
Objects
Object Propulsion Weight
boat winter small
car engine middle
shuttle rocket huge
Data type
• An real object has properties (attributes)– examples: name, quantity, size, weight, colors, shape,
temperature, the date of validity– the attributes are expressed by words (a letters string)
or numbers, which have formats– examples of a name: alfa, beta, gamma, A1, B1, G1– examples of a number: 10, 20 (the integer format),
10.01, 20.001 (the float format), 10-12-05, 10-dec-05 (the date format)
• A set of properties (attributes) of the real object defines the „entity”, which is mapped to a row of a table
• Real objects may depend one of another.• Usually a set of objects related to one object but there
are two o more types of objects.• Each type of object is mapped by a table.• Example: a student can borrow books from the library,
this means an object student has a related set of books.
• Students and books are mapped to tables
Related tables
booksA student
has borrowed
Example of the related tables – part 1
• A simply way is to map students to a table and books to a table as follows.
Name School Address
Pirx Astro Luna
Alex Astro Mars
Students
Title Author Borrowed
Limes inferior Janusz Zajdel Yes
Dzienniki gwiazdowe Stanisław Lem Yes
Books
• The example shows two independent tables.
Example of the related tables – part 2
• The relation of a student and books has to be mapped by the structure of the tables.
• In the example the table of books has an additional column, which include the data from one column of the students table
Name Title Author Borrowed
Pirx Limes inferior Janusz Zajdel Yes
Alex Dzienniki gwiazdowe
Stanisław Lem Yes
Books
The column from the students table
Searching for the data in a table
• the data in a row maps properties of a real object,• a table consists of rows, which maps the real objects,• the table can include a huge amount of rows,• in order to find a row, which reflects the specific property
of an object it is defined a key,• the key can be one column or more columns,• setting a value of the key and using the searching engine
the rows is retrieved from a table,• a key and the searching engine is the query on a table,
Query on a table
data1
data2
data1
[KEY] = data2
Query data2
Source table
Virtual table – an output of the query
The key value in a query
• A simple query is a key over one column of a table• A key has to be defined by value• A key is a type of the data in one column of a table• The data can be a type: „numbers”, „string”, „date”, OLE• Examples of a data: 3.1473520, „asd0fgh”, 01-may-05• A simple query has two forms:
– „equal to” defined by the sign =– „garter then” also „less then” defined by signs < >
• The simple query can be used over one or more column, in order to select the data which fulfill the conditions of all keys
Query on a table using keys
c11 c12 c13
c21 c22 c23
c31 c32 c33
c41 c42 c43
[KEY1] = c31, ….. , [KEY2] = c33
Query
Source table
c31 c32 c33
Query using logical expression
• Defining a query with a few keys a row is retrieved when the data in the row fulfill the condition: „first key is true” and „second key is true” and all next keys is true.
• This condition is a logical expression in the form as:
[key1] and [key2] and „all next keys”• The expression is used to retrieve data from a table
assuming the data fulfill the condition:„Data from column 1” = [key1] and „Data from column 2” and [key2] and next …
• The brackets allow to clarify the expression:(„Data from column 1” = [key1]) and („Data from column 2” and [key2]) and
next
Logical expression – an example
code a sign
50 A
51 B
52 C
53 D
54 E
(50 < [code]) and ([code] > 53)
code a sign
51 B
52 C
Query on related tables
• Query on related tables joins the data from the tables.• Query includes one or more columns from tables• The example joins the all data from the students table and
the books table
Name Title Author Borrowed
Pirx Limes inferior
Janusz Zajdel
Yes
Alex Dzienniki gwiazdowe
Stanisław Lem
Yes
Name School Address
Pirx Astro Luna
Alex Astro Mars
Name School Address Title Author Borrowed
Pirx Astro Luna Limes inferior Janusz Zajdel Yes
Alex Astro Mars Dzienniki gwiazdowe Stanisław Lem Yes
Query
Input and output data from a table using the form
• Tables, collected in database, store data• The data can be input and output from a table using a
form as interface• The input and output of data processes only one row of a
table• Forms are two types:
– „the columns form” when only one row in a form,– „the browser form” when a few rows in a form
• The form can process data from a few tables
The form for related tables
• Two tables are related when the data from tables can be joined by a query or a form
• A form over related tables (usually) is the columns form which include the browser form
• A columns form processes one row from the main table• A browser form processes rows from the subordinate
table• The columns form includes the browser form• A row is processed by the main form and the browser
processes rows which are related to the main