Textsfg
Textsfg
Relationships:
A. Prescription: Describes the recommendation of medicines by doctors to patients.
It connects the Doctor, Patient, and Medicine entities. This relationship signifies
which doctor prescribed which medicine to which patient.
B. Dispenses: It's typically one-to-many. A pharmacy can dispense the same medicine
to multiple patients, but each medicine is dispensed by one pharmacy.
Keys:
A. Patient ID, Medicine ID, Pharmacy ID, and Doctor ID can be primary keys in their
respective entities.
B. Bill ID can serve as the primary key in the Bill entity, also linking it as a
foreign key to the Patient entity.
-----------------------------------------------------------------------------------
-------------
1] Install MySQL:
Download and install MySQL on your computer. You can choose to install MySQL
Community Server, which is freely available for personal use, or you can opt for a
paid version if you need additional features and support.
4] Create a Database:
Once you're in the MySQL command line interface, you can create a new
database using the CREATE DATABASE statement.
6] Design Tables:
Now, you can start designing the structure of your database by creating
tables. Tables define the entities and relationships in your database. You'll need
to decide on the columns (attributes) for each table and the data types for those
columns.
7] Create Tables:
Use the CREATE TABLE statement to create tables in your database.eg:
CREATE TABLE users (
id INT AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(50) NOT NULL,
email VARCHAR(100) NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
8] Insert Data:
Once your tables are created, you can insert data into them using the INSERT
INTO statement.eg:
INSERT INTO users (username, email) VALUES ('john_doe', '[email protected]');