| | 1 | = Complex DB Reports (SQL, Stored Procedures, Relational Algebra) = |
| | 2 | |
| | 3 | === Price-to-Performance Efficiency Analysis === |
| | 4 | |
| | 5 | Report on which builds have the most computing power per dollar spent using a "price-to-performance index" calculated with the following formula: |
| | 6 | * (CPU Cores * CPU Base Clock) + (GPU VRAM * 100) |
| | 7 | |
| | 8 | **SQL:** |
| | 9 | |
| | 10 | {{{ |
| | 11 | WITH cpu_per_build AS ( |
| | 12 | SELECT |
| | 13 | b.id AS build_id, |
| | 14 | c.name AS cpu_model, |
| | 15 | cpu.cores, |
| | 16 | cpu.base_clock |
| | 17 | FROM build b |
| | 18 | JOIN build_component bc ON b.id = bc.build_id |
| | 19 | JOIN components c ON bc.component_id = c.id |
| | 20 | JOIN cpu ON c.id = cpu.component_id |
| | 21 | WHERE c.type = 'CPU' |
| | 22 | ), |
| | 23 | gpu_per_build AS ( |
| | 24 | SELECT |
| | 25 | b.id AS build_id, |
| | 26 | c.name AS gpu_model, |
| | 27 | gpu.vram |
| | 28 | FROM build b |
| | 29 | JOIN build_component bc ON b.id = bc.build_id |
| | 30 | JOIN components c ON bc.component_id = c.id |
| | 31 | JOIN gpu ON c.id = gpu.component_id |
| | 32 | WHERE c.type = 'GPU' |
| | 33 | ) |
| | 34 | |
| | 35 | SELECT |
| | 36 | b.name AS build_name, |
| | 37 | cpu.cpu_model, |
| | 38 | gpu.gpu_model, |
| | 39 | b.total_price, |
| | 40 | (cpu.cores * cpu.base_clock + gpu.vram * 100) AS performance_score, |
| | 41 | ROUND( |
| | 42 | (cpu.cores * cpu.base_clock + gpu.vram * 100), |
| | 43 | 4 |
| | 44 | ) AS price_to_performance_index |
| | 45 | FROM build b |
| | 46 | JOIN cpu_per_build cpu ON b.id = cpu.build_id |
| | 47 | JOIN gpu_per_build gpu ON b.id = gpu.build_id |
| | 48 | WHERE b.total_price > 0 |
| | 49 | ORDER BY price_to_performance_index DESC |
| | 50 | LIMIT 20; |
| | 51 | }}} |
| | 52 | |
| | 53 | **Relational algebra:** |
| | 54 | |
| | 55 | {{{ |
| | 56 | cpu_per_build = |
| | 57 | π_{b.id → build_id, |
| | 58 | c.name → cpu_model, |
| | 59 | cpu.cores, |
| | 60 | cpu.base_clock |
| | 61 | } ( |
| | 62 | σ_{c.type = 'CPU'} ( |
| | 63 | (((build b |
| | 64 | ⋈_{b.id = bc.build_id} build_component bc) |
| | 65 | ⋈_{bc.component_id = c.id} components c) |
| | 66 | ⋈_{c.id = cpu.component_id} cpu) |
| | 67 | ) |
| | 68 | ) |
| | 69 | |
| | 70 | gpu_per_build = |
| | 71 | π_{b.id → build_id, |
| | 72 | c.name → gpu_model, |
| | 73 | gpu.vram |
| | 74 | } ( |
| | 75 | σ_{c.type = 'GPU'} ( |
| | 76 | (((build b |
| | 77 | ⋈_{b.id = bc.build_id} build_component bc) |
| | 78 | ⋈_{bc.component_id = c.id} components c) |
| | 79 | ⋈_{c.id = gpu.component_id} gpu) |
| | 80 | ) |
| | 81 | ) |
| | 82 | |
| | 83 | λ_20 ( |
| | 84 | τ_{price_to_performance_index DESC} ( |
| | 85 | π_{b.name → build_name, |
| | 86 | cpu.cpu_model, |
| | 87 | gpu.gpu_model, |
| | 88 | b.total_price, |
| | 89 | (cpu.cores * cpu.base_clock + gpu.vram * 100) → performance_score, |
| | 90 | ROUND((cpu.cores * cpu.base_clock + gpu.vram * 100), 4) → price_to_performance_index |
| | 91 | } ( |
| | 92 | σ_{b.total_price > 0} ( |
| | 93 | ((build b |
| | 94 | ⋈_{b.id = cpu.build_id} cpu_per_build cpu) |
| | 95 | ⋈_{b.id = gpu.build_id} gpu_per_build gpu) |
| | 96 | ) |
| | 97 | ) |
| | 98 | ) |
| | 99 | ) |
| | 100 | }}} |