100 likes | 246 Views
CSCI 3328 Object Oriented Programming in C# Chapter 12: Databases and LINQ – Exercises. UTPA – Fall 2012. Objectives. In this chapter, you will do some exercises about: The relational database model LINQ to retrieve and manipulate data from a database
E N D
CSCI 3328 Object Oriented Programming in C# Chapter 12: Databases and LINQ – Exercises UTPA – Fall 2012
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
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
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
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
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.
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.
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 = …