✅ Successfully connected to MySQL server
- Host: localhost:3306
- User: root
- Database: mobile_specs
- pass: bbbb
- All tables created and populated with sample data
The original CSV with 67+ columns has been normalized into 15 related tables following 3NF and BCNF principles.
- Purpose: Eliminates brand name redundancy
- Key: brand_id (Primary Key)
- Normalization: Removes partial dependency on brand name
- Purpose: Core device information
- Key: phone_id (Primary Key)
- Foreign Keys: brand_id → brands
- Unique Constraint: (brand_id, model) prevents duplicate models per brand
- Eliminates chipset redundancy
- Groups architecture and fabrication with chipset name
- Normalizes OS name, version, and UI interface
- Unique constraint on (os_name, os_version)
- Simple lookup tables for categorical data
- Eliminates string repetition
- Dependencies: All non-key attributes depend only on phone_id
- Foreign Keys: References chipsets, OS, display_types, storage_types, ram_types
- BCNF Compliance: All determinants (phone_id) are candidate keys
- Purpose: Groups all display-related attributes
- Dependencies: All attributes functionally dependent on phone_id only
- 3NF: No transitive dependencies
- Purpose: Physical dimensions and durability specs
- Dependencies: height, width, thickness, weight all depend only on phone_id
- Purpose: Camera and video recording capabilities
- Dependencies: All camera attributes depend only on phone_id
- Purpose: Audio jack and speaker information
- Dependencies: Audio features depend only on phone_id
- Purpose: Miscellaneous features (GPS, sensors, SIM, etc.)
- Dependencies: All features depend only on phone_id
- Relationship: One phone can have multiple colors
- Junction Table: Resolves M:N relationship
- Unique Constraint: (phone_id, color_name) prevents duplicates
- Relationship: One phone can have multiple price variants
- Purpose: Handles different storage/RAM configurations with different prices
- Dependencies: Price information depends on phone_id + variant
- Atomic Values: All columns contain single, indivisible values
- No Repeating Groups: Colors and price variants moved to separate tables
- Unique Rows: Primary keys ensure uniqueness
- 1NF Compliance: ✅
- No Partial Dependencies: All non-key attributes depend on entire primary key
- Example: In
phone_specifications, RAM and storage depend on complete phone_id, not partial key
- 2NF Compliance: ✅
- No Transitive Dependencies: Non-key attributes don't depend on other non-key attributes
- Example: Brand name doesn't depend on model; moved to separate
brandstable
- 3NF Compliance: ✅
- All Determinants are Candidate Keys: Every determinant is a superkey
- Example: In all tables, only primary keys determine other attributes
-
Oppo K13 Turbo Pro (512GB)
- 12GB RAM, 512GB storage, 7000mAh battery
- Colors: Black Warrior, Purple No. 1, Knight Silver
- Prices: ₹56,000 (512GB), ₹46,000 (256GB)
-
Samsung Galaxy M36
- 6GB RAM, 128GB storage, 5000mAh battery
- Colors: Orange Haze, Velvet Black, Serene Green
- Price: ₹29,500
- Data Integrity: Foreign key constraints prevent invalid data
- Storage Efficiency: Eliminates redundant brand names, chipset details
- Consistency: Single source of truth for each data element
- Scalability: Easy to add new phones without data duplication
- Query Flexibility: Can easily join tables for complex queries
- Maintenance: Updates to brand info only need single table change
- Indexes Created: On foreign keys and frequently queried columns
- Appropriate Data Types: DECIMAL for prices, BOOLEAN for flags
- Constraints: UNIQUE constraints prevent data inconsistencies
-- Get phone specs with brand info
SELECT p.model, b.brand_name, ps.ram_gb, ps.internal_storage_gb, ps.battery_capacity
FROM phones p
JOIN brands b ON p.brand_id = b.brand_id
JOIN phone_specifications ps ON p.phone_id = ps.phone_id;
-- Get phone colors and pricing
SELECT p.model, GROUP_CONCAT(pc.color_name) as colors, pp.price_unofficial
FROM phones p
LEFT JOIN phone_colors pc ON p.phone_id = pc.phone_id
LEFT JOIN phone_pricing pp ON p.phone_id = pp.phone_id
GROUP BY p.phone_id, pp.pricing_id;The normalized database successfully transforms the flat CSV structure into a relational model that maintains data integrity, eliminates redundancy, and supports efficient querying while complying with 3NF and BCNF requirements.