Ex2Winter97

advertisement
Computer Science 101
Survey of Computer Science
Exam 3 - Fall 2010
Name:
Pledged:
1. (40 points) Complete the following:
a. A
web server
is a computer program that accepts requests from other
(client) programs for web pages and responds with the requested pages.
b. The two main sections of an HTML document are the head and the
body.
c. In HTML, the NAME parameter is used with the anchor tag in order to
make a location that can be linked to
d. In HTML, the <ol> tag marks the beginning of ordered (numbered) list
e. Give a section of HTML code that would produce a clickable link to the web
address “http://www.amazon.com” with “Click for Amazon” as the words to
click.
<a href = ‘heep://www.amazon.com’> Click for Amazon </a>
f. For each of the following relationships between people and airlines (Delta,
United, etc.) indicate whether the relationship would most likely be considered
1:1, N:1(or 1:N), or N:M
HasFlownOn indicating the person has flown on the given airline
N:M
MostRecentlyFlewOn indicating the person’s most recent flight was
on the given airline
N:1
HasNeverFlownOn indicating the person has never flown on the airline
N:M
IsMostSeniorPilotOf indicating the person is the airline’s pilot with most
seniority
1:1
2
g. Assume that we are building a database for the situation described in part f.
Assume that we have a table People for the group of people under consideration
and that the primary key for this table is PersonID. Further assume that we have a
table Airlines with primary key AirlineID. Explain how we would most likely
handle the relationship HasFlownOn in terms of the tables and columns of the
database. We would have a new table, PersonFlown, with columns PersonID
and AirlineID
Explain how we would most likely handle the relationship MostRecentlyFlewOn.
Have a column in PeopleTable with AirlineID of the airline most recently flown
on.
h. The following are the clauses of an SQL query statement:
GROUP BY, ORDER BY, SELECT, HAVING, WHERE, FROM
The SELECT clause is used to specify the columns to be shown in the result.
The FROM clause is used to specify the tables to be used in the query.
The WHERE clause is to specify filter conditions on column values that
determine which rows will be in the result.
i. The SQL keyword
DISTINCT can be used to make sure that we do not have
duplicate rows in the result of a query. This keyword would be used in
the
SELECT
clause of the query.
j. The definition of an alias for a table, for example using S for Students, takes place
in the FROM clause.
k. A column name must be qualified, for example Students.Lastname, if
two or more tables listed in the FROM clause have that column name
3
2. (20 points) Write a complete HTML document that would produce a page that looks
like the page below, complete with title in title bar and a link to the indicated website.
You can use the web address: http://htmlbible.com for the HTML Bible site.
<html>
<head>
<title> My HTML Page </title>
</head>
<body>
<h2> Favorite Tags </h2>
<h3> Formatting Tags </h3>
<ol>
<li> There are tags for <b> bold </b> </li>
<li> There are tags for <i> italics </i> </li>
<li> You can even have <b><i>both</i></b> </li>
</ol>
<hr/>
I hope to have this completed before the deadline.
In the meantime you may consult
<a href=’http://htmlbible.com’> The HTML Bible </a>
</body>
</html>
4
3. (40 points) The following are the tables together with their columns from our class
database:
Students(StudentId,LastName,FirstName,ClassYear,City,State,Birthdate,
AdvisorId,Term)
Faculty(FacultyId, LastName, FirstName, Phone, Email)
Interests(InterestId, InterestName, Category, URL)
Majors(MajorId, MajorName, Department, ChairId)
StudentInterest(StudentId, InterestId)
StudentMajor(StudentId, MajorId)
Give SQL query statements for each of the following
a. Give an alphabetical list with a single column for the names of the interests that
have the category of “Music Group”.
SELECT InterestName
FROM Interests
WHERE Category = ‘Music Group’
ORDER BY InterestName
b. Give the name of the faculty member who chairs the department that offers the
major with name “Spanish”.
SELECT LastName, FirstName
FROM Faculty, Majors
WHERE FacultyID = ChairID AND MajorName = ‘Spanish’
c. Give a list of the names of students who have “Spanish” as a major.
SELECT LastName, FirstName
FROM Students S, StudentMajor SM, Majors M
WHERE S.StudentID = SM.StudentID AND SM.MajorID = M. MajorID
AND MajorName = ‘Spanish’
5
d. Give a list with two columns, the states and the number of students from the state
who are taking CS101 this term. The list should contain only states having at least
three such students. The list should be ordered by the counts with the states with
highest counts coming first. States with the same count should appear in
alphabetical order.
SELECT State, Count(*)
FROM Students
WHERE Term = ‘F10’
GROUP BY State
HAVING Count(*) >= 3
ORDER BY Count(*) DESC, State
Download