Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sql-quiz: update quiz values with correct info #60

Merged
merged 1 commit into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion code-slides/day-2-databases/connect-sqlite.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

func main() {
fileName := "/database.db"
db, err := sql.Open("sqlite", fileName)
db, err := sql.Open("sqlite3", fileName)
if err != nil {
log.Fatal(err)
}
Expand Down
9 changes: 9 additions & 0 deletions sql-quiz/question2.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
create table users (
id int primary key,
name varchar(255) not null,
email varchar(255) not null,
password varchar(255) not null,
created_at timestamp not null default now(),
updated_at timestamp not null default now()
);

INSERT into users (id, name, email)
values (1, 'John Doe', '[email protected]');

Expand Down
11 changes: 11 additions & 0 deletions sql-quiz/question3.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
CREATE table users (
id int primary key,
name varchar(255) not null,
email varchar(255) not null,
password varchar(255) not null,
created_at timestamp not null default NOW(),
updated_at timestamp not null default NOW()
);

INSERT into users (id, name, email)
values (1, 'John Doe', '[email protected]');
INSERT into users (id, name, email, password)
values (1, 'Jane Doe', '[email protected]', 'password1');

Expand Down
14 changes: 14 additions & 0 deletions sql-quiz/question5.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
CREATE table transactions(
id int primary key,
user_id int not null,
amount int not null,
created_at timestamp not null default NOW(),
updated_at timestamp not null default NOW()
foreign key (user_id) references users(id)
);

INSERT into transactions (id, user_id, amount) values (1, 1, 1000);
INSERT into transactions (id, user_id, amount) values (2, 2, 2000);
INSERT into transactions (id, user_id, amount) values (3, 2, 3000);
INSERT into transactions (id, user_id, amount) values (4, 1, 4000);

UPDATE transactions set amount = 5000 where user_id = 1;

select * from transactions;
Expand Down
Loading