A P P E N D I X  B

DiningGuide Database Script

This appendix displays the following database scripts for the DiningGuide tutorial:

This code is also available as SQL script files within the DiningGuide application zip file, which you can download from the Tutorials and Code Camps page of the Java Studio Enterprise Developer Resources portal at http://developers.sun.com/prodtech/javatools/jsenterprise/learning/tutorials/index.html.


Script for a PointBase Database

drop table CustomerReview;
drop table Restaurant;
 
create table Restaurant(
	restaurantName	 varchar(80),
	cuisine				varchar(25),
	neighborhood				varchar(25),
	address				varchar(30),
	phone				varchar(12),
	description				varchar(200),
	rating				tinyint,
constraint pk_Restaurant primary key(restaurantName));
 
create table CustomerReview(
	restaurantName	 varchar(80) not null references Restaurant(restaurantName),
	customerName				varchar(25),
	review				varchar(200),
constraint pk_CustomerReview primary key(CustomerName, restaurantName));
 
insert into Restaurant (restaurantName, cuisine, neighborhood, address, phone, description, rating) values ('French Lemon','Mediterranean','Rockridge','1200 College Avenue','510 888 8888','Very nice spot.',5);
insert into Restaurant (restaurantName, cuisine, neighborhood, address, phone, description, rating) values ('Bay Fox','Mediterranean','Piedmont','1200 Piedmont Avenue','510 888 8888','Excellent.',5);
 
insert into CustomerReview (restaurantName, customerName, review) values ('French Lemon','Fred','Nice flowers.');
insert into CustomerReview (restaurantName, customerName, review) values ('French Lemon','Ralph','Excellent service.');


Script for an Oracle Database

drop table CustomerReview;
drop table Restaurant;
 
create table Restaurant(
	restaurantName 				varchar(80),
	cuisine 				varchar(25),
	neighborhood 				varchar(25),
	address 				varchar(30),
	phone 				varchar(12),
	description 				varchar(200),
	rating 				number(1,0),
constraint pk_Restaurant primary key(restaurantName));
grant all on Restaurant to public;
 
create table CustomerReview(
	restaurantName 	varchar(80) not null references Restaurant(restaurantName),
	customerName 				varchar(25),
	review 				varchar(200),
constraint pk_CustomerReview primary key(CustomerName, restaurantName));
grant all on CustomerReview to public;
 
insert into Restaurant (restaurantName, cuisine, neighborhood, address, phone, description, rating) values ('French Lemon','Mediterranean','Rockridge','1200 College Avenue','510 888 8888','Very nice spot.',5);
insert into Restaurant (restaurantName, cuisine, neighborhood, address, phone, description, rating) values ('Bay Fox','Mediterranean','Piedmont','1200 Piedmont Avenue','510 888 8888','Excellent.',5);
 
insert into CustomerReview (restaurantName, customerName, review) values ('French Lemon','Fred','Nice flowers.');
insert into CustomerReview (restaurantName, customerName, review) values ('French Lemon','Ralph','Excellent service.');
 
commit;