-
Data model
- Abstract representation of the date and the associations between them
- Entity Relationship Model is the most common
-
Entity
Also known as table, simple 2D grid of data made of: attributes, fields, columns
-
Primary Key
- a non null attribute of set of sttributes that uniqely identifies each instance/row of an entity
- every entity should have a primary key
-
simple v. composite primary key
simple is one word while composite is more than one word
-
foreign key
- attribute(s) for a child instance/row of an entity that identifies the unique parent instance/row
- parents can be in the same or different entity from the child
- can be null under certain conditions (orphans)
- typically the foreign key of a child identifies parent primary key
-
ER Diagrams
standardized set of notations for representing entities atrributes, primary keys, foreign keys and relationships between them
-
degrees of a relationship
- unary- one entity
- binary-two entities
- n-ary- n entities
-
cardinality of a relationship
number of records (min and max) in each entity Y that can be associated with each record in X
-
One to Many Relationship
- 1:N
- parent child, each Y with one X
- put foreign key in the child that can be associated with each record in X the parent
-
One to one relationship
- 1:1
- spouse relationship
- put FK in Y to identify X AND define a unique index to eliminate copies
-
Many to many
- M:N
- siblings table
- create a new associative entity with 2 foreign keys to the associated records in X and Y
-
Associative Entity
convert many to many relationship into a new entity consisting of two FKs to the associated records in X and Y
-
Density of a Many to many relationship
- actual/possibe
- associative entity works well with low density
-
N-ary Relationships
Create a new associaive entity or super bridge w/ N foreign keys to point to the N sides of the relationships
-
Normalization
process of eliminated redundant and inter dep0endent date from a database in order to improve consistency, maintainability, storage, efficiency and scalability
-
Normalization examples
- duplicate data is eliminated
- pre calculated calues are eliminated
- fewer secondary indives per table
-
disadvantages to normalization
more tables, non intuitive, query complexity, slower queries
-
What to avoid in table making
- multi value fields (comma deliminated, compud fields, list fields
- Repeating values
- compute field
- multilevel dependencies
-
Kth Normal Form
- !NF-all data must be accessible by a primary key, each filed must be scalar (single value), no repeating columns
- 2NF-every non key field must depends on the entire PK
- 3NF- every non key field must depends only on the PK
-
1NF
primary key for every table
-
2NF
every non key field must depend on the entire PK
-
-
denormalization
- intentionally violating rules to improve performance
- only do when performance is ciritical
-
-
CREATE
defines new object
-
ALTER
modify the definition of an existing object
-
DROP
throw away an object
-
Data Manipulation Language
-
SELECT
answers quations, generates reports, etc
-
-
UPDATE
modify existing records
-
DELETE
throw away records
|
|