Skip to content

Commit

Permalink
Updated sample DDL to work with later versions of MySQL
Browse files Browse the repository at this point in the history
  • Loading branch information
johncurrier committed Feb 9, 2011
1 parent c18fb7d commit 6f753ad
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions library.ddl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ create table ADDRESS (
state char(2) not null,
zip varchar(10) not null comment "Dash req'd for zip+4",
primary key(AddressId)
) type=InnoDB COMMENT='Address details';
) engine=InnoDB COMMENT='Address details';

create table PUBLISHER (
publisherId integer auto_increment,
Expand All @@ -21,7 +21,7 @@ create table PUBLISHER (
primary key(publisherId),
foreign key(address) references ADDRESS(addressId),
index(name)
) type=InnoDB;
) engine=InnoDB;

create table BOOK (
isbn bigint,
Expand All @@ -30,7 +30,7 @@ create table BOOK (
primary key (isbn),
foreign key (publisherId) references PUBLISHER(publisherId),
index (title)
) type=InnoDB COMMENT='Book details';
) engine=InnoDB COMMENT='Book details';

create table author (
authorId integer auto_increment,
Expand All @@ -39,14 +39,14 @@ create table author (
lastName varchar(32) not null,
primary key (authorId),
index (lastName)
) type=InnoDB;
) engine=InnoDB;

create table book_author (
isbn bigint,
authorId integer comment 'FK intentionally omitted to show an implied relationship',
primary key (isbn, authorId),
foreign key (isbn) references BOOK(isbn)
) type=InnoDB;
) engine=InnoDB;
-- foreign key (authorId) references author(authorId)

create table LIBRARY_BRANCH (
Expand All @@ -55,7 +55,7 @@ create table LIBRARY_BRANCH (
address integer not null,
primary key(BranchId),
foreign key(Address) references ADDRESS(AddressId)
) type=InnoDB;
) engine=InnoDB;

create table BOOK_LOCATION (
isbn bigint,
Expand All @@ -64,7 +64,7 @@ create table BOOK_LOCATION (
primary key(isbn, branchId),
foreign key(isbn) references BOOK(isbn),
foreign key(branchId) references LIBRARY_BRANCH(branchId)
) type=InnoDB;
) engine=InnoDB;

create table BORROWER (
cardNo integer auto_increment,
Expand All @@ -76,7 +76,7 @@ create table BORROWER (
primary key(cardNo),
foreign key(Address) references ADDRESS(AddressId),
index(lastName, firstName)
) type=InnoDB;
) engine=InnoDB;

create table borrowed_book (
isbn bigint,
Expand All @@ -89,7 +89,7 @@ create table borrowed_book (
foreign key (branchId) references LIBRARY_BRANCH(branchId),
foreign key (cardNo) references BORROWER(cardNo),
index (DueDate)
) type=InnoDB;
) engine=InnoDB;

insert into address values(null, 'Road Road', '', 'Colorado Springs', 'CO', '80920');
insert into address values(null, 'Road Road', '', 'Colorado Springs', 'CO', '80920');
Expand Down

0 comments on commit 6f753ad

Please sign in to comment.