[sql] бібліотека

Viewer

copydownloadembedprintName: бібліотека
  1. CREATE DATABASE `Бібліотека`;
  2. USE library;
  3.  
  4. CREATE TABLE Authors (
  5.     author_id INT AUTO_INCREMENT PRIMARY KEY,
  6.     first_name VARCHAR(100),
  7.     last_name VARCHAR(100),
  8.     birthdate DATE,
  9.     nationality VARCHAR(100)
  10. );
  11.  
  12. CREATE TABLE Books (
  13.     book_id INT AUTO_INCREMENT PRIMARY KEY,
  14.     title VARCHAR(255),
  15.     author_id INT,
  16.     page_count INT,
  17.     genre VARCHAR(100),
  18.     publication_year INT,
  19.     FOREIGN KEY (author_id) REFERENCES Authors(author_id)
  20. );
  21.  
  22. CREATE TABLE Publishers (
  23.     publisher_id INT AUTO_INCREMENT PRIMARY KEY,
  24.     name VARCHAR(255),
  25.     country VARCHAR(100)
  26. );
  27. Додамо авторів
  28. INSERT INTO Authors (first_name, last_name, birthdate, nationality) 
  29. VALUES ('Stephen', 'King', '1947-09-21', 'American'),
  30.        ('J.K.', 'Rowling', '1965-07-31', 'British'),
  31.        ('Leo', 'Tolstoy', '1828-09-09', 'Russian');
  32.  
  33. -- Додамо книги
  34. INSERT INTO Books (title, author_id, page_count, genre, publication_year) 
  35. VALUES ('The Shining', 1, 447, 'Horror', 1977),
  36.        ('Harry Potter and the Philosopher''s Stone', 2, 223, 'Fantasy', 1997),
  37.        ('War and Peace', 3, 1225, 'Historical Fiction', 1869);
  38.  
  39. -- Додамо видавництва
  40. INSERT INTO Publishers (name, country) 
  41. VALUES ('Doubleday', 'USA'),
  42.        ('Bloomsbury Publishing', 'UK');

Editor

You can edit this paste and save as new:


File Description
  • бібліотека
  • Paste Code
  • 30 Apr-2024
  • 1.31 Kb
You can Share it: