A First Course in Database Systems(数据库基础教程 第三版)课后答案——2.3.1\2.3.2\2.4.1

A First Course in Database Systems(数据库基础教程 第三版)课后答案——2.3.1\2.3.2\2.4.1

2.3.1

In this exercise we introduce one of our running examples of a relational database schema. The database schema consists of four relations, whose schemas are:

Product(maker, model, type)

PC(model, speed, ram, hd, price)

Laptop(model, speed, ram, hd, screen, price)

Printer(model, color, type, price)

The Product relation gives the manufacturer, model number and type (PC, laptop, or printer) of various products. We assume for convenience that model numbers are unique over all manufacturers and product types; that assumption is not realistic, and a real database would include a code for the manufacturer as part of the model number. The PC relation gives for each model number that is a PC the speed (of the processor, in gigahertz), the amount of RAM (in megabytes), the size of the hard disk (in gigabytes), and the price. The Laptop relation is similar, except that the screen size (in inches) is also included. The Printer relation records for each printer model whether the printer produces color output (true, if so), the process type (laser or ink-jet, typically), and the price. Write the following declarations:

a) A suitable schema for relation Product.

CREATE TABLE `product` (
  `maker` char(50) DEFAULT NULL,
  `model` int(11) NOT NULL,
  `p_type` char(20) DEFAULT NULL,
  PRIMARY KEY (`model`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci

b) A suitable schema for relation PC.

CREATE TABLE `pc` (
  `model` int(11) DEFAULT NULL,
  `speed` double DEFAULT NULL,
  `ram` int(11) DEFAULT NULL,
  `hd` int(11) DEFAULT NULL,
  `price` float DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci

c) A suitable schema for relation Laptop.

CREATE TABLE `laptop` (
  `model` int(11) DEFAULT NULL,
  `speed` double DEFAULT NULL,
  `ram` int(11) DEFAULT NULL,
  `hd` int(11) DEFAULT NULL,
  `screen` double DEFAULT NULL,
  `price` float DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci

d) A suitable schema for relation Printer.

CREATE TABLE `printer` (
  `model` int(11) DEFAULT NULL,
  `color` tinyint(1) DEFAULT NULL,
  `p_type` char(20) DEFAULT NULL,
  `price` float DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci

e) An alteration to your Printer schema from (d) to delete the attribute color.

alter table printer drop color;

f) An alteration to your Laptop schema from © to add the attribute od (optical-disk type, e.g., cd or dvd). Let the default value for this attribute be ’none’ if the laptop does not have an optical disk.

alter table laptop add od char(10) default 'none';

2.3.2

This exercise introduces another running example, concerning World War II capital ships. It involves the following relations:

Classes(class, type, country, numGuns, bore, displacement)

Ships(name, class, launched) Battles(name, date)

Outcomes(ship, battle, result)

Ships are built in “classes” from the same design, and the class is usually named for the fifirst ship of that class. The relation Classes records the name of the class, the type (’bb’ for battleship(战舰) or ’bc’ for battlecruiser(战列巡航舰)), the country that built the ship, the number of main guns, the bore (diameter of the gun barrel, in inches) of the main guns, and the displacement (weight, in tons). Relation Ships records the name of the ship, the name of its class, and the year in which the ship was launched. Relation Battles gives the name and date of battles involving these ships, and relation Outcomes gives the result (sunk, damaged, or ok) for each ship in each battle. Write the following declarations:

a) A suitable schema for relation Classes.

create table Classes (
	class char(20),
    s_type char(10),
    country char(20),
    numGuns int,
    bore float,
    displacement float
);

b) A suitable schema for relation Ships.

create table Ships(
	s_name char(100),
    class char(20),
    lauched date
);

c) A suitable schema for relation Battles.

create table Battles(
	s_name char(100),
    b_date date
);

d) A suitable schema for relation Outcomes.

create table Outcomes(
	ship char(100),
    battle char(100),
    result char(10)
);

e) An alteration to your Classes relation from (a) to delete the attribute bore.

alter table Classes drop bore;

f) An alteration to your Ships relation from (b) to include the attribute yard giving the shipyard where the ship was built.

alter table Ships add yard char(100);

2.4.1

This exercise builds upon the products schema of Exercise 2.3.1.

Recall that the database schema consists of four relations, whose schemas are:

Product(maker, model, type)

PC(model, speed, ram, hd, price)

Laptop(model, speed, ram, hd, screen, price)

Printer(model, color, type, price)

Some sample data for the relation Product is shown in Fig. 20. Sample data for the other three relations is shown in Fig. 21. Manufacturers and model

numbers have been “sanitized,” but the data is typical of products on sale at the beginning of 2007. Write expressions of relational algebra to answer the following queries. You may use the linear notation of Section 4.13 if you wish. For the data of Figs. 20 and 21, show the result of your query. However, your answer should work for arbitrary data, not just the data of these figures.

Product:
+-------+-------+---------+
| maker | model | p_type  |
+-------+-------+---------+
| A     |  1001 | pc      |
| A     |  1002 | pc      |
| A     |  1003 | pc      |
| B     |  1004 | pc      |
| B     |  1005 | pc      |
| B     |  1006 | pc      |
| C     |  1007 | pc      |
| D     |  1008 | pc      |
| D     |  1009 | pc      |
| D     |  1010 | pc      |
| E     |  1011 | pc      |
| E     |  1012 | pc      |
| E     |  1013 | pc      |
| E     |  2001 | laptop  |
| E     |  2002 | laptop  |
| E     |  2003 | laptop  |
| A     |  2004 | laptop  |
| A     |  2005 | laptop  |
| A     |  2006 | laptop  |
| B     |  2007 | laptop  |
| F     |  2008 | laptop  |
| F     |  2009 | laptop  |
| G     |  2010 | laptop  |
| E     |  3001 | printer |
| E     |  3002 | printer |
| E     |  3003 | printer |
| D     |  3004 | printer |
| D     |  3005 | printer |
| H     |  3006 | printer |
| H     |  3007 | printer |
+-------+-------+---------+
Pc:
+-------+-------+------+------+-------+
| model | speed | ram  | hd   | price |
+-------+-------+------+------+-------+
|  1001 |  2.66 | 1024 |  250 |  2114 |
|  1002 |   2.1 |  512 |  250 |   995 |
|  1003 |  1.42 |  512 |   80 |   478 |
|  1004 |   2.8 | 1024 |  250 |   649 |
|  1005 |   3.2 |  512 |  250 |   630 |
|  1006 |   3.2 | 1024 |  320 |  1049 |
|  1007 |   2.2 | 1024 |  200 |   510 |
|  1008 |   2.2 | 2048 |  250 |   770 |
|  1009 |     2 | 1024 |  250 |   650 |
|  1010 |   2.8 | 2048 |  300 |   770 |
|  1011 |  1.86 | 2048 |  160 |   959 |
|  1012 |   2.8 | 1024 |  160 |   649 |
|  1013 |  3.06 |  512 |   80 |   529 |
+-------+-------+------+------+-------+

Laptop:
+-------+-------+------+------+--------+-------+
| model | speed | ram  | hd   | screen | price |
+-------+-------+------+------+--------+-------+
|  2001 |     2 | 2048 |  240 |   20.1 |  3673 |
|  2002 |  1.73 | 1024 |   80 |     17 |   949 |
|  2003 |   1.8 |  512 |   60 |   15.4 |   549 |
|  2004 |     2 |  512 |   60 |   13.3 |  1150 |
|  2005 |  2.16 | 1024 |  120 |     17 |  2500 |
|  2006 |     2 | 2048 |   80 |   15.4 |  1700 |
|  2007 |  1.83 | 1024 |  120 |   13.3 |  1429 |
|  2008 |   1.6 | 1024 |  100 |   15.4 |   900 |
|  2009 |   1.6 |  512 |   80 |   14.1 |   680 |
|  2010 |     2 | 2048 |  160 |   15.4 |  2300 |
+-------+-------+------+------+--------+-------+

Printer:
+-------+-------+---------+-------+
| model | color | p_type  | price |
+-------+-------+---------+-------+
|  3001 |     1 | ink-jet |    99 |
|  3002 |     0 | laser   |   239 |
|  3003 |     1 | laser   |   899 |
|  3004 |     1 | ink-jet |   120 |
|  3005 |     0 | laser   |   120 |
|  3006 |     1 | ink-jet |   100 |
|  3007 |     1 | laser   |   200 |
+-------+-------+---------+-------+

a) What PC models have a speed of at least 3.00?

select model from pc where speed > 3.0;

R 1 = σ s p e e d > 3.00 ( P c ) R1=\sigma_{speed>3.00}(Pc) R1=σspeed>3.00(Pc)

R 2 = π m o d e l ( R 1 ) R2=\pi_{model}(R1) R2=πmodel(R1)

+-------+
| model |
+-------+
|  1005 |
|  1006 |
|  1013 |
+-------+

b) Which manufacturers make laptops with a hard disk of at least 100GB?

select maker from product natural join (select * from laptop where hd >= 100) as T1;

R 1 = σ h d ≥ 100 ( L a p t o p ) R1=\sigma_{hd\ge100}(Laptop) R1=σhd100(Laptop)​​​​

R 2 = P r o d u c t ⋈ R 1 R2=Product\Join R1 R2=ProductR1

R 3 = π m a k e r ( R 2 ) R3=\pi_{maker}(R2) R3=πmaker(R2)

+-------+
| maker |
+-------+
| E     |
| A     |
| B     |
| F     |
| G     |
+-------+

c) Find the model number and price of all products (of any type) made by manufacturer B.

R 1 = π m o d e l , p r i c e , m a k e r ( P r o d u c t ⋈ L a p t o p ) R1=\pi_{model,price,maker}(Product\Join Laptop) R1=πmodel,price,maker(ProductLaptop)​​

R 2 = π m o d e l , p r i c e , m a k e r ( P r o d u c t ⋈ P C ) R2=\pi_{model,price,maker}(Product\Join PC) R2=πmodel,price,maker(ProductPC)​​

R 3 = π m o d e l , p r i c e , m a k e r ( P r o d u c t ⋈ P r i n t e r ) R3=\pi_{model,price,maker}(Product\Join Printer) R3=πmodel,price,maker(ProductPrinter)​​

R 4 = R 1 ∪ R 2 ∪ R 3 R4=R1\cup R2\cup R3 R4=R1R2R3

R 5 = π m o d e , p r i c e ( σ m a k e r = ′ B ′ ( R 4 ) ) R5=\pi_{mode,price}(\sigma_{maker='B'}(R4)) R5=πmode,price(σmaker=B(R4))

select model,price from ((select model,price,maker from product natural join laptop as T1) 
union all (select model,price,maker from product natural join pc as T2) 
union all (select model,price,maker from product natural join printer as T3)) as T where maker='B';
+-------+-------+
| model | price |
+-------+-------+
|  2007 |  1429 |
|  1004 |   649 |
|  1005 |   630 |
|  1006 |  1049 |
+-------+-------+

d) Find the model numbers of all color laser printers.

π m o d e l ( σ c o l o r = t r u e a n d p _ t y p e = ′ l a s e r ′ ( P r i n t e r ) ) \pi_{model}(\sigma_{color=true\quad and \quad p\_type='laser'}(Printer)) πmodel(σcolor=trueandp_type=laser(Printer))​​​

select model from printer where color=true and p_type='laser';

e) Find those manufacturers that sell Laptops, but not PC’s.

R 1 = π m a k e r ( σ p _ t y p e = ′ l a p t o p ′ ( P r o d u c t ) ) R1=\pi_{maker}(\sigma_{p\_type='laptop'}(Product)) R1=πmaker(σp_type=laptop(Product))

R 2 = π m a k e r ( σ p _ t y p e = ′ p c ′ ( P r o d u c t ) ) R2=\pi_{maker}(\sigma_{p\_type='pc'}(Product)) R2=πmaker(σp_type=pc(Product))

R 3 = R 1 − R 2 R3 = R1-R2 R3=R1R2

select distinct maker from product where maker in (select maker from product where p_type='laptop') 
and maker not in (select maker from product where p_type='pc');
+-------+
| maker |
+-------+
| F     |
| G     |
+-------+

!f) Find those hard-disk sizes that occur in two or more PC’s

select distinct pc1.hd from pc pc1, pc pc2 where ( pc1.hd=pc2.hd and pc1.model<>pc2.model);

+------+
| hd   |
+------+
|  250 |
|   80 |
|  160 |
+------+

! g) Find those pairs of PC models that have both the same speed and RAM. A pair should be listed only once; e.g., list (i, j) but not (j,i).

R 1 = ρ p c 1 ( P c ) R1=\rho_{pc_1}(Pc) R1=ρpc1(Pc)

R 2 = ρ p c 2 ( P c ) R2=\rho_{pc_2}(Pc) R2=ρpc2(Pc)

R 3 = R 1 ⋈ ( p c 1. s p e e d = p c 2. s p e e d a n d p c 1. r a m = p c 2. r a m ) R 2 R3=R1\Join_{(pc1.speed=pc2.speed\quad and\quad pc1.ram = pc2.ram)}R2 R3=R1(pc1.speed=pc2.speedandpc1.ram=pc2.ram)R2

R 4 = π p c 1. m o d e l , p c 2. m o d e l ( R 3 ) R4=\pi_{pc1.model,pc2.model}(R3) R4=πpc1.model,pc2.model(R3)

select pc1.model pc1_model,pc2.model pc2_model from pc pc1, pc pc2 where (pc1.speed=pc2.speed and pc1.ram=pc2.ram and pc1.model < pc2.model);

+-----------+-----------+
| pc1_model | pc2_model |
+-----------+-----------+
|      1004 |      1012 |
+-----------+-----------+

!! h) Find those manufacturers of at least two different computers (PC’s or laptops) with speeds of at least 2.80.

R 1 = π m o d e l ( σ s p e e d ≥ 2.80 ( P c ) ∪ σ s p e e d ≥ 2.8 ( L a p t o p ) ) R1=\pi_{model}(\sigma_{speed\ge2.80}(Pc)\cup\sigma_{speed\ge2.8}(Laptop)) R1=πmodel(σspeed2.80(Pc)σspeed2.8(Laptop))

R 2 = π m o d e l , m a k e r ( R 1 ⋈ P r o d u c t ) R2=\pi_{model,maker}(R1\Join Product) R2=πmodel,maker(R1Product)

R 3 = ρ R 3 ( m o d e l 2 , m a k e r 2 ) ( R 2 ) R3=\rho_{R3(model2, maker2)}(R2) R3=ρR3(model2,maker2)(R2)​​

R 4 = π m a k e r ( R 2 ⋈ m a k e r = m a k e r 2 a n d m o d e l < > m o d e l 2 R 3 ) R4=\pi_{maker}(R2\Join_{maker=maker2\quad and \quad model<>model2}R3) R4=πmaker(R2maker=maker2andmodel<>model2R3)​​

create view temp_view  as select * from product natural join (select * from (select model from pc where speed >= 2.80 union all select model from laptop where speed >= 2.80) as T1) as T2;
select distinct v1.maker from temp_view v1, temp_view v2 where v1.model > v2.model and v1.maker = v2.maker;
drop view if exists temp_view;
+-------+
| maker |
+-------+
| B     |
| E     |
+-------+

!! i) Find the manufacturer(s) of the computer (PC or laptop) with the highest available speed.

R 1 = π m o d e l , s p e e d ( P c ) R1=\pi_{model,speed}(Pc) R1=πmodel,speed(Pc);

R 2 = π m o d e l , s p e e d ( L a p t o p ) R2=\pi_{model,speed}(Laptop) R2=πmodel,speed(Laptop);

R 3 = R 1 ∪ R 2 R3=R1\cup R2 R3=R1R2;

R 4 = ρ R 4 ( m o d e l 2 , s p e e d 2 ) ( R 3 ) ; R4=\rho_{R4(model2, speed2)}(R3); R4=ρR4(model2,speed2)(R3);

R 5 = R 3 ⋈ s p e e d < s p e e d 2 R 4 R5=R3\Join_{speed<speed2}R4 R5=R3speed<speed2R4

R 6 = R 3 − R 5 R6=R3-R5 R6=R3R5

R 7 = π m a k e r ( R 6 ⋈ P r o d u c t ) ; R7=\pi_{maker}(R6\Join Product); R7=πmaker(R6Product);

 create view R1 as select model,speed from Pc;
 create view R2 as select model, speed from Laptop;
 create view R3 as select * from (select * from R1 union all select * from R2) as T;
 create view R4 as select model as model2,speed as speed2 from R3;
 create view R5 as select model,speed from R3,R4 where speed<speed2;
 create view R6 as select model,speed from R3 where model not in (select model from R5);
 create view R7 as select distinct maker from (R6 natural join product);
 select * from R7;
+-------+
| maker |
+-------+
| B     |
+-------+

!! j) Find the manufacturers of PC’s with at least three different speeds.

R 1 = π m a k e r , s p e e d ( P r o d u c t ⋈ P c ) R1=\pi_{maker,speed}(Product\Join Pc) R1=πmaker,speed(ProductPc)

R 2 = ρ R 2 ( m a k e r 2 , s p e e d 2 ) ( R 1 ) R2=\rho_{R2(maker2,speed2)}(R1) R2=ρR2(maker2,speed2)(R1)

R 3 = ρ R 3 ( m a k e r 3 , s p e e d 3 ) ( R 1 ) R3=\rho_{R3(maker3,speed3)}(R1) R3=ρR3(maker3,speed3)(R1)

R 4 = R 1 ⋈ m a k e r = m a k e r 2 a n d s p e e d < > s p e e d 2 R 2 R4=R1\Join_{maker=maker2\quad and \quad speed<>speed2}R2 R4=R1maker=maker2andspeed<>speed2R2

R 5 = R 4 ⋈ m a k e r 3 = m a k e r a n d s p e e d 3 < > s p e e d 2 a n d s p e e d 3 < > s p e e d R 3 R5=R4\Join_{maker3=maker\quad and \quad speed3<>speed2\quad and \quad speed3<>speed}R3 R5=R4maker3=makerandspeed3<>speed2andspeed3<>speedR3

R 6 = π m a k e r ( R 5 ) R6=\pi_{maker}(R5) R6=πmaker(R5)

create view R1 as select maker,speed from (product natural join pc);
create view R2 as select maker maker2, speed speed2 from R1;
create view R3 as select maker maker3, speed speed3 from R1;
create view R4 as select * from R1,R2 where maker=maker2 and speed <> speed2;
create view R5 as select * from R4,R3 where maker3=maker and speed3<>speed2 and speed3<>speed;
create view R6 as select distinct maker from R5;
select * from R6;
+-------+
| maker |
+-------+
| A     |
| D     |
| E     |
+-------+

!! k) Find the manufacturers who sell exactly three different models of PC.

R 1 = π m a k e r , m o d e l ( P r o d u c t ⋈ P c ) R1=\pi_{maker,model}(Product\Join Pc) R1=πmaker,model(ProductPc)

R 2 = ρ R 2 ( m a k e r 2 , m o d e l 2 ) ( R 1 ) R2=\rho_{R2(maker2,model2)}(R1) R2=ρR2(maker2,model2)(R1)

R 3 = ρ R 3 ( m a k e r 3 , m o d e l 3 ) ( R 1 ) R3=\rho_{R3(maker3,model3)}(R1) R3=ρR3(maker3,model3)(R1)

R 4 = ρ R 4 ( m a k e r 4 , m o d e l 4 ) ( R 1 ) R4 =\rho_{R4(maker4,model4)}(R1) R4=ρR4(maker4,model4)(R1)

R 5 = R 1 ⋈ m a k e r = m a k e r 2 a n d m o d e l < > m o d e l 2 R 2 R5=R1\Join_{maker=maker2\quad and \quad model<>model2}R2 R5=R1maker=maker2andmodel<>model2R2

R 6 = R 3 ⋈ m a k e r 3 = m a k e r a n d m o d e l 3 < > m o d e l 2 a n d m o d e l 3 < > m o d e l R 5 R6=R3\Join_{maker3=maker\quad and \quad model3<>model2\quad and \quad model3 <>model}R5 R6=R3maker3=makerandmodel3<>model2andmodel3<>modelR5

R 7 = R 4 ⋈ m a k e r 4 = m a k e r a n d ( m o d e l 4 = m o d e l o r m o d e l 4 = m o d e l 2 o r m o d e l 4 = m o d e l 3 ) R 5 R7=R4\Join_{maker4=maker\quad and \quad(model4=model\quad or \quad model4 =model2\quad or\quad model4=model3)}R5 R7=R4maker4=makerand(model4=modelormodel4=model2ormodel4=model3)R5

R 8 = π m a k e r ( R 7 ) R8=\pi_{maker}(R7) R8=πmaker(R7)​​

create view R1 as select maker,model from (product natural join pc);
create view R2 as select maker maker2, model model2 from R1;
create view R3 as select maker maker3, model model3 from R1;
create view R4 as select maker maker4, model model4 from R1;
create view R5 as select * from R1,R2 where maker=maker2 and model<>model2;
create view R6 as select * from R3,R5 where maker3=maker and model3<>model2 and model3<>model;
create view R7 as select * from R4,R6 where maker4=maker and (model4=model or model4=model2 or model=model3);
select distinct maker from R7;
+-------+
| maker |
+-------+
| A     |
| B     |
| D     |
| E     |
+-------+

数据文件

-- MySQL dump 10.13  Distrib 8.0.19, for Win64 (x86_64)
--
-- Host: localhost    Database: first_course_to_dbms
-- ------------------------------------------------------
-- Server version	8.0.18

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!50503 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

--
-- Table structure for table `laptop`
--

DROP TABLE IF EXISTS `laptop`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `laptop` (
  `model` int(11) DEFAULT NULL,
  `speed` double DEFAULT NULL,
  `ram` int(11) DEFAULT NULL,
  `hd` int(11) DEFAULT NULL,
  `screen` double DEFAULT NULL,
  `price` float DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `laptop`
--

LOCK TABLES `laptop` WRITE;
/*!40000 ALTER TABLE `laptop` DISABLE KEYS */;
INSERT INTO `laptop` VALUES (2001,2,2048,240,20.1,3673),(2002,1.73,1024,80,17,949),(2003,1.8,512,60,15.4,549),(2004,2,512,60,13.3,1150),(2005,2.16,1024,120,17,2500),(2006,2,2048,80,15.4,1700),(2007,1.83,1024,120,13.3,1429),(2008,1.6,1024,100,15.4,900),(2009,1.6,512,80,14.1,680),(2010,2,2048,160,15.4,2300);
/*!40000 ALTER TABLE `laptop` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `pc`
--

DROP TABLE IF EXISTS `pc`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `pc` (
  `model` int(11) DEFAULT NULL,
  `speed` double DEFAULT NULL,
  `ram` int(11) DEFAULT NULL,
  `hd` int(11) DEFAULT NULL,
  `price` float DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `pc`
--

LOCK TABLES `pc` WRITE;
/*!40000 ALTER TABLE `pc` DISABLE KEYS */;
INSERT INTO `pc` VALUES (1001,2.66,1024,250,2114),(1002,2.1,512,250,995),(1003,1.42,512,80,478),(1004,2.8,1024,250,649),(1005,3.2,512,250,630),(1006,3.2,1024,320,1049),(1007,2.2,1024,200,510),(1008,2.2,2048,250,770),(1009,2,1024,250,650),(1010,2.8,2048,300,770),(1011,1.86,2048,160,959),(1012,2.8,1024,160,649),(1013,3.06,512,80,529);
/*!40000 ALTER TABLE `pc` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `printer`
--

DROP TABLE IF EXISTS `printer`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `printer` (
  `model` int(11) DEFAULT NULL,
  `color` tinyint(1) DEFAULT NULL,
  `p_type` char(20) DEFAULT NULL,
  `price` float DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `printer`
--

LOCK TABLES `printer` WRITE;
/*!40000 ALTER TABLE `printer` DISABLE KEYS */;
INSERT INTO `printer` VALUES (3001,1,'ink-jet',99),(3002,0,'laser',239),(3003,1,'laser',899),(3004,1,'ink-jet',120),(3005,0,'laser',120),(3006,1,'ink-jet',100),(3007,1,'laser',200);
/*!40000 ALTER TABLE `printer` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `product`
--

DROP TABLE IF EXISTS `product`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `product` (
  `maker` char(50) DEFAULT NULL,
  `model` int(11) NOT NULL,
  `p_type` char(20) DEFAULT NULL,
  PRIMARY KEY (`model`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `product`
--

LOCK TABLES `product` WRITE;
/*!40000 ALTER TABLE `product` DISABLE KEYS */;
INSERT INTO `product` VALUES ('A',1001,'pc'),('A',1002,'pc'),('A',1003,'pc'),('B',1004,'pc'),('B',1005,'pc'),('B',1006,'pc'),('C',1007,'pc'),('D',1008,'pc'),('D',1009,'pc'),('D',1010,'pc'),('E',1011,'pc'),('E',1012,'pc'),('E',1013,'pc'),('E',2001,'laptop'),('E',2002,'laptop'),('E',2003,'laptop'),('A',2004,'laptop'),('A',2005,'laptop'),('A',2006,'laptop'),('B',2007,'laptop'),('F',2008,'laptop'),('F',2009,'laptop'),('G',2010,'laptop'),('E',3001,'printer'),('E',3002,'printer'),('E',3003,'printer'),('D',3004,'printer'),('D',3005,'printer'),('H',3006,'printer'),('H',3007,'printer');
/*!40000 ALTER TABLE `product` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

-- Dump completed on 2022-01-16 20:02:02

  • 5
    点赞
  • 55
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值