1
00:00:00,237 --> 00:00:02,820
(upbeat music)

2
00:00:05,730 --> 00:00:08,590
So if we're going to use a database in our programmes

3
00:00:08,590 --> 00:00:12,160
it's important to understand what a database is.

4
00:00:12,160 --> 00:00:15,030
Now a database is just an organised collection of data

5
00:00:15,030 --> 00:00:17,390
that can be used to store information

6
00:00:17,390 --> 00:00:19,560
on a computer or on an Android device

7
00:00:19,560 --> 00:00:22,800
or accessed from a web server over the internet.

8
00:00:22,800 --> 00:00:25,850
Now if you used an Android phone or tablet

9
00:00:25,850 --> 00:00:28,170
and if you're watching this as part of my Android course

10
00:00:28,170 --> 00:00:30,360
then you certainly will have Android itself

11
00:00:30,360 --> 00:00:32,590
uses many databases to store things like

12
00:00:32,590 --> 00:00:34,960
your contacts info, text messages,

13
00:00:34,960 --> 00:00:37,180
and also your browser history.

14
00:00:37,180 --> 00:00:40,640
Now search history on a browser is also stored in a database

15
00:00:40,640 --> 00:00:43,070
which is how the Google search on your phone knows

16
00:00:43,070 --> 00:00:44,950
what you've searched for previously

17
00:00:44,950 --> 00:00:46,393
and can offer suggestions.

18
00:00:50,040 --> 00:00:52,120
Anything that stores and retrieves information

19
00:00:52,120 --> 00:00:54,380
can be called a database these days,

20
00:00:54,380 --> 00:00:57,110
though, and the term database is normally used

21
00:00:57,110 --> 00:01:00,280
to refer to more structured data.

22
00:01:00,280 --> 00:01:03,620
Now vendors such as Microsoft, Oracle, and IBM

23
00:01:03,620 --> 00:01:05,820
produce database management systems based on

24
00:01:05,820 --> 00:01:08,230
a relational database.

25
00:01:08,230 --> 00:01:10,580
The data is stored is rows and columns with

26
00:01:10,580 --> 00:01:13,450
a row corresponding to a single record

27
00:01:13,450 --> 00:01:15,380
and the columns representing the fields

28
00:01:15,380 --> 00:01:16,890
that make up a record,

29
00:01:16,890 --> 00:01:19,380
such as name address and data of birth

30
00:01:19,380 --> 00:01:21,480
in the case of a persons record

31
00:01:21,480 --> 00:01:24,070
or stock number, description, and quantity

32
00:01:24,070 --> 00:01:26,190
in a stock keeping application.

33
00:01:26,190 --> 00:01:28,810
So there's a huge number of database systems out there.

34
00:01:28,810 --> 00:01:30,410
Probably the most well know are the

35
00:01:30,410 --> 00:01:33,500
traditional databases being Microsoft SQL Server,

36
00:01:33,500 --> 00:01:36,650
Oracle, and DB2 from IBM.

37
00:01:36,650 --> 00:01:38,410
Now Oracle now own the Java language

38
00:01:38,410 --> 00:01:40,510
after buying Sun Microsystems,

39
00:01:40,510 --> 00:01:43,563
but they were originally created as a database company.

40
00:01:47,600 --> 00:01:50,310
So these traditionally databases typically use Structured

41
00:01:50,310 --> 00:01:53,800
Query Language, shortened to Sequel or S-Q-L,

42
00:01:53,800 --> 00:01:56,480
for performing operations such as querying

43
00:01:56,480 --> 00:01:58,170
and updating the data,

44
00:01:58,170 --> 00:02:00,050
but there is now a growing interest in

45
00:02:00,050 --> 00:02:04,033
NoSQL databases used for storing and processing Big Data.

46
00:02:04,940 --> 00:02:07,330
Android includes a public domain database engine

47
00:02:07,330 --> 00:02:11,180
called SQLite and Python includes support for SQLite

48
00:02:11,180 --> 00:02:13,460
databases in the standard library.

49
00:02:13,460 --> 00:02:15,920
Unlike our traditional database management systems,

50
00:02:15,920 --> 00:02:18,010
such as SQL Server or Oracle,

51
00:02:18,010 --> 00:02:20,350
SQLite is completely self contained,

52
00:02:20,350 --> 00:02:23,000
it doesn't actually need a separate server to run on.

53
00:02:27,270 --> 00:02:30,310
SQLite was designed to be embedded into systems

54
00:02:30,310 --> 00:02:33,040
and originally missile guidance systems, in fact.

55
00:02:33,040 --> 00:02:36,820
Now it uses the SQL language, which makes very easy to use.

56
00:02:36,820 --> 00:02:39,410
If you already know a bit about databases

57
00:02:39,410 --> 00:02:41,170
that means that you can move on to use

58
00:02:41,170 --> 00:02:44,443
other SQL databases once you've learned to use SQLite.

59
00:02:45,610 --> 00:02:48,610
Now SQL was developed from Edgar F. Codd's work

60
00:02:48,610 --> 00:02:52,170
on relational databases in the 1970s

61
00:02:52,170 --> 00:02:55,750
and became became an ANSI standard in 1986.

62
00:02:55,750 --> 00:02:58,970
SQLite implements most of the features of SQL-92

63
00:02:58,970 --> 00:03:02,220
and although, there have been four revisions of the standard

64
00:03:02,220 --> 00:03:04,860
since SQL-92 includes everything needed

65
00:03:04,860 --> 00:03:07,190
for most database tasks.

66
00:03:07,190 --> 00:03:10,230
Interestingly, text messages on an iPhone

67
00:03:10,230 --> 00:03:12,613
are also stored in a SQLite database.

68
00:03:15,940 --> 00:03:18,000
So if you're freaking out about now at the prospect

69
00:03:18,000 --> 00:03:21,150
of having to learn yet another language, don't worry.

70
00:03:21,150 --> 00:03:23,110
SQL is a language, but it's nowhere

71
00:03:23,110 --> 00:03:25,890
near as complicated as Java, for example.

72
00:03:25,890 --> 00:03:28,120
In fact, you can do a lot of database work with only

73
00:03:28,120 --> 00:03:32,370
four commands, Select, Insert, Update, and Delete.

74
00:03:32,370 --> 00:03:34,200
You'll see those in

75
00:03:34,200 --> 00:03:36,490
this section of the course as we work forward.

76
00:03:36,490 --> 00:03:39,400
Now if you're going to be doing a lot of database work

77
00:03:39,400 --> 00:03:42,030
then you will need to learn SQL more fully

78
00:03:42,030 --> 00:03:44,730
then what we need here and you'll also need to learn about

79
00:03:44,730 --> 00:03:46,480
things like normalisation,

80
00:03:46,480 --> 00:03:48,410
but the basics that I'm gonna cover

81
00:03:48,410 --> 00:03:50,210
will allow you to create programmes that can do

82
00:03:50,210 --> 00:03:53,160
basic storage, update, and retrieval

83
00:03:53,160 --> 00:03:54,913
of information in a database.

84
00:03:58,930 --> 00:04:01,160
SQLite has been around since 2000

85
00:04:01,160 --> 00:04:03,720
and it is a very fast and very stable

86
00:04:03,720 --> 00:04:05,670
stand alone database.

87
00:04:05,670 --> 00:04:07,610
In fact, it's the most widely deployed

88
00:04:07,610 --> 00:04:09,520
database engine in the world.

89
00:04:09,520 --> 00:04:10,870
It's actually close to being the most

90
00:04:10,870 --> 00:04:13,570
widely deployed piece of software of any kind,

91
00:04:13,570 --> 00:04:15,550
which is pretty impressive.

92
00:04:15,550 --> 00:04:18,620
The examples of its use and justification for that claim

93
00:04:18,620 --> 00:04:20,230
that it's the most widely deployed

94
00:04:20,230 --> 00:04:21,450
database engine in the world are at

95
00:04:21,450 --> 00:04:25,530
sqlite.org/mostdeployed.html.

96
00:04:25,530 --> 00:04:28,240
An interesting read there if you've got the time.

97
00:04:28,240 --> 00:04:29,860
You can also find out more information

98
00:04:29,860 --> 00:04:31,730
about SQLite at that website.

99
00:04:31,730 --> 00:04:33,760
Click the SQLite logo at the top of the page

100
00:04:33,760 --> 00:04:34,920
to go to the home page

101
00:04:35,810 --> 00:04:37,990
and you can just go to sqlite.org

102
00:04:37,990 --> 00:04:41,510
or you can just type in sqlite.org/index.html,

103
00:04:41,510 --> 00:04:42,993
either way it will get you there.

104
00:04:46,440 --> 00:04:48,610
All right, so we're gonna first look at some basic database

105
00:04:48,610 --> 00:04:51,040
terminology and then we're gonna move on to use

106
00:04:51,040 --> 00:04:53,190
SQLite to create a database

107
00:04:53,190 --> 00:04:55,730
and store some information in that database.

108
00:04:55,730 --> 00:04:57,820
We need to understand things like table,

109
00:04:57,820 --> 00:05:00,380
records, and fields, as well as record sets

110
00:05:00,380 --> 00:05:01,750
and why they're important.

111
00:05:01,750 --> 00:05:03,150
So we'll start, though, by looking at

112
00:05:03,150 --> 00:05:05,373
database terminology in the next video.

