ЛБ1
.pdf1
1.1:
SQL -
.
1.3
Windows Linux -
.
1.4.
-
-
-
http://localhost/phpmyadmin.
1.1.
1 -
1.2).
1.2 -
1.4.2
)>
[NOT NULL UNIQUE],...,
...)
- -
-NOT NULL -
-
-UNIQUE - ;
-PRIMARY KEY -
- -
;
- FO
-
1.4.3
CREATE TABLE authors (au_id INT,
author VARCHAR(25) NOT NULL, PRIMARY KEY(au_id));
CREATE TABLE publishers (pub_id INT, publisher VARCHAR(255) NOT NULL,
url VARCHAR(255), PRIMARY KEY(pub_id)); CREATE TABLE titles (title_id INT,
title VARCHAR(255) NOT NULL, yearpub INT, pub_id INT,
PRIMARY KEY(title_id), CONSTRAINT a1
FOREIGN KEY (pub_id) REFERENCES publishers(pub_id));
CREATE TABLE titleautors (au_id INT, title_id INT,
CONSTRAINT a2 FOREIGN KEY (au_id) REFERENCES authors(au_id), CONSTRAINT a3 FOREIGN KEY (title_id) REFERENCES titles(title_id));
CREATE TABLE wwwsites (site_id INT,
site VARCHAR(255) NOT NULL, url VARCHAR(255),
PRIMARY KEY(site_id));
CREATE TABLE wwwsiteauthors (au_id INT, site_id INT, CONSTRAINT a4 FOREIGN KEY (au_id) REFERENCES authors(au_id),
CONSTRAINT a5 FOREIGN KEY (site_id) REFERENCES wwwsites(site_id));
1.3.
1.3 -
1.4.4
TABLE: DROP TABLE <>.
" DROP TABLE titleautors.
1.4.5
1.1.
1.
1. A
2.
3.
4.
REFER
5. |
ALTER TABLE < |
> DROP FOREIGN KEY (< |
".
1.4.6 publishers
1. - :
CREATE TABLE spr_publisher (publisher VARCHAR(255),
address VARCHAR(150), PRIMARY KEY (publisher)).
2.
ALTER TABLE publishers ADD CONSTRAINT a6 FOREIGN KEY (publisher) REFERENCES spr_publisher (publisher); -
.
publications2. titleautors
au_id: int(11) title_id: int(11)
publications2. titles
title _id: int(11) title: varchar(255) yearpub: int{11) pub_id: int(11)
Publications2.authors |
|
|
au_id: int(11) |
|
publications2. |
author: varchar(25) |
|
|
|
wwwsiteauthors |
|
|
|
|
|
|
au_id: int(11) |
|
||
|
|
site_id: int(11 |
publications2. wwwsites site_id: int(11)
site: varchar(255) url: varchar(255)
publications2.publishers |
|
|
|
publications2.spr_publisher |
|
pub_id: int(11) |
|
publisher: varchar(255) |
publisher: varchar(255) |
|
address: varchar(150) |
url: varchar(255) |
|
|
|
||
|
|
|
1.4 -
1.4.7 MySQL
ySQL
1.2.
1.2 MySQL
1 |
2 |
3 |
|
TINYINT
SMALLINT
MEDIUMINT
INT
INTEGER
BIGINT
FLOAT
DOUBLE,
REAL
DECIMAL, NUMERIC
- 3
.
4
-
- +9223372036854775807.
4
-
-1.175494351E-38.
8
-
1.7976931348623157E + 308
2.2250738585072014E-308.
-
DECIMAL - DOUBLE.
N
CHAR
VARCHAR
DATE
TIME
YEAR
ENUM
-
-
-
-
3-01-
-12-
-MM-
--
3 |
- |
1- -
-
. -
1.6 |
E |
1.2).
POST (NP int, IMIA char(30), ADRES char(50))
-NP - ;
-IMIA - .
DETAL (ND char(3), NAIM char(25), MATER char(30), CENA float (5,2))
-ND - ;
-NAIM, MATER -
POSTKA (NP int, ND char(3), KOL int)
-NP, ND - ;
-NP - ;
-ND - ;
-KOL - .
DETAL - POSTKA (1:M)
POST - POSTKA (1:M).
1.6:
-
|
1. |
- |
; |
- |
|
1. SP_MATER;
-
SP_MATER (NM char(3), NAZVANIE char(30))
NM - NAZVANIE - 1.6.3
-
-
SP_ADRES -
1.
1.2)
-
SP_ADRES (ADRES char(50))
ADRES -
SP_ADRES - POST (1:M) 1.6.4
-
-
-
;
-
POSTKA
NP ND KOL
1 |
10 |
1 |
25 |
1 |
48 |
1 |
8 |
1 |
32 |
1 |
25 |
1 |
13 |
1 |
7 |
2 |
17 |
2 |
17 |
2 |
25 |
3 |
16 |
3 |
52 |
3 |
9 |
4 |
40 |
4 |
67 |
5 |
173 |
5 |
13 |
6 |
41 |
6 |
52 |
;
POSTKA.
|
DETAL |
|
ND |
NAIM MATER |
CENA |
|
M1 |
1,25 |
|
M2 |
3 |
|
M2 |
2,25 |
|
M2 |
20,6 |
|
M2 |
1,87 |
|
M1 |
2,5 |
|
M2 |
5,2 |
|
M3 |
10,57 |
POST
NP IMIA ADRES
1
2 3
4 5
6 54