0% found this document useful (0 votes)
72 views

Mysql Example

This document defines three database tables: sailors, boats, and reserves. The sailors table stores sailor IDs, names, ratings, and ages. The boats table stores boat IDs, names, and colors. The reserves table stores reservations with sailor IDs, boat IDs, and reservation dates, linking the sailors and boats tables through foreign keys.

Uploaded by

lakshmilavanya
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
72 views

Mysql Example

This document defines three database tables: sailors, boats, and reserves. The sailors table stores sailor IDs, names, ratings, and ages. The boats table stores boat IDs, names, and colors. The reserves table stores reservations with sailor IDs, boat IDs, and reservation dates, linking the sailors and boats tables through foreign keys.

Uploaded by

lakshmilavanya
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Tables used in this note:

Sailors(sid: integer, sname: string, rating: integer, age: real);

Boats(bid: integer, bname: string, color: string);

Reserves(sid: integer, bid: integer, day: date).

CREATE TABLE sailors ( sid integer not null, sname varchar(32), rating integer, age real, CONSTRAINT
PK_sailors PRIMARY KEY (sid) );

create table boats(bid integer, bname char(20),bcolor char(10), primary key (bid));

CREATE TABLE reserves ( sid integer not null, bid integer not null, day datetime not null,
CONSTRAINT PK_reserves PRIMARY KEY (sid, bid, day), FOREIGN KEY (sid) REFERENCES sailors(sid),
FOREIGN KEY (bid) REFERENCES boats(bid) );

You might also like