text stringlengths 1 81 | start float64 0 10.1k | duration float64 0 24.9 |
|---|---|---|
And notice here, that "title" has to
be actually added to our database. | 342.67 | 5.05 |
It can't be [? NULL. ?] It
can't have an empty value. | 347.72 | 2.78 |
Same thing for "accession_number." | 350.5 | 2.19 |
And further, "accession_number"
has to be unique. | 352.69 | 3.445 |
I can't have two items [? with ?]
[? a ?] [? different ?] | 356.135 | 2.375 |
"accession_number." | 358.51 | 1.08 |
Otherwise, I might get them
confused in my database | 359.59 | 2.79 |
or inside my museum archives as well. | 362.38 | 2.95 |
So let me then add this
schema to my database. | 365.33 | 4.22 |
And I can do so with
this command right here. | 369.55 | 2.73 |
This is a SQLite command called .read,
that we saw a little bit last week | 372.28 | 4.5 |
as well. | 376.78 | 0.91 |
I could type .read and then the
name of this file I want to read. | 377.69 | 3.75 |
So I'll say .read schema.sql. | 381.44 | 4.18 |
Hit Enter. | 385.62 | 2.4 |
And now if I type, let's say .schema,
I can see that same [? sql ?] | 388.02 | 5.43 |
[? schema, ?] same database
schema. now inside of my terminal. | 393.45 | 5.83 |
OK, so now as promised, let's try
adding some rows to this table. | 399.28 | 5.14 |
Because right now, if I do SELECT
[? star ?] from [? collections ?] | 404.42 | 3.62 |
[? semicolon, ?] I don't see anything
because nothing is inside yet. | 408.04 | 4.89 |
But I could add something
using INSERT INTO. | 412.93 | 3.07 |
So let's try that. | 416 | 1.39 |
I'll say INSERT INTO
the "collections table." | 417.39 | 4.24 |
And now, I have to ask, what
columns inside of "collections" | 421.63 | 3.75 |
[? do I ?] [? want ?] to add data to. | 425.38 | 2.7 |
Well, I probably want to add
to the first the "id" column, | 428.08 | 3.54 |
that primary key column. | 431.62 | 1.86 |
Then maybe, I want to add a
"title" to this row, and also | 433.48 | 3.99 |
an "accession_number," and also,
of course, the date this piece | 437.47 | 3.84 |
was "acquired." | 441.31 | 1.36 |
So now, I have the table
I'm inserting into along | 442.67 | 3.08 |
with the columns I'm adding values for. | 445.75 | 2.49 |
So for style's sake,
I'll hit Enter here. | 448.24 | 2.82 |
And now, I could type a list of
values to insert into this new row. | 451.06 | 4.65 |
I could say VALUES, and then
inside parentheses, the values | 455.71 | 4.35 |
I want to insert. | 460.06 | 1.59 |
Maybe the first primary key
that I give to this item | 461.65 | 3.36 |
is going to be just [? 1, ?] start
at 1, and add up as we add new items. | 465.01 | 4.41 |
For the title, I'll say let's call
this one "Profusion of flowers." | 469.42 | 4.11 |
This is the piece we recently
acquired into our collection. | 473.53 | 3.3 |
The accession number that
we gave it was 56.257. | 476.83 | 3.57 |
And the date it was acquired
was back in 1956-04-12. | 480.4 | 5.72 |
Now, I have all these values here. | 486.12 | 1.56 |
I'll type [? semicolon ?] hit
Enter, and nothing seems to happen. | 487.68 | 4.35 |
But if I type, let's say, select
[? star ?] from collections | 492.03 | 5.34 |
[? semicolon, ?] what do I
see, but this new row inside. | 497.37 | 5.46 |
Let's do it again to get a hang of this. | 502.83 | 1.71 |
I want to now add "Farmers
working at dawn" to my collection. | 504.54 | 3.06 |
So I'll do the same thing,
I'll say let's INSERT INTO | 507.6 | 3.48 |
the "collections" table. | 511.08 | 1.589 |
And let's add values for
the "id" column, the "title" | 512.669 | 4.26 |
column, the "accession_number," and
also the "acquired" column like this. | 516.929 | 5.73 |
Again for style's sake, I'll hit Enter. | 522.659 | 1.981 |
Now, I give some list of values
to add into this new row. | 524.64 | 4.14 |
I'll say VALUES here, then this list
of values to add for each column. | 528.78 | 4.5 |
Well, the first column, I have
to give a value for is "id." | 533.28 | 4.08 |
If you remember, our last id was
1, so what should this id be? | 537.36 | 5.1 |
Maybe 2. | 542.46 | 1.08 |
So I'll type 2 here as the next
increment of my primary key, | 543.54 | 4.65 |
then I'll give it a title. | 548.19 | 1.14 |
And this title was
"Farmers working at dawn." | 549.33 | 4.14 |
We gave it an accession
number to keep track of it | 553.47 | 2.34 |
in our own internal museum
records, our own archives here. | 555.81 | 3.1 |
So I'll say 11.6152 is the
[? accession ?] [? number ?] for this | 558.91 | 6.2 |
particular item, then I'll say we
acquired it back in 1911-08-03. | 565.11 | 7.63 |
Now, I'll hit a semicolon
here, hit Enter. | 572.74 | 3.27 |
And now, I should be able to see if
I type [? SELECT ?] [? star ?] FROM | 576.01 | 3.51 |
"collections," SELECT
[? star ?] FROM "collections" | 579.52 | 3 |
[? semicolon, ?] I now have these
two items inside of my collection. | 582.52 | 6.22 |
Now, let's do one more here. | 588.74 | 2.7 |
But let's focus in particular
on this primary key. | 591.44 | 4.2 |
Notice here, how we've been actually
inserting our very own primary key | 595.64 | 3.93 |
1 and then 2. | 599.57 | 1.83 |
But maybe that's not the best design. | 601.4 | 3.823 |
Let me try this again. | 605.223 | 0.917 |
I'll say INSERT INTO, let's go for,
"collections" [? is ?] our table name. | 606.14 | 5.94 |
And maybe I'll try again to add
to the "id" column, the "title" | 612.08 | 4.71 |
column, the "accession_number,"
and the "acquired" column here. | 616.79 | 7.14 |
What could go wrong do you think if I
try to specify the primary key myself? | 623.93 | 6.03 |
Let me ask this as an
audience question here. | 629.96 | 1.92 |
Feel free raise your hand. | 631.88 | 1.26 |
What might go wrong if I try
to make the primary key myself? | 633.14 | 4.56 |
Insert a value myself? | 637.7 | 1.485 |
Let's go to [INAUDIBLE]. | 643.01 | 1.89 |
SPEAKER 2: Yeah, what we could do when
we have to [INAUDIBLE] a lot of values, | 644.9 | 5.04 |
like maybe like big data or something,
is there a way to add it to a CSV file | 649.94 | 6.87 |
or something rather than typing
[? insert ?] [? into ?] tables? | 656.81 | 2.915 |
SPEAKER 1: A good question. | 659.725 | 1.125 |
I think you're onto
something here, which | 660.85 | 1.708 |
is we're inserting one row at a time,
which could get easily repetitive. | 662.558 | 3.042 |
So let me hold that thought
for just a minute here | 665.6 | 2.297 |
and focus on the primary keys before
we see some more efficient ways | 667.897 | 2.833 |
to actually add data to our table. | 670.73 | 2.23 |
So I'm with you on this
idea of maybe we don't want | 672.96 | 2.84 |
to duplicate this primary key, right? | 675.8 | 1.897 |
Maybe we could do a
little better than that. | 677.697 | 1.833 |
So I'll come back to my computer here. | 679.53 | 2.25 |
And if I specify the primary
key, I might actually | 681.78 | 3.89 |
add a value that's already in there. | 685.67 | 2.17 |
So I could, thankfully, leave it
up to SQLite to actually increment | 687.84 | 4.34 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.