Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [MySQL]optymalizacja struktury, Spis godzin otwarcia sklepów
KsaR
post
Post #1





Grupa: Zarejestrowani
Postów: 520
Pomógł: 102
Dołączył: 15.07.2014
Skąd: NULL

Ostrzeżenie: (0%)
-----


  1. /**
  2.  * sklep
  3.  */
  4. CREATE TABLE IF NOT EXISTS `stores` (
  5. `store_id` TINYINT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
  6. `store_name` VARCHAR(255) CHARSET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL
  7. ) ENGINE=MyISAM CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
  8.  
  9. INSERT INTO `stores` (`store_name`) VALUES
  10. ('TESCO');
  11.  
  12. /**
  13.  * dni tygodnia w ktorych sklep jest czynny wraz z id godzin.
  14.  */
  15. CREATE TABLE IF NOT EXISTS `store_week` (
  16. `store_id` TINYINT UNSIGNED NOT NULL,
  17. `store_day` TINYINT UNSIGNED,
  18. /**
  19.   * `hours`.`hour_id` ↓
  20.   */
  21. `store_from` TINYINT UNSIGNED,
  22. `store_to` TINYINT UNSIGNED
  23. ) ENGINE=MyISAM
  24. CHARSET=utf8mb4
  25. COLLATE=utf8mb4_general_ci;
  26.  
  27. INSERT INTO `store_week` (`store_id`, `store_day`, `store_from`, `store_to`) VALUES
  28. (1, 1, 1, 0),
  29. (1, 2, 1, 0),
  30. (1, 3, 1, 0),
  31. (1, 4, 1, 0),
  32. (1, 5, 1, 0),
  33. (1, 6, 1, 0),
  34. (1, 7, 2, 0);
  35.  
  36. /**
  37.  * godziny.
  38.  */
  39. CREATE TABLE IF NOT EXISTS `hours` (
  40. `hour_id` TINYINT UNSIGNED NOT NULL,
  41. `hour` SMALLINT UNSIGNED NOT NULL
  42. ) ENGINE=MyISAM CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
  43.  
  44. INSERT INTO `hours` (`hour_id`, `hour`) VALUES
  45. (0, 0000),
  46. (1, 0600),
  47. (2, 0700);


Planuję zrobić spis sklepów wraz z godzinami otwarcia od/do.
Czy te tabele są dobrze znormalizowane?

Przy okazji,
Umie ktos to dobrze pobrać? (IMG:style_emoticons/default/biggrin.gif) próbuję już kilka godzin i nadal nie wyszło.
(Z join, union, ...group by, ...)
Konkretniej:

`stores`.`store_name`,
(`store_week`.`store_from`, `store_week`.`store_to` | jako `hours`.`hour` gdzie `hours`.`hour_id`=tamte id)
gdzie `store_week`.`store_day`=WEEKDAY(CURDATE())+1

Ten post edytował KsaR 13.09.2016, 13:06:59
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 23.12.2025 - 11:36