Unit 11 Flashcards

1
Q

How to select something in SQL?

A

SELECT
FROM
WHERE
ORDER BY

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

How to create a table in SQL?

A

CREATE TABLE tblProduct
(
ProductID CHAR(4) NOT NULL PRIMARY KEY,
Description VARCHAR(20) NOT NULL,
Price CURRENCY
)

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

How to add a new column to a table in SQL?

A

ALTER TABLE tblProduct
ADD QtyInStock INTEGER

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

How to delete a column in SQL?

A

ALTER TABLE tblProduct
DROP QtyInStock

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

How to change the type/ length of a column?

A

ALTER TABLE tblProduct
MODIFY COLUMN Description VARCHAR (30) NOT NULL

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

How to define linked tables?

A

CREATE TABLE ProductComponent // creating table
( ProductID CHAR(4) NOT NULL,
CompID CHAR(6) NOT NULL,
Quantity INTEGER,
FOREIGN KEY ProductID REFERENCES Product(ProductID), //enforcing the relashonships
FOREIGN KEY CompID REFERENCES Component(CompID),
PRIMARY KEY (ProductID, CompID) )

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

How to insert data into a table?

A

INSERT INTO Product(ProductID, Description, Price) //note only put the ones you want to add data into
VALUES (“A345”, “Pink Rabbit”, 7.50)

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

How to update data in a table?

A

UPDATE Product
SET Description = “Blue Rabbit”, Price = 8.25
WHERE ProductID = “A345”

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

How to delete a record in SQL?

A

DELETE FROM Product
WHERE ProductID = “A345”

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

What is first normal form?

A

A data base will be in 1nf is it has no repearting attributes or grouped attributes

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

What is second normal form?

A

A database will be in 2nf if it is already in 1nf and is in a state where all of its non key attributes(columns) are dependant on/ related to the primary key.

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

What is 3rd normal form?

A

A database will be in 3nf it is alredy in 2nf and contains no attribbutes that (in addition to the primary key) ALSO depend on another attribute in the table.

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