02 - Relational Databases Flashcards
(31 cards)
What are:
Attributes?
Columns. Allowed data (e.g. INT, STRING, etc) in an attribute is called attribute domain.
What are:
Tuples?
records. A record in a table is a row, with the same number of attributes (columns). Important: Each tuple within a table needs to be unique as required by the relational model.
What are: Schema?
(meta-data) - Specification of how data is to be structured logically, defined at setup, rarely change. E.g. Student (SID int, name string, age int, gpa real)
What are: Instance?
Content of a table, changes rapidly, but always conforms to the schema.
What is a key?
a set of one or more attributes (columns) in the table that have certain properties.
Explain: Compound key?
Including two or more attributes
Explain: Superkey?
No two tuples have the same values. Key attributes that can uniquely identify a row. Several super keys can present in a table.
Explain: Candidate key?
It’s a minimum super key. A super key reduced to the least amount of attributes needed to uniquely identify a row.
Explain: Primary key?
Used to uniquely identify of find the tuples in a table, every tuple in a relational database has its own primary key. Normally it will be chosen from one of the primary keys.
Explain: Secondary Key?
Used to look up tuples, not uniqueness
Explain: Foreign Key?
used as constraint
What is an index?
database structure, quicker and easier to find tuples based on values in one or more attributes. Not the same as key.
What are: Constraints?
Related to a particular attribute in a table. Constraints are the rules enforced on the data columns of a table. These are used to limit the type of data that can go into a table.
Attribute required. Special value null represents an empty value.
Explain: Primary Key Constraints?
Entity integrity. No two records can have identical values for the primary key attribute of a table. All of the attributes that make up the primary key have non-null values.
Explain: Foreign Key Constraints?
Foreign key: refer to a key in another table. Referential integrity constraint. A tuples’ value in one or more attributes in one table must match the values in another table.
DB Operations: Selection?
Select some or all of the tuples in a table. Ex. Select only the students tuples where their gpa is greater than 2.5.
DB Operations: Projection?
Drops attributes from a table. Ex. list only students name and not their ages.
DB Operations: Union?
Combines tables with similar columns and removes duplicates.
DB Operations: Intersection?
Finds the records that are the same in two tables.
DB Operations: Difference?
Selects the tuples in one table that are not in a second table
DB Operations: Cartesian Product?
Creates a new table containing every tuples in a first table combined with every tuples in a second table.
DB Operations: Join?
Tuples in one table are paired only with those in the second table if they meet some conditions. Similar to cartesian product.
Ex: Student <-> Enroll = {(Rian, COMP40110), (Rian,COMP40120), (Alfie,COMP40120), (Alfie,COMP41430),…}
DB Operations: Divide?
Opposite of the Cartesian product. Uses one table to partition the tuples in another table.
How can you make DB retrevial faster?
keys & indexing