Pet shop Management System Database Design
The capstone project entitled “Pet shop Management System” is a platform that allows the different pet shop owners or managers to post and publish their pet and other products on their pet shop. The platform is an ecommerce website specifically intended for pets, pet shop services, pet shop accessories and other products.
This article will provide you with the list of tables and field/columns for every table in the design of database structure/schema of pet shop management system. The team will later provide a video tutorial on how to create the database in PHPMyAdmin.
This database design has 12 tables with their respective fields and columns as well as their relationships among each other.
tbl_pet – this table will store the information of the different pets posted on the platform by their specific owner/pet shop. The table has the following columns:
- pet_id – primary key of the table. It is set usually to auto_increment (the database will automatically give this column a value starting from 1).
- pet_description – the detailed description of the pet such as the color, birthday, weight, height, etc.
- pet_category_id – this is a foreign key that points out to the pet category table.
- vendor_id – this is another foreign key that links to the vendor or shop owner who posted the item/pet information.
- pet_images – images of the pet.
- pet_status – this refers to the availability of the pet.
- user_id – the user who encode/manage/update/approve the posted information.
Create SQL Statement – the statement below is used to create the tbl_pet, copy the sql statement and paste it in the sql manager/tab of your phpmyadmin.
CREATE TABLE `tbl_pet` ( `pet_id` int(11) NOT NULL, `pet_description` varchar(50) NOT NULL, `pet_category_id` int(11) NOT NULL, `vendor_id` int(11) NOT NULL, `pet_images` blob NOT NULL, `pet_status` int(1) NOT NULL, `user_id` int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
tbl_pet_category – the pet category table stores the type of pet allowed to be posted on the platform. The following are the columns of the table:
- pet_category_id – primary key of the table. It is set usually to auto_increment (the database will automatically give this column a value starting from 1).
- pet_category_name – the pet category name (dog, cat, fish, rabbit, etc)
- user_id – the user who encode/manage/update the information.
Create SQL Statement – the statement below is used to create the tbl_pet_category, copy the sql statement and paste it in the sql manager/tab of your phpmyadmin.
CREATE TABLE `tbl_pet_category` ( `pet_category_id` int(11) NOT NULL, `pet_category_name` varchar(30) NOT NULL, `user_id` int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
tbl_pet_product_category – this table will store the list of pet product category of the multi-store pet shop management system. The following are the entities/columns of the table:
- product_category_id – primary key of the table. It is set usually to auto_increment (the database will automatically give this column a value starting from 1).
- category_name – category name of the pet product (dog food, accessories, fish food, etc.)
- user_id – the user who encode/manage/update the product category information.
Create SQL Statement – the statement below is used to create the tbl_pet_product_category, copy the sql statement and paste it in the sql manager/tab of your phpmyadmin.
CREATE TABLE `tbl_pet_product_category` ( `product_category_id` int(11) NOT NULL, `category_name` varchar(30) NOT NULL, `user_id` int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
tbl_pet_product – this table will store the products posted by different vendors or pet shop owners/managers, this is where the vendors can post their pet and pet products. The table has 12 columns and they are the following:
- pet_product_id – primary key of the table. It is set usually to auto_increment (the database will automatically give this column a value starting from 1).
- product_code – the unique code of the product, it is in a form of barcode, qrcode, or an alphanumeric combination.
- product_name – the name of the pet product
- product_detail – detailed description of the product.
- product_category_id – this refers to the type or category of the product, it is a foreign key that links to the pet product category table.
- quantity_on_hand – the number of available products.
- vendor_price – cost of the product from the vendor.
- retail_price – the price that will be sold to the customer. (the difference from the retail to vendor price will serve as the profit or share of the platform)
- discount – discount of the product (if any).
- vendor_id – the vendor or pet shop owner/manager who posted the product. It is a foreign key that points out to the vendor table.
- status – availability status of the product.
- user_id – the user who encode/manage/update/approve the product information.
Create SQL Statement – the statement below is used to create the tbl_pet_product, copy the sql statement and paste it in the sql manager/tab of your phpmyadmin.
CREATE TABLE `tbl_pet_product` ( `pet_product_id` int(11) NOT NULL, `product_code` varchar(30) NOT NULL, `product_name` varchar(30) NOT NULL, `product_detail` varchar(100) NOT NULL, `product_category_id` int(11) NOT NULL, `quantity_on_hand` int(5) NOT NULL, `vendor_price` float NOT NULL, `retail_price` float NOT NULL, `discount` float NOT NULL, `vendor_id` int(11) NOT NULL, `status` int(1) NOT NULL, `user_id` int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
tbl_order – this table stores the order information of the customer. The transaction will be managed by the users or moderators of the platform.
- order_id – primary key of the table. It is set usually to auto_increment (the database will automatically give this column a value starting from 1).
- reference_no – control or monitoring number of the order transaction.
- customer_id – refers to the customer who transacted the order. It is a foreign key that links to the customer table.
- order_date – the date when the order was placed.
- order_status – the status of the order (accepted, declined, to deliver, to receive)
- expected_delivery_date – the date the order will be delivered to the customer.
- total_amount – total amount of the ordered products.
- number_of_items – total number of items being ordered.
- user_id – the user who encode/manage/update/approve the order information.
Create SQL Statement – the statement below is used to create the tbl_order, copy the sql statement and paste it in the sql manager/tab of your phpmyadmin.
CREATE TABLE `tbl_order` ( `order_id` int(11) NOT NULL, `reference_no` varchar(30) NOT NULL, `customer_id` int(11) NOT NULL, `order_date` date NOT NULL, `order_status` int(1) NOT NULL, `expected_delivery_date` date NOT NULL, `total_amount` float NOT NULL, `number_of_items` int(5) NOT NULL, `user_id` int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
tbl_order_detail – this table will hold and store the itemized order by the customer.
- order_detail_id – primary key of the table. It is set usually to auto_increment (the database will automatically give this column a value starting from 1).
- order_id – foreign key that links to the order table.
- pet_product_id – the list of items ordered by the customer, it is a foreign key that points out to the item or pet product table.
- quantity – the number of items ordered by the customer (per product)
- quantity_price – the price of the item. This was recorded since the price of the product in the product table might change or updated by the vendor.
- status – this column will store 0 for completed, 1 for delivery, 2 for cancelled.
- remarks – additional information or message on the item or product.
- vendor_id – the vendor will be the one who can manage and update the status per item.
Create SQL Statement – the statement below is used to create the tbl_order_detail, copy the sql statement and paste it in the sql manager/tab of your phpmyadmin.
CREATE TABLE `tbl_order_detail` ( `order_detail_id` int(11) NOT NULL, `order_id` int(11) NOT NULL, `pet_product_id` int(11) NOT NULL, `quantity` int(5) NOT NULL, `quantity_price` float NOT NULL, `status` int(1) NOT NULL, `remarks` varchar(100) NOT NULL, `vendor_id` int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
tbl_service – aside from pet information and pet product information, the vendor can also post their services on the platform and this table will that information.
- service_id – primary key of the table. It is set usually to auto_increment (the database will automatically give this column a value starting from 1).
- Reference_no
- service_name – name of the service (grooming, vaccination, check-up, etc)
- service_detail – detailed information about the service
- service_fee – service fee with additional charge of the platform.
- vendor_id – this is foreign key that points out to the vendor who posted the service information
- user_id – the user who encode/manage/update/approve the order information.
Create SQL Statement – the statement below is used to create the tbl_service, copy the sql statement and paste it in the sql manager/tab of your phpmyadmin.
CREATE TABLE `tbl_service` ( `service_id` int(11) NOT NULL, `reference_no` varchar(30) NOT NULL, `service_name` varchar(30) NOT NULL, `service_detail` varchar(100) NOT NULL, `service_fee` float NOT NULL, `vendor_id` int(11) NOT NULL, `user_id` int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
tbl_customer – this table will store the information of the customer, the table has 11 columns.
- customer_id – primary key of the table. It is set usually to auto_increment (the database will automatically give this column a value starting from 1).
- customer_code – a unique code given to the person (qr code, barcode, etc)
- avatar – this will hold the profile image of the person.
- customer_name – full name of the client/customer.
- email_address – email address of the client/customer.
- contact_number – contact number of the client/customer, preferably mobile or cellphone number.
- complete_address – complete address of the client/customer.
- username – the desired username of the client/customer.
- password – the desired password of the client/customer.
- status – the value of this column is 0 or 1, 0 means deactivated or inactive, 1 is activated or active.
- user_id – the user who accepts/approve/deactivate the customer profile and registration. It is a foreign key that connects to the user table.
Create SQL Statement – the statement below is used to create the tbl_customer, copy the sql statement and paste it in the sql manager/tab of your phpmyadmin.
CREATE TABLE `tbl_customer` ( `customer_id` int(11) NOT NULL, `customer_code` varchar(30) NOT NULL, `avatar` blob NOT NULL, `customer_name` varchar(30) NOT NULL, `email_address` varchar(30) NOT NULL, `contact_number` varchar(15) NOT NULL, `complete_address` varchar(100) NOT NULL, `username` varchar(30) NOT NULL, `password` varchar(30) NOT NULL, `status` int(1) NOT NULL, `user_id` int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
tbl_payment – payment information will be stored and archived on this table.
- payment_id – primary key of the table. It is set usually to auto_increment (the database will automatically give this column a value starting from 1).
- reference_no – it is either reference number of order or service.
- payment_for – 0 for order, 1 for service.
- amount_paid – amount paid by the customer.
- remarks – additional information on the transaction.
- payment_status – status of the payment (partial, fully paid)
- paid_by – person who processed the payment (it is usually the customer information).
- user_id – the user who processed the payment information.
Create SQL Statement – the statement below is used to create the tbl_payment, copy the sql statement and paste it in the sql manager/tab of your phpmyadmin.
CREATE TABLE `tbl_payment` ( `payment_id` int(11) NOT NULL, `reference_no` varchar(30) NOT NULL, `payment_for` int(1) NOT NULL, `amount_paid` float NOT NULL, `remarks` varchar(100) NOT NULL, `payment_status` int(1) NOT NULL, `paid_by` varchar(30) NOT NULL, `user_id` int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
tbl_vendor– this table will store the information of the laundry shop or company. The table has 7 columns.
- company_id – primary key of the table. It is set usually to auto_increment (the database will automatically give this column a value starting from 1).
- company_name – the complete name of the company.
- company_contact_person – contact person of the company
- company_email – official email address of the company
- company_contact_number – contact information of the company (landline, mobile, etc)
- company_website – official website of the company (if any)
- company_profile – this column is open for any content such as the history of the company, services offered, and any other information about the company or shop
- vendor_username – unique username of the vendor or shop owner/manager.
- vendor_password – strong password is required for this field.
- user_id – the user who accepts/approve/deactivate the company profile. It is a foreign key that connects to the user table.
Create SQL Statement – the statement below is used to create the tbl_setting, copy the sql statement and paste it in the sql manager/tab of your phpmyadmin.
CREATE TABLE `tbl_vendor` ( `company_id` int(11) NOT NULL, `company_name` varchar(50) NOT NULL, `company_contact_person` varchar(30) NOT NULL, `company_email` varchar(30) NOT NULL, `company_contact_number` varchar(15) NOT NULL, `company_website` varchar(30) NOT NULL, `company_profile` varchar(250) NOT NULL, `vendor_username` varchar(30) NOT NULL, `vendor_password` varchar(30) NOT NULL, `user_id` int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
tbl_user – this table will store the information of personnel who can access the records of the system.
- user_id – primary key of the table. It is set usually to auto_increment (the database will automatically give this column a value starting from 1).
- username – username of the personnel used to login together with the password.
- password – password of the personnel used to login together with the username.
- avatar – this will hold the profile image of the user.
- fullname – the complete name of the personnel or user.
- contact – contact number of the personnel (mobile/cellphone number).
- email – email address of the personnel/user.
- user_category_id – the user group or category of the user.
- status – the value of this column is 0 or 1, 0 means deactivated or inactive, 1 is activated or active.
Create SQL Statement – the statement below is used to create the tbl_user, copy the sql statement and paste it in the sql manager/tab of your phpmyadmin.
CREATE TABLE `tbl_user` ( `user_id` int(11) NOT NULL, `username` varchar(30) NOT NULL, `password` varchar(30) NOT NULL, `avatar` blob NOT NULL, `fullname` varchar(50) NOT NULL, `contact` varchar(15) NOT NULL, `email` varchar(30) NOT NULL, `user_category_id` int(1) NOT NULL, `status` int(1) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
tbl_user_group – this table store the information of the user group which includes the functions they can and can’t access in the system.
- user_group_id – primary key of the table. It is set usually to auto_increment (the database will automatically give this column a value starting from 1).
- group_name – name of the category or user group.
- description – information on what the user group is all about.
- allow_add – this column is to allow or prevent user from adding a record.
- allow_edit – this column is to allow or prevent user from editing or updating a record.
- allow_delete – this column is to allow or prevent user from removing or deleting a record.
- allow_print – this column is to allow or prevent user from printing a report.
- allow_import – this column is to allow or prevent user from importing records to the system.
- allow_export – this column is to allow or prevent user from exporting records from the system.
Create SQL Statement – the statement below is used to create the tbl_user_group, copy the sql statement and paste it in the sql manager/tab of your phpmyadmin.
CREATE TABLE `tbl_user_group` ( `user_group_id` int(11) NOT NULL, `group_name` varchar(30) NOT NULL, `description` varchar(50) NOT NULL, `allow_add` int(1) NOT NULL, `allow_edit` int(1) NOT NULL, `allow_delete` int(1) NOT NULL, `allow_print` int(1) NOT NULL, `allow_import` int(1) NOT NULL, `allow_export` int(1) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
Indexes for dumped tables
-- -- Indexes for table `tbl_customer` -- ALTER TABLE `tbl_customer` ADD PRIMARY KEY (`customer_id`), ADD KEY `user_id` (`user_id`); -- -- Indexes for table `tbl_order` -- ALTER TABLE `tbl_order` ADD PRIMARY KEY (`order_id`), ADD KEY `customer_id` (`customer_id`), ADD KEY `user_id` (`user_id`); -- -- Indexes for table `tbl_order_detail` -- ALTER TABLE `tbl_order_detail` ADD PRIMARY KEY (`order_detail_id`), ADD KEY `order_id` (`order_id`), ADD KEY `pet_product_id` (`pet_product_id`), ADD KEY `vendor_id` (`vendor_id`); -- -- Indexes for table `tbl_payment` -- ALTER TABLE `tbl_payment` ADD PRIMARY KEY (`payment_id`), ADD KEY `user_id` (`user_id`); -- -- Indexes for table `tbl_pet` -- ALTER TABLE `tbl_pet` ADD PRIMARY KEY (`pet_id`), ADD KEY `pet_category_id` (`pet_category_id`), ADD KEY `vendor_id` (`vendor_id`), ADD KEY `user_id` (`user_id`); -- -- Indexes for table `tbl_pet_category` -- ALTER TABLE `tbl_pet_category` ADD PRIMARY KEY (`pet_category_id`), ADD KEY `user_id` (`user_id`); -- -- Indexes for table `tbl_pet_product` -- ALTER TABLE `tbl_pet_product` ADD PRIMARY KEY (`pet_product_id`), ADD KEY `product_category_id` (`product_category_id`), ADD KEY `vendor_id` (`vendor_id`), ADD KEY `user_id` (`user_id`); -- -- Indexes for table `tbl_pet_product_category` -- ALTER TABLE `tbl_pet_product_category` ADD PRIMARY KEY (`product_category_id`), ADD KEY `user_id` (`user_id`); -- -- Indexes for table `tbl_service` -- ALTER TABLE `tbl_service` ADD PRIMARY KEY (`service_id`), ADD KEY `vendor_id` (`vendor_id`), ADD KEY `user_id` (`user_id`); -- -- Indexes for table `tbl_user` -- ALTER TABLE `tbl_user` ADD PRIMARY KEY (`user_id`), ADD KEY `user_category_id` (`user_category_id`); -- -- Indexes for table `tbl_user_group` -- ALTER TABLE `tbl_user_group` ADD PRIMARY KEY (`user_group_id`); -- -- Indexes for table `tbl_vendor` -- ALTER TABLE `tbl_vendor` ADD PRIMARY KEY (`company_id`), ADD KEY `user_id` (`user_id`); -- -- AUTO_INCREMENT for dumped tables -- -- -- AUTO_INCREMENT for table `tbl_customer` -- ALTER TABLE `tbl_customer` MODIFY `customer_id` int(11) NOT NULL AUTO_INCREMENT; -- -- AUTO_INCREMENT for table `tbl_order` -- ALTER TABLE `tbl_order` MODIFY `order_id` int(11) NOT NULL AUTO_INCREMENT; -- -- AUTO_INCREMENT for table `tbl_order_detail` -- ALTER TABLE `tbl_order_detail` MODIFY `order_detail_id` int(11) NOT NULL AUTO_INCREMENT; -- -- AUTO_INCREMENT for table `tbl_payment` -- ALTER TABLE `tbl_payment` MODIFY `payment_id` int(11) NOT NULL AUTO_INCREMENT; -- -- AUTO_INCREMENT for table `tbl_pet` -- ALTER TABLE `tbl_pet` MODIFY `pet_id` int(11) NOT NULL AUTO_INCREMENT; -- -- AUTO_INCREMENT for table `tbl_pet_category` -- ALTER TABLE `tbl_pet_category` MODIFY `pet_category_id` int(11) NOT NULL AUTO_INCREMENT; -- -- AUTO_INCREMENT for table `tbl_pet_product` -- ALTER TABLE `tbl_pet_product` MODIFY `pet_product_id` int(11) NOT NULL AUTO_INCREMENT; -- -- AUTO_INCREMENT for table `tbl_pet_product_category` -- ALTER TABLE `tbl_pet_product_category` MODIFY `product_category_id` int(11) NOT NULL AUTO_INCREMENT; -- -- AUTO_INCREMENT for table `tbl_service` -- ALTER TABLE `tbl_service` MODIFY `service_id` int(11) NOT NULL AUTO_INCREMENT; -- -- AUTO_INCREMENT for table `tbl_user` -- ALTER TABLE `tbl_user` MODIFY `user_id` int(11) NOT NULL AUTO_INCREMENT; -- -- AUTO_INCREMENT for table `tbl_user_group` -- ALTER TABLE `tbl_user_group` MODIFY `user_group_id` int(11) NOT NULL AUTO_INCREMENT; -- -- AUTO_INCREMENT for table `tbl_vendor` -- ALTER TABLE `tbl_vendor` MODIFY `company_id` int(11) NOT NULL AUTO_INCREMENT;
Constraints for dumped tables
-- -- Constraints for table `tbl_customer` -- ALTER TABLE `tbl_customer` ADD CONSTRAINT `tbl_customer_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `tbl_user` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE; -- -- Constraints for table `tbl_order` -- ALTER TABLE `tbl_order` ADD CONSTRAINT `tbl_order_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `tbl_user` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE, ADD CONSTRAINT `tbl_order_ibfk_2` FOREIGN KEY (`customer_id`) REFERENCES `tbl_customer` (`customer_id`) ON DELETE CASCADE ON UPDATE CASCADE; -- -- Constraints for table `tbl_order_detail` -- ALTER TABLE `tbl_order_detail` ADD CONSTRAINT `tbl_order_detail_ibfk_1` FOREIGN KEY (`pet_product_id`) REFERENCES `tbl_pet_product` (`pet_product_id`) ON DELETE CASCADE ON UPDATE CASCADE, ADD CONSTRAINT `tbl_order_detail_ibfk_2` FOREIGN KEY (`order_id`) REFERENCES `tbl_order` (`order_id`) ON DELETE CASCADE ON UPDATE CASCADE, ADD CONSTRAINT `tbl_order_detail_ibfk_3` FOREIGN KEY (`vendor_id`) REFERENCES `tbl_vendor` (`company_id`) ON DELETE CASCADE ON UPDATE CASCADE; -- -- Constraints for table `tbl_payment` -- ALTER TABLE `tbl_payment` ADD CONSTRAINT `tbl_payment_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `tbl_user` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE; -- -- Constraints for table `tbl_pet` -- ALTER TABLE `tbl_pet` ADD CONSTRAINT `tbl_pet_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `tbl_user` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE, ADD CONSTRAINT `tbl_pet_ibfk_2` FOREIGN KEY (`pet_category_id`) REFERENCES `tbl_pet_category` (`pet_category_id`) ON DELETE CASCADE ON UPDATE CASCADE, ADD CONSTRAINT `tbl_pet_ibfk_3` FOREIGN KEY (`vendor_id`) REFERENCES `tbl_vendor` (`company_id`) ON DELETE CASCADE ON UPDATE CASCADE; -- -- Constraints for table `tbl_pet_category` -- ALTER TABLE `tbl_pet_category` ADD CONSTRAINT `tbl_pet_category_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `tbl_user` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE; -- -- Constraints for table `tbl_pet_product` -- ALTER TABLE `tbl_pet_product` ADD CONSTRAINT `tbl_pet_product_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `tbl_user` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE, ADD CONSTRAINT `tbl_pet_product_ibfk_2` FOREIGN KEY (`product_category_id`) REFERENCES `tbl_pet_product_category` (`product_category_id`) ON DELETE CASCADE ON UPDATE CASCADE; -- -- Constraints for table `tbl_pet_product_category` -- ALTER TABLE `tbl_pet_product_category` ADD CONSTRAINT `tbl_pet_product_category_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `tbl_user` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE; -- -- Constraints for table `tbl_service` -- ALTER TABLE `tbl_service` ADD CONSTRAINT `tbl_service_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `tbl_user` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE, ADD CONSTRAINT `tbl_service_ibfk_2` FOREIGN KEY (`vendor_id`) REFERENCES `tbl_vendor` (`company_id`) ON DELETE CASCADE ON UPDATE CASCADE; -- -- Constraints for table `tbl_user` -- ALTER TABLE `tbl_user` ADD CONSTRAINT `tbl_user_ibfk_1` FOREIGN KEY (`user_category_id`) REFERENCES `tbl_user_group` (`user_group_id`) ON DELETE CASCADE ON UPDATE CASCADE; -- -- Constraints for table `tbl_vendor` -- ALTER TABLE `tbl_vendor` ADD CONSTRAINT `tbl_vendor_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `tbl_user` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE; COMMIT;
Our team can modify the project based on your specific business requirements.
You may visit our facebook page for more information, inquiries and comments.
Hire our team to do the project.