Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 10

CREATION TABLES

Clients table create table clients

(clientid varchar(20) PRIMARY KEY,

fname varchar(20),

lname varchar(20),

gender varchar(1),

age number(10),

contact_add varchar(20),

email varchar(20));

ALTER TABLE clients


ADD start_date date;

ALTER TABLE clients


ADD end_date date,

ALTER TABLE clients


ADD payment_method varchar2(15) ;

2.Payment table CREATE TABLE payment (

payment_id VARCHAR(20) PRIMARY KEY,

clientid VARCHAR(20),

payment_date DATE,

payment_amount NUMBER(20),

FOREIGN KEY (clientid) REFERENCES


clients(clientid)

);

Membership table CREATE TABLE membership (

mem_id VARCHAR(20) PRIMARY KEY,

clientid VARCHAR(20),
status VARCHAR(20),

DATE1 DATE,

FOREIGN KEY (clientid) REFERENCES

clients(clientid) );

Trainer table  create table trainer(trainer_id


varchar(20) PRIMARY KEY,
name varchar(20),
salary number(20),
email varchar(20),
password varchar(20)
hire_date date,
ph_no numner(10),
address varchar2(30));
 ALTER TABLE trainer
ADD COLUMN sched_id VARCHAR(20),
ADD CONSTRAINT fk_sched_id
FOREIGN KEY (sched_id) REFERENCES
schedule(sched_id);

Schedule table CREATE TABLE schedule (


sched_id VARCHAR(20) PRIMARY
KEY,
clientid VARCHAR(20),
trainer_id VARCHAR(20),
sesion VARCHAR(20),
activity VARCHAR(20),
date1 DATE,
time_sheet VARCHAR(20),
FOREIGN KEY (clientid) REFERENCES
clients(clientid),
FOREIGN KEY (trainer_id)
REFERENCES trainer(trainer_id)
);
Transaction table create table transaction_records
(trans_id varchar(20) PRIMARY KEY,
trans_name varchar(20),
clientid VARCHAR(20),
amount NUMBER(20),
date2 DATE,
FOREIGN KEY (clientid) REFERENCES
clients(clientid)
)
Attendance table
CREATE TABLE attendance (
attendance_id NUMBER(10) PRIMARY
KEY,
clientid varchar(20) NOT NULL,
class_id NUMBER(10) NOT NULL,
attendance_date DATE NOT NULL,
FOREIGN KEY (clientid) REFERENCES
clients(clientid) ON DELETE CASCADE,
FOREIGN KEY (class_id) REFERENCES
class(class_id) ON DELETE CASCADE
);

Class type table CREATE TABLE classType (


class_type_id number(20) PRIMARY
KEY,
class_type_name VARCHAR(10) NOT
NULL,
class_type_description VARCHAR(25),
class_type_duration number(20) NOT
NULL,
class_type_difficulty VARCHAR(20)
NOT NULL
);
desc transaction_records;
desc schedule;
desc membership;
desc payment;
desc clients;
desc class;
desc trainer;
desc classtype;
desc attendance;

PROCEDUR CREATE OR REPLACE PROCEDURE insertclients(


E FOR p_clientid IN CLIENTS.CLIENTID%TYPE,
INSERTION p_fname IN CLIENTS.FNAME%TYPE,
INTO p_lname IN CLIENTS.LNAME%TYPE,
CLIENTS p_age IN CLIENTS.AGE%TYPE,
TABLE p_contact_add IN CLIENTS.CONTACT_ADD%TYPE)
IS
BEGIN

INSERT INTO clients ("CLIENTID", "FNAME", "LNAME",


"AGE","CONTACT_ADD")
VALUES (p_clientid, p_fname, p_lname, p_age,
p_contact_add);

COMMIT;

END;
/

BEGIN
insertclients(126, 'yuvraj', 'Y', 30, '126 KERALA');
END;

PROCEDUR
E FOR CREATE OR REPLACE PROCEDURE insertpayment(
INSERTION p_payment_id IN PAYMENT.PAYMENT_ID%TYPE,
INTO p_clientid IN PAYMENT.CLIENTID%TYPE,
PAYMENT p_date1 IN PAYMENT.DATE1%TYPE,
TABLE p_amount IN PAYMENT.AMOUNT%TYPE)
IS
BEGIN

INSERT INTO PAYMENT ("PAYMENT_ID", "CLIENTID",


"DATE1", "AMOUNT")
VALUES (p_payment_id, p_clientid, p_date1,
p_amount);

COMMIT;

END;
/
A gym management data model can be designed to store and manage
data related to gym operations, such as member information, class
schedules, equipment inventory, and payment transactions. Here is a
possible data model for a gym management system:
clients table
 client_id (primary key)
 first_name
 last_name
 email
 phone_number
 address
 start_date
 end_date
 membership_type
 payment_method

Class table
 class_id (primary key)
 class_name
 class_description
 class_schedule
 trainer_name

Payment table
 payment_id (primary key)
 member_id (foreign key)
 payment_date
 payment_amount

Attendance table
 attendance_id (primary key)
 member_id (foreign key)
 class_id (foreign key)
 attendance_date
Trainer table
 trainer_id (primary key)
 first_name
 last_name
 email
 phone_number
 address
 hire_date

This data model allows the gym to keep track of member information,
class schedules, equipment inventory, payment transactions, and
instructor details. The primary key in each table uniquely identifies each
record, while foreign keys establish relationships between tables. This
allows for easy querying and analysis of data to make informed business
decisions.

Clients Table Datatype constraints


clientid varchar(20) PRIMARY KEY
fname varchar(20) -
lname varchar(20) -
gender varchar(1) -
age Number(10) -
contact_add varchar(20) -
email varchar(20) -
start_date date -
end_date date -
payment_method varchar2(15) -

Membership Table Datatype constraints


mem_id VARCHAR(20) PRIMARY KEY
clientid VARCHAR(20) FOREIGN KEY
status VARCHAR(20) -
DATE1 DATE -
Trainer Table Datatype constraints
trainer_id varchar(20) PRIMARY KEY
name varchar(20)
Sched_id Varchar(20) FOREIGN KEY
email varchar(20)
hire_date date
ph_no number(10)
address varchar2(30)

Schedule Table Datatype constraints


sched_id VARCHAR(20) PRIMARY KEY
clientid VARCHAR(20) FOREIGN KEY
trainer_id VARCHAR(20) FOREIGN KEY
sesion VARCHAR(20)
activity VARCHAR(20)
date1 DATE
time_sheet VARCHAR(20)

Transaction records Table Datatype constraints


trans_id varchar(20) PRIMARY KEY
trans_name varchar(20)
clientid VARCHAR(20) FOREIGN KEY
date2 DATE

attendance Table Datatype constraints


attendance_id NUMBER(10) PRIMARY KEY,
Clientid varchar(20) FOREIGN KEY
NOT NULL

class_id NUMBER(10) NOT FOREIGN KEY


NULL
attendance_date DATE NOT NULL,

You might also like