Relational DB Flashcards
- What are the three components of a database model?
Data structure → describes how data is organized
Operations → manipulates data structures
Rules → govern valid data
- What is a tuple?
a tuple is an ordered collection
- What is a set?
a set is an unordered collection of elements enclosed in braces
- {a,b,c} and {c,b,a} are the same because order doesn’t matter
- How is a relational database structure organized?
a table has a name, a fixed tuple of columns, and varying sets of rows
- a column has a name and a data type
- a row is an unnamed tuple of values. each value corresponds to a column and belongs to the columns data type
- a data type is a named set of values from which column values are drawn
Describe ‘select’
Selectselects a subset of rows of a table.
Describe ‘project’
Project eliminates one or more columns of a table.
- Describe ‘product’
- Productlists all combinations of rows of two tables.
- Describe ‘join’
- Joincombines two tables by comparing related columns.
- Describe ‘union’
- Unionselects all rows of two tables.
- Describe ‘intersect’
Intersect selects rows common to two tables.
- Describe ‘difference’
Difference selects rows that appear in one table but not another.
- Describe ‘rename’
- Renamechanges a table name.
- Describe ‘aggregate’
- Aggregate computes functions over multiple table rows, such as sum and count.
- What are the three logical constraints in relational database management that ensure data is valid?
- Unique primary key → all tables have a primary key column, or group of columns, in which values may not repeat
- Unique column names → Different columns of the same table have different names
- No duplicate rows → No two rows of the same table have identical values in all columns
- What does SQL stand for?
Structured Query Language
- What is a ‘statement’?
- A statement is a complete command composed of one or more clauses
- What is a ‘clause’?
- A clause groups SQL keywords like SELECT, FROM, and WHERE with table names
- What are some key words in SQL?
SELECT, FROM, WHERE
- How do you end a statement in MySQL?
a semi-colon, “ ; “
- What is DDL and what is it responsible for?
- Data definition language (DDL) → Defines the structure of the database
- What is DQL and what is it responsible for?
- Data query language (DQL) → Retrieves data from the database
- What is DML and what is it responsible for?
- Data manipulation language (DML)→ Manipulates data stored in a database
- What is DCL and what is it responsible for?
- Data control language (DCL) → Controls database user access
- What is DTL and what is it responsible for?
- Data transaction language (DTL) → Manages database transactions. commits data to a database, rolls back data from a database, and creates save points.
- Describe the statement
CREATE DATABASE {database name}
creates a new db
- Describe the statement
DROP DATABASE {database name}
deletes a db, including all tables
- Describe the keyword SHOW
provides information about database and its contents
- Describe some commonly used SHOW statements
- SHOW DATABASES → lists dbs available in the system
- SHOW TABLES → lists tables available in the currently selected db
- SHOW COLUMNS → Lists columns in a specified table named by a FROM clause
- SHOW CREATE TABLE → shows the CREATE TABLE statement for a given table
- In relational databases, how many values can exist in one cell?
1
- Are duplicate column names allowed?
no
- Are duplicate rows allowed?
no
- How does row order affect query status?
- No row order. The organization of the rows never affects query results data independence
Define data independence
- The result of a database query is not affected by the physical organization of data on storage devices
- Describe the Integer data type
- Integerdata types represent positive and negative integers. Several integer data types exist, varying by the number of bytes allocated for each value. Common integer data types include INT, implemented as 4 bytes of storage, and SMALLINT, implemented as 2 bytes.
- Describe the decimal data type
- Decimaldata types represent numbers with fractional values. Decimal data types vary by number of digits after the decimal point and maximum size. Common decimal data types include FLOAT and DECIMAL.
- Describe the Character data type
- Characterdata types represent textual characters. Common character data types include CHAR, a fixed string of characters, and VARCHAR, a string of variable length up to a specified maximum size.
- Describe the Date and time data types
- Date and timedata types represent date, time, or both. Some date and time data types include a time zone or specify a time interval. Some date and time data types represent an interval rather than a point in time. Common date and time data types include DATE, TIME, DATETIME, and TIMESTAMP.
- Describe the Binary data type
- Binarydata types store data exactly as the data appears in memory or computer files, bit for bit. The database manages binary data as a series of zeros and ones. Common binary data types include BLOB, BINARY, VARBINARY, and IMAGE.
- Describe the Spatial data type
- Spatialdata types store geometric information, such as lines, polygons, and map coordinates. Examples include POLYGON, POINT, and GEOMETRY. Spatial data types are relatively new and consequently vary greatly across database systems.
- Describe the Document data type
- Document data types contain textual data in a structured format such as XML or JSON.