ISYS 4283 UARK Harmon Midterm Flashcards

(69 cards)

1
Q

are established between entities in a well-structured database so that the desired information can be retrieved

A

Relationships

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

A person’s name, birthday, and social security are all examples of:

A

Attributes

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

A person, place, object, event, or concept about which the organization wishes to maintain data is called a(n)

A

entity

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

A database is an organized collection of ______ related data

A

logically

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

When normalizing, the goal is to decompose relations with anomalies to produce smaller, well-structured relations

A

True

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

The _______ states that no primary key attribute may be null

A

entity integrity rule

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

A relation is in first normal form if it has no more than one multivalued attribute

A

False

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

A primary key is an attribute that uniquely identifies each row in a relation

A

true

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

An attribute (or attributes) that uniquely identifies each row in a relation is called a:

A

primary key

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

In the figure below, the primary key for “order line” is which type of key:

A

Composite: In database design, a composite key is a candidate key that consists of two or more attributes (table columns) that together uniquely identify an entity occurrence (table row).

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

A rule that states each foreign key value must match a primary key value in the other relation is called the

A

referential integrity constraint

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

When all multivalued attributes have been removed from a relation is it said to be in

A

first normal form

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

are anomalies that can be caused by editing data in tables

A

modification

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

A relation that contains no multivalued attributes and has non-key attributes solely dependent on the primary key but contains transitive dependencies is in which normal form

A

Second

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

An appropriate datatype for one wanting a fixed-length type for last name would include:

A

Char

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

The smallest unit of application data recognized by system software is a

A

field

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

A decimal datatype would be appropriate for a zip code

A

false

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

A method for handling missing data is to

A

track missing data with special reports

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

One method to handle missing values is to substitute a value estimated with a formula

A

true

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

A relationship where the minimum and maximum cardinality are both one is a(n)

A

mandatory one

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

Data that describes the properties of other data are

A

metadata

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

What is Lisa Simpson’s Address

A

SELECT address, city, state, zip, FROM student WHERE first_name = “Lisa” AND last_name = “Simpson”;

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

How many students are named ned?

A

SELECT COUNT (*) FROM student WHERE first_name = “Ned”;

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

How many classes are there broken down by department?

A

SELECT department, COUNT(course_ID) FROM course GROUP BY department;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Where are different departments
SELECT DISTINCT departments, FROM course;
26
Add new student: Homer Simpson 742 Evergreen Terrace Springfield, OR 97475
INSERT into student( first_name, last_name, address, city, state, zip) VALUES ('Homer', 'Simpson', '742 Evergreen Terrace', 'Springfield', 'OR', '97475');
27
Update Marge Simpson's zip to 11111 & her city to Fayetteville (She's a student)
UPDATE student SET zip='11111', city='Fayetteville' WHERE first_name = "Marge", AND last_name = "Simpson";
28
Create Student Table
CREATE TABLE Student( student_ID integer not null PRIMARY KEY, first_name varchar(50) not null, Last_name varchar(50) not null, Address varchar(50), City varchar(50), State char(2), zip char(5), );
29
create student course table
CREATE TABLE student_course ( student_id integer not null FOREIGN KEY REFERENCES student(student_id), Course_id interget not null FOREIGN KEY REFERENCES course(course_id), grade decimal(3,2) not null, PRIMARY KEY(student_ID, course_ID), );
30
How many products do we stock? Label the field.
SELECT COUNT(*) AS num_prod, FROM products;
31
What was the date of the most recent order
SELECT MAX(order_date) AS lastorder, FROM orders;
32
What was the average total price of all items ordered?
SELECT AVG(quantity*item_price) AS avg_tot_price, FROM OrderItems;
33
What is an entity
Person, place, object, event, concept (often corresponds to a row in a table)
34
What are attributes?
Properties or characteristics of an entity or relationship type (often corresponds to a field in a table
35
Describe the difference between required and optional attributes
* Required- must have a value for every entity (or relationship) instance with which it is associated * Optional- may not have a value for every entity (or relationship) instance with which it is associated
36
Describe and explain relationships
– link between entities(corresponds to primary key-foreign key equivalencies in related tables) - Have cardinalities, one to one, one to many, many to many, can be mandatory or optional
37
What are primary keys?
An attribute (or combination of attributes) that uniquely identifies individual instances of an entity type. Also called Identifier key
38
What are foreign Keys
Attributes that links two tables together, refers to a primary key in another entity
39
What is the entity integrity rule?
The entity integrity rule states that for every instance of an entity, the value of the primary key must exist, be unique, and cannot be null
40
What is referential integrity rule
requires that a foreign key must have a matching primary key or it must be null.
41
Explain cardinality and the different types
The number of instances of one entity that can or must be associated with each instance of another entity: - Minimum cardinality: if zero, then optional, if one or more than mandatory - Maximum cardinality: the maximum number
41
One-to-one
Each entity in the relationship will have exactly one related entity
42
one-to-many
An entity on one side of the relationship can have many related entities, but an entity on the other side will have a maximum of one related entity
43
many-to-many
Entities on both sides of the relationship can have many related entities on the other side
44
what is an associative entity
(bridge table): Associative entity is like a relationship with an attribute, but it is also considered to be an entity in its own right. Used to resolve many to many relationships, links entities together
45
Composite keys are described as what
Composite Keys are described as what? -Composite- required 2 fields to create a unique identifier for the row, typically used when braking up many-to-many relationships. A composite key is a combination of 2 keys to make a unique identifier
46
What is data normalization?
The process of decomposing relations with anomalies to produce smaller, well-structured relations
47
What are 1NF
First normal form- no multivalued attributes, every attribute value is atomic, all relations are in 1st normal form
48
What is 2NF
1NF plus every non-key attribute is fully functionally dependent on the ENTIRE primary key -Every non-key attribute must be defined by the entire key, not by only part of the key -No partial functional dependencies
49
How to get into 2nd normal form
remove all partial transparencies
50
Partial dependency
non-key attribute dependent on part of the primary key, ex. productdescrip, prodfinish,prodprice, partial on prodID
51
transitive dependency
primary key is determinant for another attribute which in turn is a determinant for the 3rd ex. customeraddress on customername on customerID
52
Why do we normalize a database
Primarily a tool to validate and improve a logical design so that it satisfies certain constraints that avoid unnecessary duplication of data, goal is to end redundancy and avoid anomalies
53
What is 3NF
2NF plus no transitive dependencies
54
How do we get to 3NF
Remove transitive dependency Ex. taking customer ID out of OrderID and making it its own thing
55
Types of strings:
-char- fixed length( remaining space is filled with blanks) -varchar- variable length
56
Numeric strings:
-Integer- allows whole numbers -2.7 mil to 2.7 mil -tinyint- 0-255 -smallint- -32000- 32000 -bigint -decimal(p,s)- precision and scale
57
Date and time string
-datetime -date -time
58
What does “*” do in SQL
It means all columns, it is a way to retrieve all info
59
SELECT Clause
List the columns and expressions to be returned from the query, what do you want to find EX. SELECT address
60
FROM clause
indicate the table or view from which data will be obtained EX. FROM student
61
WHERE clause
indicate the conditions under which a row will be included EX. WHERE first_name="john"
62
What is the GROUP BY clause and why is it useful
is used to arrange identical data into groups with the help of some functions. GROUP BY is used with the SELECT statement ex. SELECT deptID, FROM course, GROUP BY first_name;
63
What is the HAVING clause?
restricts the results of a GROUP BY in a Select Expression. Always used with GROUP BY. HAVING Clause restricts the data on the group records rather than individual records. EX. SELECT deptID, FROM employee GROUP BY deptID HAVING AVG(Salary) >3000
64
Can you do mathematical operators in SQL
yes, you can do +,-, *, / or through SELECT or AVG(), COUNT(), MAX()
65
When preparing to create a table, one should:
Name of new table specified after CREATE statement, Name and definition of table columns separated by comma
66
INSERT INTO does what?
Adds one or more rows to a table EX. INSERT INTO customer SELECT * FROM customer WHERE state='TX'
67
What is alter table
ALTER TABLE statement allows you to change column specifications EX. ALTER TABLE vendors ADD vend_phone char (20) or DROP COLUMN vend_phone char (20)
68
What is the proper order in a SELECT statement of the following: SELECT, HAVING, GROUP BY, FROM, ORDER BY, WHERE
SELECT, FROM, WHERE, GROUP BY, HAVING, ORDER BY