-- Insert sample categories INSERT INTO kategorijos (pavadinimas, aprasymas) VALUES ('Elektronika', 'Kompiuteriai, telefonai ir kiti įrenginiai'), ('Biuro reikmenys', 'Popierius, rašikliai ir kita'); -- Insert sample products INSERT INTO prekes (kategorija_id, pavadinimas, kaina, kiekis) VALUES (1, 'Nešiojamas kompiuteris Pro', 1200.50, 5), (1, 'Išmanusis telefonas X', 850.00, 10), (2, 'A4 formato popierius (500 lapų)', 5.99, 100); Use code with caution. Copied to clipboard 4. Basic Query Examples
Define your tables with primary keys, foreign keys, and constraints to ensure data integrity. Common tools like dbForge SQL Complete can help with advanced formatting and autocompletion of these T-SQL codes.
Including common queries can serve as documentation for other developers. You can also use tools like dbForge Documenter to generate comprehensive documentation in HTML or PDF formats. Duombaze.sql
Below is a complete draft for a generic system (e.g., a simple Content Management or Inventory system) that you can adapt. 1. Database Initialization
: Always use NOT NULL for required fields and UNIQUE for identifiers like emails to prevent duplicates. Common tools like dbForge SQL Complete can help
: For larger datasets, consider adding indexes to columns frequently used in WHERE clauses to improve performance.
This section ensures the database exists and that you are working within the correct context. Below is a complete draft for a generic system (e
-- Select all products with their category names SELECT p.pavadinimas AS Preke, p.kaina, k.pavadinimas AS Kategorija FROM prekes p LEFT JOIN kategorijos k ON p.kategorija_id = k.id; -- Find products with low stock (less than 10) SELECT * FROM prekes WHERE kiekis < 10; Use code with caution. Copied to clipboard Best Practices for Your SQL Draft