f Flashcards
Aggregation:
Used to model a relationship involving a relationship set
Allows us to treat a relationship set as an entity set for purposes of participation in other relationships
Lowest-level ER model:
physical data model (PDM) – most detailed
is ER design subjective
Yes
Entity:
real-world object, distinguishable from other objects. An entity is described as using a set of attributes.
Reasons to use ISA:
Add descriptive attributes specific to a subclass (ex. Not appropriate for all entities in the superclass)
Identify entities that participate in a particular relationship (ex. Not all superclass entities participate)
Weak Entity:
Weak entity can be identified uniquely only by considering the primary key of another (owner) entity.
Weak entity set must have total participation in this identifying relationship set.
Weak entities only have a “partial key” (dashed underline)
The steps:
- Identify the entities
- Identify the relationships between the entities
- Determine whether a relationship is 1:1 1:M or M:N
- Determine whether participation in a relationship mandatory (At least one instance or full participation) or not
- Identify weak entities
- Identify ISA hierarchies and aggregations
- Consider possible refinements: should a concept be modeled as an entity or attribute? Should a concept be modeled as an entity or a relationship? Identifying relationships? Binary or ternary?
Mid-level ER model:
Logical data model (LDM)
In translation a relationship set to a relation, attributes of the relation must include(3):
- keys for each participating entity set (as foreign keys)
- this set of attributes forms a superkey for the relation
- all descriptive attributes
Owner entity set and weak entity set must participate in
Owner entity set and weak entity set must participate in a one-to-many relationship set (one owner, many weak entities).
Entity set:
a connection of similar entities (ex. All employees). All entities in an entity set have the same set of attributes, each entity set has a key (underlined), each attribute has a domain.
Locks and transaction design:
When you change a row, no one else can modify it until you issue a COMMIT, try not to hold locks for too long since it will slow down other sessions
Two biggest causes of contention are
locks and latches (or mutexes)
Types of contention (3):
locks
latches and mutex
buffer contention
Two ways to design transaction locking?
Pessimistic and Optimistic
Contention prevents:
Contention prevents the database from working on all of the requests that are outstanding
High-level ER model:
Conceptual data model (CDM)
Contention is another word for
bottleneck
Pessimistic locking:
works best if you think someone else is going to “grab” your row before you are finished
Hints:
You can add a hint to your SQL to change the execution plan
SELECT /* index(index name) */
Performance problems are often seen as
unacceptable response time or throughput
Are indexes good for small or large amount of the tables?
Indexes are only good for getting small amount of the table
Tuning involves
proactive monitoring and bottleneck elimination, providing room for system scalability (process more workload)
Partitioning:
Split table up to make them smaller
Execution plan:
Called explain plan or query plan. Tells you how the optimizer will execute your SQL
Transaction design:
Minimize lock duration using pessimistic and optimistic locking strategies
Histograms:
Histogram allows the optimizer to understand how the data is being distributed and make the best decision
Network overhead:
Avoid unnecessary network round trips.
Optimistic locking:
works best if you think no one else will “grab” the row
Denormalize:
merge tables to avoid joins, create “materialized views: to avoid big grouping or filtering
SQL tuning
optimizer determines execution plan
does a concatenated index have 1 or many columns?
Concatenated index has more than one column
Two ways to reduce round trips:
Use the “Array” interface in your program code
Use the stored procedures for complex interactions with the database
Should you create an index on all columns?
Do not create an index on every column
what do you violate in Denormalization?
In denormalization you violate 3NF to improve performance
Configure Memory:
use memory to avoid I/O, operations to read from memory, operations to share memory
IT Service Management (ITSM) can be used to
IT Service Management (ITSM) can be used to identify and maintain service levels
When to not use NULLS?
Do not use NULL if you will search for NULLS use something that can be indexed (N/A)
Reduce contention:
avoid contention for locks and latches
Instance tuning
avoid bottlenecks in initial design and later monitor performance
Indexes:
Create indexes on groups of columns that are queried together
Indexes speed up queries but make DML slower
Nulls:
Using nulls has significant performance implications (nulls do not take any space, nulls cannot be indexed)
Performance management tools do what?
Monitor, estimate, plan capacity, analyze, reorganize, optimize, cache, compress, sort
What can you do for optimal performance(4)?
Tune the application
Reduce contention
Configure Memory
Tune I/O
Tune the application:
choose the best data model, reduce the load on the database, tune the SQL statements
3 Things we can do to tune our application:
- Structure the tables in a way that the database would work better
- Tune the application code (Java, C++ etc.)
- Tune the SQL statements
Should you put a high or low load on a database and why?
Do not put much load on the database
When the application puts too much load on the database, and the performance decrease, it is not the database fault
When do subtypes occur?
Subtypes can occur when you are modelling things that are almost the same
Tune I/O:
use fast disks, use RAID (o + 1), use SSDs