ddata 324 hw 2

.docx

School

Washington State University *

*We aren’t endorsed by this school

Course

424

Subject

Computer Science

Date

Feb 20, 2024

Type

docx

Pages

5

Uploaded by Titanninja

Report
CREATE TABLE Patient ( SSN VARCHAR ( 11 ) NOT NULL PRIMARY KEY , name VARCHAR ( 50 ) NOT NULL , age INT NOT NULL , phySSN VARCHAR ( 11 ) NOT NULL , FOREIGN KEY (phySSN) REFERENCES Pri_physician(SSN) ); CREATE TABLE Pri_physician ( SSN VARCHAR ( 11 ) NOT NULL PRIMARY KEY , name VARCHAR ( 50 ) NOT NULL , specialty VARCHAR ( 50 ) NOT NULL , experience INT NOT NULL , FOREIGN KEY (SSN) REFERENCES Doctor(SSN) ); CREATE TABLE Doctor ( SSN VARCHAR ( 11 ) NOT NULL PRIMARY KEY , name VARCHAR ( 50 ) NOT NULL , experience INT NOT NULL , presi VARCHAR ( 11 ) NOT NULL , FOREIGN KEY (presi) REFERENCES Clinic(SSN) ); CREATE TABLE Clinic ( SSN VARCHAR ( 11 ) NOT NULL PRIMARY KEY , clinic_name VARCHAR ( 50 ) NOT NULL , phone_num VARCHAR ( 15 ) NOT NULL , address VARCHAR ( 100 ) NOT NULL ); CREATE TABLE Prescription ( date DATE NOT NULL , SSN VARCHAR ( 11 ) NOT NULL , drug_name VARCHAR ( 50 ) NOT NULL , PRIMARY KEY ( date , SSN, drug_name), FOREIGN KEY (SSN) REFERENCES Doctor(SSN), FOREIGN KEY (drug_name) REFERENCES Drug(drug_name)
); CREATE TABLE Pharmacy ( name VARCHAR ( 50 ) NOT NULL PRIMARY KEY , phone_num VARCHAR ( 15 ) NOT NULL , address VARCHAR ( 100 ) NOT NULL , city VARCHAR ( 50 ) NOT NULL ); CREATE TABLE Sell ( name VARCHAR ( 50 ) NOT NULL , drug_name VARCHAR ( 50 ) NOT NULL , price FLOAT NOT NULL , PRIMARY KEY ( name , drug_name), FOREIGN KEY ( name ) REFERENCES Pharmacy( name ), FOREIGN KEY (drug_name) REFERENCES Drug(drug_name) ); CREATE TABLE Drug ( drug_name VARCHAR ( 50 ) NOT NULL PRIMARY KEY , formula VARCHAR ( 100 ) NOT NULL ); CREATE TABLE Online_pharmacy ( name VARCHAR ( 50 ) NOT NULL PRIMARY KEY , WebURL VARCHAR ( 100 ) NOT NULL , FOREIGN KEY ( name ) REFERENCES Pharmacy( name ) ); CREATE TABLE InStore_pharmacy ( name VARCHAR ( 50 ) NOT NULL PRIMARY KEY , FOREIGN KEY ( name ) REFERENCES Pharmacy( name ) );
CREATE TABLE DrugCompany ( company_id INT NOT NULL , name VARCHAR ( 100 ), phone_num CHAR ( 10 ), address VARCHAR ( 255 ), contract TEXT , supervisor VARCHAR ( 100 ), start_date DATE , end_date DATE , PRIMARY KEY (company_id), UNIQUE (phone_num) ); 1.
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help