BIS II - SQL Flashcards

1
Q

SQL

- Definition & use

A
Structured Query Language
Standard relational database
Used to 
- define and set up relations
- ton insert, alter, and to delete data 
- to query data from one or more relations
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Data Types

Tinyint

A

Binary variable (representing yes/no decisions)

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

int(m)

A

Integer numbers with an m maximum displayed places

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

float(m,d)

A

Float numbers with an m maximum displayed places and d decimal places

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

char(m)

A

Character string of length m

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

varchar(m)

A

character string of a variable length (m: maximum length)

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

date

A

Date in format YYYY-MM-DD

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

Creating a table

A
CREATE TABLE Customer 
(
Customer_id INT NOT NULL, 
Name VARCHAR(40) NOT NULL,
PRIMARY KEY (Customer_id)
)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Dropping a Table

A

DROP TABLE customer (can also be in lower case)

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

Adding new attributes

A

ALTER TABLE Customer ADD rating INT NOT NULL AFTER Discount`

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

Dropping attributes

A

ALTER TABLE Customer DROP rating

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

Inserting new data records

A

INSERT INTO Customer (Customer_id, Name, Address) VALUES (NULL, James Bond, Burgplatz 2`);

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

Altering data records

A

UPDATE Customer SET Discount= ‘0.08’ WHERE Customer.Customer_id= 1

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

Selecting an entire table

A

SELECT * FROM Customer

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

Selecting from a table

A

SELECT Name, Address FROM Customer

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

Selecting from a table with constraints

A

SELECT Customer_id, Name, Address FROM Customer WHERE rating=4

17
Q

Selecting data, additional clauses to WHERE

A

AND: displays a record if all the conditions separated by AND are true
OR displays a record if any of the conditions separated by OR is true
NOT displays a record if the condition(s) is NOT TRUE

18
Q

Selecting Data: Combining rows

A

SELECT Sales_transaction.Customer_id, Customer.Customer_name FROM Sales_transaction JOIN Customer On Sales_transaction.Customer_id=Customer.Customer_id