Search Header Logo
[igCS] Database - Intro, Structure and Data types

[igCS] Database - Intro, Structure and Data types

Assessment

Presentation

•

Computers

•

9th - 10th Grade

•

Practice Problem

•

Medium

Created by

Andy tsui

Used 6+ times

FREE Resource

20 Slides • 15 Questions

1

[igCS] Database

Slide image

2

Objectives

  • define a single-table database from given data storage requirements

  • choose and specify suitable data types

3

What is Database?

  • Collection of data that is stored and organized in a logical manner

  • It can be paper-based or electronic

4

Slide image

Physical Database: Records stored in paper and folders in a clinic

5

Open Ended

Name some physical database you have encountered before.

6

Slide image

Before Internet, companies registered their contact number on yellow page

7

Electronic (Computer) Database

  • Very common and appears in various scales

  • e.g. The phonebook (or contacts) is a database usually with about 100 contacts

  • The chat history of your instant messaging app may have 10000 records

8

Open Ended

Suggest one more database in your smartphone and give approx. how many total records in it.

9

In your smartphone

Probably there's tens or hundreds different database running in it...

10

Slide image

Comparison of instant messaging users, in million. The scale of a database can be massive!

11

How companies support such a massive of database? - Data center

  • https://www.youtube.com/watch?v=80aK2_iwMOs

12

Basic Functions provided by a database

  • Storing and organization of data

  • Search and retrieve of data (Query)

13

Slide image

Database table structure

14

Table

  • A table is a collection of same type of item

  • e.g. for a school database system, we may have a student table which is storing student info.

  • A database have multiple tables is called "relational database"

15

Database table (cont'd)

  • Record is one entry in the table (row) - e.g. a particular student in our student table

  • Field (column) one particular "property" of the record, e.g. First Name, Last Name, Gender are example of fields in student table


16

Multiple Choice

Question image

How many records in this table?

1

5

2

6

3

7

4

9

17

Multiple Choice

Question image

How many fields in this table?

1

5

2

6

3

7

4

9

18

Fill in the Blank

What is the History score for Diana?

19

Indexing

  • Make record searchable

  • For example, in a dictionary the keyword is indexed (sorted);

  • In yellow page numbers are grouped by type of business then by company name in alphabetical order

20

Open Ended

Question image

How is a typical supermarket index their products?

21

Open Ended

Library is not using ISBN but call number to index their books. Do some research, how does it work?

22

Fill in the Blank

Which page the word "Von Neumann" appears first in the textbook?

23

Indexing in db table

  • Index in a database is called key

  • Each table should have at least one key, which is called primary key

  • Primary key is a unique (across the same table) value which is used to represent/identify a record in a table

24

Open Ended

Assumed that we are creating a database table for students in our class. List 5 most important fields in that table.

25

Multiple Select

Which of the followings are eligible to be primary key in our CS class student table?

1

FirstName

2

LastName

3

StudentID

4

Email

5

ClassNumber

26

More about primary key

  • Primary key must be unique to identify a record

  • Primary key is unique in one table only, it can be repeated in another table.

  • e.g. Student ID is Primary Key in Student table, but the same Value can be, for example, used in Report card table

  • Primary key is also primary index, to help database retrieve a certain record

27

Database data types

  • Each field in the database is assigned with a data type

  • Usually database structure is fixed in size, so in data definitions the size of field is also defined

28

Slide image

29

Case study

Take out text book and study p.171, Case study.

30

Multiple Choice

What is the data type for Name?

1

short text

2

integer

3

decimal

4

yes/no

31

Multiple Choice

What is the data type for Gender?

1

short text

2

integer

3

decimal

4

yes/no

32

Multiple Choice

What is the data type for Date of Birth?

1

short text

2

integer

3

Date/Time

4

Currency

33

Multiple Choice

What is the most suitable data type for Telephone Number?

1

short text

2

integer

3

Date/Time

4

Currency

34

Open Ended

Is there any field that is suitable to be a primary key? Explain why [2].

35

In case if no suitable primary key...

  • In general each table must have a primary key

  • In case if nothing suitable for it, we need to make up one

  • One possible method is "Automatic ID", which either use computer algorithm to generate a code, or auto increment number

[igCS] Database

Slide image

Show answer

Auto Play

Slide 1 / 35

SLIDE