Database Basics Flashcards

1
Q

How are queries executed in the REST API?

A

The “Query” parameter, with a query string

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

How are queries executed in the SOAP API?

A

using the query() method

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

SOQL is used when you know which objects the data resides in and you want to:

A

Retrieve data from a single object or multiple objects that are related.
Count the number of records that meet a specified criteria.
Sort results as part of the query.
Retrieve data from number, date, or checkbox fields.

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

What is a SOQL semi-join?

A

a subquery on another object in an IN clause to restrict the records returned

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

What is a SOQL anti-join?

A

A subquery on another object in a NOT IN clause to restrict the records returned.

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

Explain parent-to-child semi-join.

A

A parent to child semi-join is when a parent filters for specific child records in the where clause.

ex: selecting opportunities related to an account based on Stage.

select id, name from account where id in (select accountid from opportunity where stagename= ‘closed lost’)

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

Explain parent-to-child anti-join.

A

A parent-to-child anti-join is when a parent filters for child records excluded from the where clause.

ex: selecting opportunities related to an account that don’t meet criteria.

select id, name from account where id not in (select accountid from opportunity where stagename = ‘closed lost’)

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

Explain child-to-child semi-join.

A

A c2c semi-join is when a result set is filtered by a reference fields of two child objects.

ex: retrieving opportunities for contacts who have a source of ‘web’.

select id from opportunity where accountid in (select accountid from contact where leadsource=’Web’)

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

Explain child-to-child anti-join.

A

A c2c semi-join is when a result set is filtered by the exclusion of reference fields of two child objects.

ex: retrieving opportunities for contacts who don’t have a source of ‘web’.

select id from opportunity where accountid not in (select accountid from contact where leadsource=’Web’)

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

True or false:

Semi-joins & Anti joins can evaluate relationship queries in a SELECT clause.

A

True

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

True/False:

Semi-joins/anti-joins can be combined in a single query.

A

True

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

What are the 2 basic limits of semi & anti joins?

A

No more than two IN or NOT IN clauses.

You cannot use NOT with a semi or anti-join

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

What are the restrictions of the main WHERE clause of a semi or anti join query?

A

The left operand must query a single ID (PK) or reference (FK).
The left operand can’t use relationships (ex: Account.id).

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

True/false

A subquery must query a field referencing the same object type as the main query

A

true

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

True/false

Standard SOQL limits apply to the number of records matched in a subquery .

A

False

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

True/False.

A query that has a subquery is subject to the standard SOQL limits on the main query.

A

true

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

True/False.

The selected column in a subquery must be a foreign key field.

A

true

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

True/False.

The selected column in a subquery can traverse relationships.

A

false

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

True/False.

You can query on the same object in a subquery as a main query.

A

false

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

True/False.

You cannot nest a semi or anti join statement in another semi or anti join statement.

A

True

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

True/False.

You can use semi/anti-joins in a subquery WHERE clase.

A

false

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

True/False.

Subqueries can be used with the OR clause

A

false

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

What four clauses are not supported in subqueries?

A

Count
For Update
Order By
Limit

24
Q

Which objects are not supported in subqueries?

A
ActivityHistory
Attachments
Event
EventAttendee
Note
OpenActivity
Tags (AccountTag, ContactTag, etc.)
Task
25
Q

In a child-to-parent relationship, what is the relationship name to the parent?

Give an example

A

The foreign key.

Contact.Account

26
Q

What property holds the reference to the parent object?

A

relationshipName

27
Q

For parent-to-child relationships, the parent object has a name for the child relationship that is unique to the parent…what is it?

give an example.

A

the plural form of the child object.

Account.Contacts

28
Q

What relationships can be queried using SOQL?

A

child-to-parent (n:1)
Parent-to-child (1:n)
parent-to-child as an FK in an aggregate query

29
Q

True/False:
Any query, including subqueries, can include a WHERE clause, which applies to the object in the FROM clause in the current query.

A

True

30
Q

True/False:

Relationship queries can’t be done on custom objects

A

false.

31
Q

Why is the plural form of the relationship required on creation of a custom relationship?

A

To reference the relationship in a relationship query

32
Q

In a child-to-parent relationship, how is the parent referenced?

A

using dot notation

ex: parent__r.fieldname

33
Q

true/false:

Parent-to-Child relationship queries use dot notation.

A

false.

34
Q

In Apex, how are parent to child relationship queries processed?

A

Perform query on parent object.
Iterate over parent QueryResult with queryMore().
for each parent, retrieve the child QueryResult.
Iterate over child recs using queryMore() on each QueryResult.

35
Q

In a parent-to-child query, explain the result set.

A

The query returns a set of Parent records, which contains a query result set of child fields from the subquery

36
Q

Give an example of a Parent-to-child relationship query

A

Select name, (select firstname, lastname from contacts) from account where name like ‘Acme%’

37
Q

How does an outer join work in SOQL?

A

SOQL relationship queries return records even if the relevant foreign key field has a null value.

ex: Select id, casenumber, account.id, account.name from case; if account.id is not populated for a record, it is returned with this query.

38
Q

Using the Enterprise WSDL, how can you determine if a parent-to-child relationship exists from the parent object?

A

In the WSDL, the parent object will contain an element with the plural name of the child relationship with a type of tns:QueryResult

39
Q

Using the Enterprise WSDL, how can you determine if a child-to-parent relationship exists from the child object?

A

In the WSDL, the child object will contain two elements: one representing the ID of the parent object, the other representing the parent object.

ex: Account, type=ens: Account
AccountId, type=tns:ID

40
Q

True/False:

All relationships are exposed in the API?

A

false

41
Q

What is the most reliable way to identify relationships?

A

execute a describeSObjects() call.

42
Q

How many child-to-parent relationships can be specified in a single query?

A

up to 35

43
Q

How many relationships can a custom object have?

A

25

44
Q

True/False:

All of the child-to-parent relationships can be referenced in a single query.

A

true

45
Q

How many parent-to-child relationships can be specified in a single query?

A

up to 20

46
Q

In a child-to-parent relationship, how many levels of relationships can be specified?

A

5

47
Q

How many levels are represented in the following relationship?

Contact.Account.Owner.Firstname

A

3

48
Q

How many levels of relationship can a query specify in a parent-to-child relationship?

A

1

ex: Account-to-opportunity, but not account to opportunity to OLI

49
Q

True/False:

You can filter on the body of a Note via relationship query.

A

False

50
Q

True/False:

You can filter on the body of an Attachment via relationship query

A

false

51
Q

What field types cannot be filtered in a relationship query?

A

TextArea
Blobs
SControl objects

52
Q

What is the max number of rows that can be fetched in a subquery that involves an external object?

A

1000

53
Q

How many joins can a SOQL query have across external objects and other types of objects?

A

4

54
Q

Why does a join to an external object take longer?

A

Because each join requires a separate round trip to the external system.

55
Q

True/False:

External objects support the ORDER BY clause in a relationship query, except when using OData 2.0 for SF Connect?

A

False

56
Q

True/false:

If the main object of a query is an external object, then queryMore() only supports the main object and not the subqueries?

A

true

57
Q

What is the default batch size for a QueryResult Object?

query() or queryMore()

A

500