Practice Using Functions
Write queries to answer the astronomy questions in Practice 10 and 11.
Use the Schema
Browser when you need it.
Practice 10. In the field 5112-6-119, what percentage
of all objects detected by the SDSS are too close to the edge
of their fields to be trusted?
Hint: Use two searches, one with a flag and one
without. Search run=5112, camcol=6, field=119.
Show Sample Solution
To find the number of objects in the field too close to the edge of their fields,
use the "EDGE" flag in the following query:
select
count(objID)
from
photoObj
where
run=5112
and camcol=6
and field=119
and (flags & dbo.fPhotoFlags('EDGE')) > 0
The query returns a count of 17.
To find the total number of objects in the field, use the same query without
the flag:
SELECT
count(objID)
FROM
photoObj
WHERE
run=5112
and camcol=6
and field=119
This query returns a count of 670.
So the percentage of objects too close to the field edge to trust is
17 / 670, or about 3%.
Hide Sample Solution
|
Practice 11. Choose a galaxy cluster from SkyServer's
Famous Places tool.
Write a query to select galaxies in the cluster, and only galaxies in
the cluster.
Hint: After you pick a cluster, use the
Navigation Tool to examine the cluster. Guess which galaxies
belong to the cluster - you should be able to tell just by looking.
Click on 5-10 cluster galaxies and save them in your online notebook.
Open the notebook, and look for features that the cluster galaxies
have in common. Guess the center position and radius of
the galaxies. Then, write a query that uses what you have learned
to search for cluster galaxies.
Show Sample Solution
First, select a galaxy cluster from the Famous Places
tool and look at it in the Navigation Tool. As an example, these answers
will use Abell 0957.
Galaxy clusters tend to have similar colors, or differences in
magnitudes. Color is one of the most reliable ways to identify which
galaxies are in a cluster. Most of the galaxies in Abell 0957 have a
g-r color of about 0.8. So a search should consider galaxies with g-r
of about 0.6 to 1.
The galaxies in Abell 0958 appear to extend about 0.15 degrees, or
9 arcminutes. The brightest galaxy in Abell 0958 appears to have an r
magnitude of about 13. The faintest galaxy appears to be at about r = 18.
Combining all these results into one query:
SELECT
p.objID, p.ra, p.dec, p.u, p.g, p.r, p.i, p.z
FROM photoObj p
JOIN dbo.fGetNearbyObjEq(153.378,-0.85,9) n ON n.objID = p.objID
WHERE
p.type = 3
and p.r BETWEEN 13 and 18
and p.g-p.r BETWEEN 0.6 and 1
The query returns 46 objects. Not every galaxy is part of the cluster, but most are.
Your results will be different, depending on which cluster you chose, what
criteria you chose, and how big you thought the cluster was. The
important thing is that you think carefully about how to search for
galaxies in a cluster, then write a query that reflects your thinking.
Hide Sample Solution
|
Answers
An Afterthought: Procedures and Constants
In addition to tables, views, and functions, the Schema Browser contains
entries for procedures and constants. Procedures, like functions, are
mini-programs that the database can execute. Unlike functions, they
do not output a single value; rather, they manipulate the inputs passed
in to them. Procedures are called with the syntax
dbo.spProcedurename(inputs)
Nearly all of the procedures in SkyServer are used by the web
server or tools - you will hardly ever use them in your queries. If
you ever need them, the
Schema Browser will tell you what they do and how to use them.
Constants are, well, constant. They can be displayed and
searched just like tables can. See the
Schema Browser for a complete description of SkyServer's constants.
You're done! Click Next for the conclusion.
|