Chapter 8 : Database Flashcards

1
Q

What does database provides?

A
  1. Provides a structured manner in which data can be stored, retrieve and for further processing
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What state is data stored inside variable?

A
  1. Volatile
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a Database Management System?

A
  1. Software that manages large collections of data
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is Database Management System designed to?

A
  1. Store Data
  2. Retrieve Data
  3. Manipulate Data
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

List out the 3 layer manipulation for C# application can interact with

A
  1. Application
    • Interacts with the user and sends instructions to DBMS
  2. DBMS
    • Works directly with the data and sends the result back to the application
  3. Data
    • The data stored in DBMS
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the data type used to represent True / False value
1. SQL Server Data Type
2. C#

A
  1. bit
  2. bool
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the data type used to represent date and time value
1. SQL Server Data Type
2. C#

A
  1. datetime
  2. DateTime
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the data type used to represent decimal value with total digits appearing after the decimal point
1. SQL Server Data Type
2. C#

A

1.decimal ( t , d )
2. decimal

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the data type used to represent real numbers
1. SQL Server Data Type
2. C#

A
  1. float
  2. double
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the data type used to represent an integer number
1. SQL Server Data Type
2. C#

A
  1. int
  2. int
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the data type used to represent currency?
1. SQL Server Data Type
2. C#

A
  1. money
  2. decimal
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is the data type used to represent a fixed-length Unicode string with a maximun length of n character?
1. SQL Server Data Type
2. C#

A
  1. char(n)
  2. string
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the data type used to represent a variable-length Unicode string with a maximun length of n character?
1. SQL Server Data Type
2. C#

A
  1. varchar(n)
  2. string
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What does most database have?

A
  1. Primary Key
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is Primary Key used? ( 2 )

A
  1. Column that can be used to identify a specific row
  2. The column that is designed as the primary key must hold a unique value for each row
  • Example
    EmployeeID, Social Security Number, Invoice Number, Sales Order Number
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How to solve issues for data I want to store in a table does not contain any unique items that can be used as a primary keys? ( 2 )

A
  1. Create an identity column specifically to serve as the primary key ( Identify Column )
  2. Identify column typically contain integers
  3. Each time a new row is addded to the table, the DBMS automatically assigns a unique value to the identify column
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What is a table?

A
  1. 2 dimentional container made of rows and columns
  • Data stored in a database are organized into tables, rows and columns
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What is a row or a column?

A
  1. A row is a complete set of information about a single term
  2. A column holds an individual piece of information about the item ( Metadata )

Name Phone
Jil 555-5678

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

List out the layers that .NET applications uses to connect to a database

A
  1. Application
  2. Binding Source
    • A component that can connect user interface controls directly to a dataset
  3. Dataset
    • Gets a copy of a table from the table adapter and keeps the copy of the table in memory
  4. Table Adapter
    • Connets to a data source and retrieves data from a table in a data source
  5. Data Source
    • A source of data with which the application can work
20
Q

What databases that Visual Studio provides that make it easy to create and configure the database?

A
  1. Server-Based Database
21
Q

What information that the connection string includes?

A
  1. Include information on data provides to be used
22
Q

What is the syntax for connection string?

A

SqlConnection connection = new SqlConnection(connectionString)

23
Q

What is the full name for SQL?

A
  1. Structured Query Language
  • Standard language for working with database management system
24
Q

What parts of SQL involves Data Definition Language? ( 3 )

A
  1. Create
  2. Alter
  3. Drop DB & Table
25
Q

What parts of SQL involves Data Manipulation Language? ( 4 )

A
  1. Create
  2. Read
  3. Update
  4. Delete Records
26
Q

List out 2 syntax to insert record into SQL

A

INSERT INTO table_name
VALUES ( value1, value2, … )

INSERT INTO table_name(col1, col2, col3, …)
VALUES ( value1, value2, value3)

INSERT INTO Book
VALUES ( 1, ‘Learn ABC’, 20.00 )

27
Q

How to read records from SQL?

A

SELECT column FROM table_name

SELECT Description FROM Product
SELECT Description, Price FROM Product
SELECT * FROM Product ( Every Column )

28
Q

How to select values from a table where the value isn’t repeated?

A
  1. Use SELECT DISTINCT

SELECT DISTINCT Title, Price FROM Book;

29
Q

What clause that I need to use to narrow the list down to few selected rows in the table? Also point out the format

A
  1. WHERE clause

SELECT Columns FROM Table WHERE Criteria
SELECT * FROM Product WHERE Price > 20.00

30
Q

How to retrieve all the columns from only rows where the description is “Denim Jeans”?

A

SELECT * FROM Product WHERE Description = “Denim Jeans”

31
Q

List out the Relational Operators that WHERE clause can use ( 9 )

A
  1. =
  2. <> - Not Equal
  3. >
  4. > =
  5. <
  6. <=
  7. BETWEEN
  8. LIKE
  9. IN
32
Q

List out the Logical Operators that WHERE clause can use ( 3 )

A
  1. AND
  2. OR
  3. NOT
33
Q

What does the AND operators requires? Give an example on how to select price > 20 and price < 30

A
  1. Requires both search criteria to be true for a row to be qualified as a match
  2. SELECT * FROM Product WHERE Price > 20 AND Price < 30
34
Q

What does the Or operators requires? Give an example on how to select price > 20 or product number < 10

A
  1. Requires that either of the search criteria to be true for a row to be qualified as a match
  2. SELECT * FROM Product WHERE Price > 20 OR Product_Number < 10
35
Q

What does the NOT operator disqualify? Give an example on how to select price where the price is not 20

A
  1. Disqualify a search criteria
  2. SELECT * FROM Product WHERE NOT Price = 20
36
Q

What does the LIKE operator allows?

A
  1. Allows me to do a search on a pattern rather than specifying exactly what is desired
  • Both “Oxford Shirt” and “UNIQLO Shirt” both contains the string shirt
37
Q

How to write SQL Statement to search on Description has the string Shirt?

A

SELECT * FROM Product WHERE Description LIKE “%Shirt%”

38
Q

List out 2 wildcard character that the LIKE operator can use

A
  1. %
  2. _ ( Underscore )
39
Q

What does % represents when using the LIKE operator?

A
  1. Any sequence of zero or more characters

SELECT * FROM Product WHERE Description LIKE ‘%Shirt%’

40
Q

What does _ represents when using the LIKE operator?

A
  1. Represents a single character

SELECT * FROM Product WHERE Product_Number LIKE ‘2-0

  • Where product number have 2-0 ( 21-01 , 22-02, … )
41
Q

How to select a customer name that start with a?

A
  1. WHERE Customer_Name LIKE “a%”
42
Q

How to select a customer name that ends with a?

A
  1. WHERE Customer_Name LIKE “%a”
43
Q

How to select a customer name that have or in any position?

A
  1. WHERE Customer_Name LIKE “%or%”
44
Q

How to select a customer name that have r in second position?

A
  1. WHERE Customer_Name LIKE “_r%”
45
Q

How to select a customer name that start with a and are least 3 characters in length?

A
  1. WHERE Customer_Name LIKE “a_%_%”
  2. WHERE Customer_Name LIKE “a___%”
46
Q

How to select a customer name that start with a and end with o?

A
  1. WHERE CustomerName LIKE “a%o”
47
Q

Until Slide 30