1
- # Lesson 1: Server setup and Basics of creation, insertion and retrieval of data
1
+ # Lesson 1: MySQL and Node setup! Create, Insert and Select !
2
2
3
3
Objective : This module aims to incorporate JavaScript code to operate the MySQL database.
4
4
MySQL client can be used to demonstrate SQL queries however, students should know how to
@@ -71,7 +71,6 @@ const capitals = [
71
71
" Madrid" ];
72
72
```
73
73
74
-
75
74
### Relations = Table
76
75
77
76
* What is a relation (in the following sentences)?
@@ -82,28 +81,23 @@ const capitals = [
82
81
Dan, 29, works in Amazon and lives in Seattle. His friend Ben who just celebrated
83
82
his 24th birthday works in Facebook and lives in Redmond.
84
83
85
- -
86
-
87
84
### DBMS implementations
88
85
89
86
* ** MySQL **
90
87
* PostgreSQL
91
88
* MongoDB (NoSQL)
92
89
* Cassandra (NoSQL)
93
90
94
-
95
91
### MySQL components
96
92
97
93
* MySQL server (runs as a service, default port: 3306)
98
94
* mysql: monitor / terminal / client (to connect to the server and execute stuff)
99
95
* mysqladmin: Administering a MySQL Server
100
96
101
-
102
-
103
97
### Create Table in MySQL
104
98
105
- ## Collection of rows and columns
106
- ## SYNTAX
99
+ #### Collection of rows and columns
100
+ #### SYNTAX
107
101
```
108
102
CREATE TABLE table_name (column_name, column_type [, column2_name, column2_type]);
109
103
```
@@ -116,30 +110,27 @@ CREATE TABLE table_name (column_name, column_type [, column2_name, column2_type]
116
110
### Fill up the table in MySQL: INSERT rows
117
111
A row (aka record or tuple) represents a single, implicitly structured data item in the table.
118
112
119
- ## SYNTAX
113
+ #### SYNTAX
120
114
```
121
115
INSERT INTO table_name VALUES(value1, value2 [,value3,...]);
122
116
```
123
117
* INSERT INTO table_name VALUES(...values...)
124
118
* INSERT INTO table_name (column names) VALUES(..values...)
125
119
* INSERT INTO table_name SET column_name = {expr | DEFAULT}
126
120
127
-
128
-
129
121
### See the content : SELECT
130
122
131
123
* FROM clause : multiple tables
132
124
* WHERE clause : Multiple conditions(AND, OR, NOT) Operators ( =, <>, BETWEEN, LIKE, IN)
133
125
* Aggregation : SUM, AVG, COUNT
134
126
* Joins : Natural join, inner join, left outer and right outer join
135
- ## Simple SYNTAX for a single table
127
+ #### Simple SYNTAX for a single table
136
128
```
137
129
SELECT */column_name FROM TABLE
138
- WHERE condition1 AND/OR
139
- condition2;
130
+ WHERE condition1 [ AND/OR
131
+ condition2 ...] ;
140
132
```
141
133
142
-
143
134
### INSERT and SELECT together
144
135
145
136
```
@@ -152,14 +143,12 @@ FROM transferred_ employees
152
143
WHERE transfer_date > '2008-01-01';
153
144
```
154
145
155
-
156
146
### Uniqueness and Keys
157
147
158
148
* Super key : set of columns that uniquely identify a row
159
149
* Candidate key : minimal super key that can uniquely identify a row
160
150
* Primary key : choice of candidate key chosen by database designer : cannot be null
161
151
162
-
163
152
## Reference Material
164
153
165
154
- [ TutorialsPoint MySQL Introduction] ( http://www.tutorialspoint.com/mysql/mysql-introduction.htm )
0 commit comments