Quiz 1 Flashcards
(43 cards)
What is a database?
- Collection of files
- Predefined structure
- Optimized for efficient retrieval
How are databases different from data files?
- Structure for efficient retrieval
- Consistency: no contradictions
- Computer crash: database handles it
- Security
- Concurrency
DBMS
Collection of programs that allow user to create, maintain, and query a database.
What is the new philosophy regarding data and programs?
All about the data. Data is persistent, more important than the programs that access it.
Four steps for building and using a relational databases
- Design the schema: database design
- Create the schema with DDL (data design language)
- Load the database with initial data
- Query and updates
Example SQL for creation of schema
CREATE TABLE STUDENT(
NAME char(30) SID Int NOT NULL GPA float );
Define a query
In a high level language, NOT an algorithm.
- Easy to formulate
- Just because a query looks easy does not mean efficient retrieval
Difference between DDL and DML
DDL (Data design language): This handles the design of the database.
DML (Data Manipulation language): For queries and updates.
- SQL can be used for both of these
List names and GPA of students greater than 32 using SQL
SELECT name,gpa FROM Student WHERE gpa > 3.2
Define the result of a query
- The result is a TABLE (or a view)
- It is closed mathematically
What are the three theoretical bases of SQL?
- Set theory
- Relational algebra
- Predicate calculus
Define the relational model
- Model that stores all its data in interconnected tables.
- High level query language
- Theoretical basis consisting of relational algebra and set theory
- Basic construct is a TABLE (relation)
Define rows and columns in relational database design.
Rows: Tuple
Columns: Attributes
- GPA would be an attribute NAME
- 3.75 would be an attribute VALUE
- Each attribute has a type, NULL being special
What two values can there be for NULL in relational database design?
Unknown and undefined
True or false: Someone with a NULL GPA would still be listed in the following queries: SELECT * FROM Students WHERE GPA Not 3.5 SELECT * FROM Students WHERE GPA > 3.5 SELECT * FROM Students WHERE GPA
False
Define schema
Structural description of table
Define instance
Actual contents of table at that time
Does ordering of the tuples matter?
No, and that goes back to set theory. {1,2,3,4} = {2,4,3,1}
Does ordering of the columns matter?
Yes, if attribute names are not specified. The following statement would not work without ordering of columns. INSERT INTO Students VALUES (‘Smith’, 17, 3.8, 1)
True or false: Every tuple MUST be unique.
True
Define a “Key”
A set of attributes whose value is unique in each tuple
What are the different types of keys?
Primary key: Only one candidate key can become a primary key. Underlined in schema.
Candidate key: A set of attributes that qualify as a unique key in a database. Each one can qualify as a primary key.
What are set members in relational database design?
All of the tuples in the table
A union B
Everything in A, B, and the part that intersects A and B.