Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSCI 3328 Object Oriented Programming in C# Chapter 12: Databases and LINQ – Exercises 1 Xiang Lian The University of Texas Rio Grande Valley Edinburg,

Similar presentations


Presentation on theme: "CSCI 3328 Object Oriented Programming in C# Chapter 12: Databases and LINQ – Exercises 1 Xiang Lian The University of Texas Rio Grande Valley Edinburg,"— Presentation transcript:

1 CSCI 3328 Object Oriented Programming in C# Chapter 12: Databases and LINQ – Exercises 1 Xiang Lian The University of Texas Rio Grande Valley Edinburg, TX 78539 xiang.lian@utrgv.edu

2 Objectives In this chapter, you will do some exercises about: –The relational database model –LINQ to retrieve and manipulate data from a database –Data binding to display or update data between GUI controls and databases 2

3 Multiple Choice The international standard database query language is ________. –A. LINQ B. C# C. SQL D. XML A table in a relational database consists of ____ and ____ in which values are stored. –A. rows … columns B. keys … records C. array … collection D. bits and characters The _____uniquely identifies each row in a relational database table. –A. foreign key B. attribute C. primary key D. view The _______control displays data in a table that correspond to rows and columns of the underlying data source. –A. DataSource B. DataContext C. DataBinding D. Database 3

4 Multiple Choice (cont'd) A relational database can be manipulated in LINQ to SQL via a(n) _________ object, which contains properties for accessing each table in the database. –A. LINQ to SQL B. SQL to LINQ C. SQL to XML D. Database Merging data from multiple relational database tables is called _____ the data. –A. selecting B. projecting C. where D. joining A(n) _________is a column (or groups of column) in a relational database table that matches the primary-key column (groups of column) in another table. –A. foreign key B. attribute C. primary key D. view The _______ property of a control specifies where it gets the data it displays. –A. DataSource B. DataContext C. DataBinding D. Database 4

5 Multiple Choice (cont'd) The optional _____ clause in a SQL SELECT query specifies selection criteria. –A. WHERE B. SELECT C. FROM D. ORDER BY The optional _____ clause in a SQL SELECT query specifies the order in which rows –A. WHERE B. SELECT C. FROM D. ORDER BY 5

6 True / False Statements Providing the same value for a foreign key in multiple rows causes the DBMS to report an error. Providing a foreign-key value that does not appear as a primary-key value in another table is an error. The result of a SQL query can be sorted in ascending or descending order. LINQ to SQL automatically saves changes made back to the database. 6

7 True / False Statements (cont'd) Only SQL UPDATE statement can change the data in a database. SQL SELECT queries can merge data from multiple relational database tables. A SQL DELETE statement deletes only one row in a relational table. 7

8 Display Table In the example of Books database in this chapter, create an LINQ query that changes the DataSource property of authorBindingSource to contain only the specified authors "Xiang Lian". –private BooksDataContext database = new BooksDataContext(); –authorBindingSource.DataSource = … 8

9 9

10 Happy Thanksgiving Day! 10

11 11


Download ppt "CSCI 3328 Object Oriented Programming in C# Chapter 12: Databases and LINQ – Exercises 1 Xiang Lian The University of Texas Rio Grande Valley Edinburg,"

Similar presentations


Ads by Google