Database Reference
In-Depth Information
information such as student names, classes that the students are enrolled in, the students' advi-
sors, and so on. hese views can be created by selecting the data from the tables STUDENT,
CLASS, FACULTY, and STUDENT_CLASS as shown in the following tasks.
TASK 1: CREATING VIEW USING SQL DATABASE
Let us create a view called STUDENT_ADVISOR_VIEW.
1. On your local computer, log on to Windows Azure through the URL
https:// yourserver .database.windows.net
where yourserver is your SQL Database server name.
2. Enter the database name Class_Registration . hen, enter your user name and pass-
word to log on to Windows Azure SQL Database.
3. Once you have logged on, click the New Query icon at the upper-left corner of your
screen.
4. Enter the following SQL statement to create the view STUDENT_ADVISOR_VIEW:
CREATE VIEW STUDENT_ADVISOR_VIEW
AS
SELECT S.FirstName, S.LastName, F.LastName As [Advisor]
FROM STUDENT S JOIN FACULTY F ON S.FacultyID = F.FacultyId
5. Highlight the code and click Run . As shown in Figure 8.4, the view STUDENT_
ADVISOR_VIEW is successfully created.
6. To see how the view works, enter the following SQL statement:
SELECT * FROM STUDENT_ADVISOR_VIEW
Highlight the code and click Run . Figure 8.5 shows that the view returns the full names
of the students with their advisors' last names.
Figure 8.4
Create STUDENT_ADVISOR_VIEW.
Search WWH ::




Custom Search