Module 04 - Data Modeling Flashcards
Accessing table structures
Count rows
SELECT COUNT (*)
Examing columns (Acessing table structures)
SELECT *
FROM [TABLE]
WHERE ROWNUM <=
Checking referential integrity constraints
Given two tables with an assumed foreign key constraint:
SKU_DATA (SKU, SKU_Description, Department,Buyer)
INVENTORY (WAREHOUSEID, SKU, SKU_Description ,QUANTITYONHAND, QUANTITYONORDER)
Where INVENTORY.SKU must exist in SKU_DATA.SKU
}To find any foreign key values that violate the foreign key constraint:
}
SELECT SKU
FROM INVENTORY
WHERE SKU NOT IN
(SELECT SKU
FROM SKU_DATA);
Normalization vs Denormalization
For updateable DB: Normalization
For read-only DB: Denormalization
Read-only databases
Are nonoperational databases using data extracted from operational databes.
Used on querying, reporting, and datamining applications
Denormalization
Is the joining of the data in normalized tables prior to storing the data. The data is then stored in nonnormalized data
Common design problems
Checking for NULL values
SELECT COUNT(*) AS QuantityNullCount
FROM ORDER_ITEM
WHERE Quantity IS NULL;
Multivalue problem
The multivalue, multicolumn problem occurs when multiple values of an attribute are stored in more than one column.
}Solution = like the 4NF solution for multivalued dependencies, use a separate table to store the multiple values.
Inconsistent values problem
Inconsistent values occur when different users, or different data sources, use slightly different forms of the same data value
Detection method:
SELECT SKU_Description, COUNT(*) AS NameCount
FROM SKU_DATA
GROUP BY SKU_Description;
Missing values problem
A missing value or null value is a value that has never been provided.
In a database table, a null value appears in upper case letters as NULL.
General-purpose remarks columns
A general-purpose remarks column is a column with a name such as:
- Remarks
- Comments
- Notes
It often contains important data stored in an inconsistent, verbal, and verbose way.
- A typical use is to store data on a customer’s interests.
Such a column may:
- Be used inconsistentlyHold multiple data items