Week 4 L1 Flashcards

1
Q

How to insert a document ?

A

.insert

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How to insert datasets such as JSON CSV and TSV?

A

use mongo import

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

how to specify format of import?

A

/type

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What happens if no collection name is given ?

A

the collection is named from file without extension

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How do you remove any blanks from insert?

A

/ignoreBlanks

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

what does upserting data mean ?

A

/mode upsert

Upsert inserts new data but replaces any matching data. Inserts if no match or updates if it does.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How to specify fields for upsert?

A

/upsertFields

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How to specify field names?

A

/fields name

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How to specify list of field names

A

/headerline

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How to export data?

A

mongoexport

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How to export part of a collection

A

/query

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How to export a subset of names of fields

A

/fields title

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

how to sort a export ?

A

/sort

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

how to reduce number of exported documentes

A

/skip and /limit

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What are indexes

A

Special data structures that store small portions of collections data set in a easy to traverse form. Indexes store values of specific fields or set of fields ordered by value of field. Each entry in index points to DB document.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Why do we use indexes?

A

To support efficient execution of queries in mongo db.
Without indexes Mongodb must scan every document in a collection to select those documents that match the query criteria.

17
Q

At what level does mongodb define its indexes?

A

At collection level

18
Q

What structure do indexes in mongo db use?

A

B-Trees

19
Q

What is the big O notation of a non index look up ?

A

O(N)

20
Q

What is the big O notation when using a B tree ?

A

O(log n)

21
Q

Benefits of index

A

Held In ram
Results are also already sorted so no need for additional sort after query
Covered results do not need to access DB at all, just return data from the index.
Range searches are quicker

22
Q

How do we measure the efficiency of a search ?

A

Using the explain method

23
Q

What are the different types of index in mongodb?

A
Default ID index
Single field index , compound index,
multikey index- index array fields,
geospatial index, 
text indexes,
hashed indexes
24
Q

What are some examples of mongodb index properties?

A

unique indexes- reject duplicate values from index fields.

sparse indexes- only index docs that have a index fields, so only contains subset of whole collection

25
Q

why should you be careful with the amount of indexes you use?

A

should only index what oyu need as too many indexes can fill ram.
Index should be for frequent and targeted queries and updates.
Indexes will slow down large number of insert updates and deletes as the index will also need to be changed.

26
Q

What is index hinting ?

A

If you search across many fields and there are more than one field with index and there’s no compound index then hint tells mongo db optimises which index to use