What does index
keyword mean and what function it serves? I understand that it is meant to speed up querying, but I am not very sure how this can be done.
W
This keyword means that you are creating an index on column blog_post_id
along with the table.
Queries like that:
SELECT *
FROM blog_comment
WHERE blog_post_id = @id
will use this index to search on this field and run faster.
Also, there is a foreign key
on this column.
When you decide to delete a blog post, the database will need check against this table to see there are no orphan comments. The index will also speed up this check, so queries like
DELETE
FROM blog_post
WHERE ...
will also run faster.