Test 2 Notes Flashcards
Relational algebra
a theory that uses algebraic structures with well-founded semantics for modeling data and defining queries.
Sets
a set is a collection of elements
{a,b,c},{a,d,e,f} ← no duplications
Bags
collection of elements with duplications
Query
a function over relations; Q(R1,…,Rn) = Rresult
Because the result of a query is a relation it can be used as input to another query. → nested queries
Set Operations
Set union: It is the set of all elements in the collection.
Set intersection: it is the set of all objects that are members of both sets A and B
Set difference; S-T is the set that consists of elements of S which are not elements of T
Relational Algebra Operators
Selection (sigma): takes the horizontal subset of rows of a single table
Projection (pi): takes a vertical subset from the columns of a single table
Cross product (X)
Join (infinity): a combination of cross product, selection, and projection
Union (U)
Set diff (-)
Intersection(Upside down U)
Selection operator
Selection operator, (sigma) is to specify the rows to be retained from input relation. It takes the horizontal subset of rows of a single table that satisfies a particular condition.
Projection
(pi): vertical subset from columns of single table
Cross product(X)
Merges both tables together
Join (infinite looking thing)
combination of cross product, selection, and projection.
Union
A UNION B, this will simply add A and B together, but they must be union compatible. To combine result-set of two or more SELECT statements.
Compatibility test
A and B have same number of fields or attributes, and field in each schema has same type.
Set difference
A and B must be compatible once again, defines relation consisting of tubles in A but not in B.
Intersection
Must be compatible, gets a relation consisting of set of all tuple which occur in both A and B
Database design consists of
Requirement analysis, Architecture design, Implementation, Testing, Maintenance.
Database Design Process
Phase 1: Conceptual Model
Phase 2: Relational Model
Phase 3: Normalization
Phase 4: Physical Schema
Entities
An entity is an object or a class of real world objects having common characteristics and properties.
Attribute
An attribute is a characteristic of an entity or relationship
Relationship
an association among two or more entities
Every entity must have a primary key (T/F)
True
ERD (Entity Relationship Diagram)
a diagram that shows relationships of entity sets stored in a database. It is a conceptual diagram. Crucial to categorize what are entities in db design.
Relational schema
a set of relational tables and associated items that are related to one another
Entity-relationship model
A high level data model used to determine data elements and relationship for specified system
Relational model
a model that represents the database as a collection of relations. A relation is nothing but a table.
ER Model shows real world objects, for anyone, entities attributes relationships and arrows, conceptual or high level.
(T/F)
True
Relational Model does not show objects in tables and how they relate, for programmers, tables, columns, domains, Representational. (T/F)
False
Conceptual model procedure
Step 1: identify entities
Step 2: decide attributes for entity
Step 3: decide datatype for attribute
Step 4: build entity relationships diagrams
Step 5: Create relational schemes - design primary and foreign keys
Step 6: create physical database
Step 7: develop test cases for testing
Weak entities
cannot exist by itself. Depends on strong entity to ensure existence. Has partial discriminator key (no primary key), double rectangle.
Strong entity
does not depend on any other entity for existence. Is also known as an independent entity (Single rectangle)
Key attribute
uniquely identifies an entity
Composite attribute
combination of other attributes