{"id":3425,"date":"2026-01-14T11:07:49","date_gmt":"2026-01-14T03:07:49","guid":{"rendered":"https:\/\/five.co\/?p=3425"},"modified":"2026-01-30T15:51:01","modified_gmt":"2026-01-30T07:51:01","slug":"build-a-database-schema","status":"publish","type":"post","link":"https:\/\/preview-php85.dzine.org\/five\/blog\/build-a-database-schema\/","title":{"rendered":"Build a Database Schema In 5 Steps"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">How to Build a Database Schema <\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A database schema is a crucial component in database design that defines the structure, organization, and relationships of data within a database. Let&#8217;s break this down into steps and create a simple example to illustrate the process.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n<div class=\"root-eb-toc-levx4 wp-block-essential-blocks-table-of-contents\"><div class=\"eb-parent-wrapper eb-parent-eb-toc-levx4 \"><div class=\"eb-toc-container eb-toc-levx4  eb-toc-is-not-sticky eb-toc-not-collapsible eb-toc-initially-not-collapsed eb-toc-scrollToTop style-1 list-style-none\" data-scroll-top=\"false\" data-scroll-top-icon=\"fas fa-angle-up\" data-collapsible=\"false\" data-sticky-hide-mobile=\"false\" data-sticky=\"false\" data-scroll-target=\"scroll_to_toc\" data-copy-link=\"false\" data-editor-type=\"\" data-hide-desktop=\"false\" data-hide-tab=\"false\" data-hide-mobile=\"false\" data-itemcollapsed=\"false\" data-highlight-scroll=\"false\"><div class=\"eb-toc-header\"><h2 class=\"eb-toc-title\">Table of Contents<\/h2><\/div><div class=\"eb-toc-wrapper \" data-headers=\"[{&quot;level&quot;:2,&quot;content&quot;:&quot;How to Build a Database Schema &quot;,&quot;text&quot;:&quot;How to Build a Database Schema &quot;,&quot;link&quot;:&quot;how-to-build-a-database-schema&quot;},{&quot;level&quot;:2,&quot;content&quot;:&quot;Why You Need a Database Schema&quot;,&quot;text&quot;:&quot;Why You Need a Database Schema&quot;,&quot;link&quot;:&quot;why-you-need-a-database-schema&quot;},{&quot;level&quot;:2,&quot;content&quot;:&quot;Step by Step Guide: Building a Database Schema&quot;,&quot;text&quot;:&quot;Step by Step Guide: Building a Database Schema&quot;,&quot;link&quot;:&quot;step-by-step-guide-building-a-database-schema&quot;},{&quot;level&quot;:3,&quot;content&quot;:&quot;Step 1: Identify Entities&quot;,&quot;text&quot;:&quot;Step 1: Identify Entities&quot;,&quot;link&quot;:&quot;step-1-identify-entities&quot;},{&quot;level&quot;:3,&quot;content&quot;:&quot;Step 2: Define Attributes&quot;,&quot;text&quot;:&quot;Step 2: Define Attributes&quot;,&quot;link&quot;:&quot;step-2-define-attributes&quot;},{&quot;level&quot;:3,&quot;content&quot;:&quot;Step 3: Determine Primary Keys&quot;,&quot;text&quot;:&quot;Step 3: Determine Primary Keys&quot;,&quot;link&quot;:&quot;step-3-determine-primary-keys&quot;},{&quot;level&quot;:3,&quot;content&quot;:&quot;Step 4: Establish Relationships&quot;,&quot;text&quot;:&quot;Step 4: Establish Relationships&quot;,&quot;link&quot;:&quot;step-4-establish-relationships&quot;},{&quot;level&quot;:3,&quot;content&quot;:&quot;Step 5: Create Tables&quot;,&quot;text&quot;:&quot;Step 5: Create Tables&quot;,&quot;link&quot;:&quot;step-5-create-tables&quot;},{&quot;level&quot;:2,&quot;content&quot;:&quot;Example Entity-Relationship Diagram&quot;,&quot;text&quot;:&quot;Example Entity-Relationship Diagram&quot;,&quot;link&quot;:&quot;example-entity-relationship-diagram&quot;},{&quot;level&quot;:3,&quot;content&quot;:&quot;Get Started with Five Today&quot;,&quot;text&quot;:&quot;Get Started with Five Today&quot;,&quot;link&quot;:&quot;get-started-with-five-today&quot;}]\" data-visible=\"[true,true,true,true,true,true]\" data-delete-headers=\"[{&quot;label&quot;:&quot;How to Build a Database Schema &quot;,&quot;value&quot;:&quot;how-to-build-a-database-schema&quot;,&quot;isDelete&quot;:true},{&quot;label&quot;:&quot;Why You Need a Database Schema&quot;,&quot;value&quot;:&quot;why-you-need-a-database-schema&quot;,&quot;isDelete&quot;:false},{&quot;label&quot;:&quot;Step by Step Guide: Building a Database Schema&quot;,&quot;value&quot;:&quot;step-by-step-guide-building-a-database-schema&quot;,&quot;isDelete&quot;:false},{&quot;label&quot;:&quot;Step 1: Identify Entities&quot;,&quot;value&quot;:&quot;step-1-identify-entities&quot;,&quot;isDelete&quot;:false},{&quot;label&quot;:&quot;Step 2: Define Attributes&quot;,&quot;value&quot;:&quot;step-2-define-attributes&quot;,&quot;isDelete&quot;:false},{&quot;label&quot;:&quot;Step 3: Determine Primary Keys&quot;,&quot;value&quot;:&quot;step-3-determine-primary-keys&quot;,&quot;isDelete&quot;:false},{&quot;label&quot;:&quot;Step 4: Establish Relationships&quot;,&quot;value&quot;:&quot;step-4-establish-relationships&quot;,&quot;isDelete&quot;:false},{&quot;label&quot;:&quot;Step 5: Create Tables&quot;,&quot;value&quot;:&quot;step-5-create-tables&quot;,&quot;isDelete&quot;:false},{&quot;label&quot;:&quot;Example Entity-Relationship Diagram&quot;,&quot;value&quot;:&quot;example-entity-relationship-diagram&quot;,&quot;isDelete&quot;:false},{&quot;label&quot;:&quot;Get Started with Five Today&quot;,&quot;value&quot;:&quot;get-started-with-five-today&quot;,&quot;isDelete&quot;:true}]\" data-smooth=\"true\" data-top-offset=\"\"><div class=\"eb-toc__list-wrap\"><ul class=\"eb-toc__list\"><li><a href=\"#why-you-need-a-database-schema\">Why You Need a Database Schema<\/a><li><a href=\"#step-by-step-guide-building-a-database-schema\">Step by Step Guide: Building a Database Schema<\/a><ul class=\"eb-toc__list\"><li><a href=\"#step-1-identify-entities\">Step 1: Identify Entities<\/a><li><a href=\"#step-2-define-attributes\">Step 2: Define Attributes<\/a><li><a href=\"#step-3-determine-primary-keys\">Step 3: Determine Primary Keys<\/a><li><a href=\"#step-4-establish-relationships\">Step 4: Establish Relationships<\/a><li><a href=\"#step-5-create-tables\">Step 5: Create Tables<\/a><\/li><\/ul><li><a href=\"#example-entity-relationship-diagram\">Example Entity-Relationship Diagram<\/a><\/ul><\/div><\/div><\/div><\/div><\/div>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Why You Need a Database Schema<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A database schema is essentially the blueprint or structure of a database. It defines how data is organized and how the relations among them are associated. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A schema specifies what kinds of data can go into each table, helping to maintain data integrity. It outlines how different tables are related to each other, allowing for efficient data retrieval and management.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In practical terms, if you build a large web application without a database schema. You might end up with:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Inconsistent data (e.g., dates stored in different formats)<\/li>\n\n\n\n<li>Redundant data leading to update anomalies<\/li>\n\n\n\n<li>Difficulty in querying related data<\/li>\n\n\n\n<li>Performance issues as data volume grows<\/li>\n\n\n\n<li>Security vulnerabilities due to lack of access control at the data level<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">By contrast, with a well-designed schema, you have a solid foundation that supports the entire application, from data entry to reporting and analysis.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\">This guide provides a step-by-step process for building a database schema, using a simple library management system as an example. Here&#8217;s a brief overview of each step:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">1. Identify Entities: Using Books, Authors, and Borrowers as our main entities.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">2. Define Attributes: List the key attributes for each entity.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">3. Determine Primary Keys: Chose unique identifiers for each entity (ISBN for Books, AuthorID for Authors, and BorrowerID for Borrowers).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">4. Establish Relationships: Identify the many-to-many relationships between Books and Authors, and between Books and Borrowers.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">5. Create Tables: We provide SQL statements to create the necessary tables, including junction tables for the many-to-many relationships.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Step by Step Guide: Building a Database Schema<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Step 1: Identify Entities<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">First, identify the main entities (objects or concepts) in your system. These will become your tables.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example: For a simple library management system, we might have:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Books<\/li>\n\n\n\n<li>Authors<\/li>\n\n\n\n<li>Borrowers<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">Step 2: Define Attributes<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">For each entity, define its attributes (properties or characteristics). These will become the columns in your tables.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Books: ISBN, Title, PublicationYear, Genre<\/li>\n\n\n\n<li>Authors: AuthorID, FirstName, LastName, BirthDate<\/li>\n\n\n\n<li>Borrowers: BorrowerID, FirstName, LastName, Email<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">Step 3: Determine Primary Keys<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Choose a unique identifier for each entity. This will be the primary key for each table.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Books: ISBN (primary key)<\/li>\n\n\n\n<li>Authors: AuthorID (primary key)<\/li>\n\n\n\n<li>Borrowers: BorrowerID (primary key)<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">Step 4: Establish Relationships<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Identify how your entities relate to each other. This will help you create foreign keys and junction tables if needed.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A book can have multiple authors, and an author can write multiple books <a href=\"https:\/\/preview-php85.dzine.org\/five\/blog\/how-to-create-many-to-many-relationships-in-sql\/\">(many-to-many)<\/a><\/li>\n\n\n\n<li>A borrower can borrow multiple books, and a book can be borrowed by multiple borrowers over time <a href=\"https:\/\/preview-php85.dzine.org\/five\/blog\/how-to-create-many-to-many-relationships-in-sql\/\">(many-to-many)<\/a><\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">Step 5: Create Tables<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Building your tables can be done in traditional SQL using a SQL GUI such as MySQL Workbench, or you can create tables using modern relational database builders such as <a href=\"https:\/\/preview-php85.dzine.org\/five\/get-started\/\">Five<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Five gives you a simple point-and-click database builder for MySQL. All you have to do is create fields, and assign your field a data type (such as a string, float, integer, or binary), and define the relationships in point-and-click.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">One big advantage of Five is that it automatically creates\u00a0<em>Primary Keys<\/em>\u00a0and\u00a0<em>Foreign Keys<\/em>. These\u00a0<em>keys\u00a0<\/em>uniquely identify records and are used to build relationships between tables.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Once you define your data model, Five automatically creates a frontend web application, which you can then customize as needed.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">With Five you can significantly speed up the process of implementing your database schema, reduce the chance of errors, and easily make changes as your project evolves. It abstracts away much of the complexity, allowing you to focus on your data model and business logic rather than the intricacies of database management.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<div style=\"background-color: #001524;\"><hr style=\"height: 5px;\" \/>\n<pre style=\"text-align: center; overflow: hidden; white-space: pre-line;\"><span style=\"color: #f1ebda; background-color: #4588d8; font-size: calc(18px + 0.390625vw);\"><strong>Build a Database Web Application<\/strong><br \/><span style=\"font-size: 14pt;\">Rapidly build and deploy your database using Five<\/span><\/span><\/pre>\n<p style=\"text-align: center;\"><a href=\"https:\/\/preview-php85.dzine.org\/five\/get-started\" target=\"_blank\" rel=\"noopener\"><button style=\"background-color: #f8b92b; border: none; color: black; padding: 20px; text-align: center; text-decoration: none; display: inline-block; font-size: 18px; cursor: pointer; margin: 4px 2px; border-radius: 5px;\"><strong>Get Instant Access<\/strong><\/button><br \/><\/a><\/p>\n<hr style=\"height: 5px;\" \/><\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\">Tables based on the entities, attributes, and relationships we&#8217;ve identified:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#abb2bf;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#282c34\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"CREATE TABLE Books (\n    ISBN VARCHAR(13) PRIMARY KEY,\n    Title VARCHAR(255) NOT NULL,\n    PublicationYear INT,\n    Genre VARCHAR(50)\n);\n\nCREATE TABLE Authors (\n    AuthorID INT PRIMARY KEY AUTO_INCREMENT,\n    FirstName VARCHAR(50),\n    LastName VARCHAR(50),\n    BirthDate DATE\n);\n\nCREATE TABLE Borrowers (\n    BorrowerID INT PRIMARY KEY AUTO_INCREMENT,\n    FirstName VARCHAR(50),\n    LastName VARCHAR(50),\n    Email VARCHAR(100) UNIQUE,\n    RegistrationDate DATE\n);\n\nCREATE TABLE BookAuthors (\n    ISBN VARCHAR(13),\n    AuthorID INT,\n    PRIMARY KEY (ISBN, AuthorID),\n    FOREIGN KEY (ISBN) REFERENCES Books(ISBN),\n    FOREIGN KEY (AuthorID) REFERENCES Authors(AuthorID)\n);\n\nCREATE TABLE BookLoans (\n    LoanID INT PRIMARY KEY AUTO_INCREMENT,\n    ISBN VARCHAR(13),\n    BorrowerID INT,\n    LoanDate DATE,\n    DueDate DATE,\n    ReturnDate DATE,\n    FOREIGN KEY (ISBN) REFERENCES Books(ISBN),\n    FOREIGN KEY (BorrowerID) REFERENCES Borrowers(BorrowerID)\n);\" style=\"color:#abb2bf;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki one-dark-pro\" style=\"background-color: #282c34\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #C678DD\">CREATE<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #C678DD\">TABLE<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #61AFEF\">Books<\/span><span style=\"color: #ABB2BF\"> (<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    ISBN <\/span><span style=\"color: #C678DD\">VARCHAR<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #D19A66\">13<\/span><span style=\"color: #ABB2BF\">) <\/span><span style=\"color: #C678DD\">PRIMARY KEY<\/span><span style=\"color: #ABB2BF\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    Title <\/span><span style=\"color: #C678DD\">VARCHAR<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #D19A66\">255<\/span><span style=\"color: #ABB2BF\">) <\/span><span style=\"color: #C678DD\">NOT NULL<\/span><span style=\"color: #ABB2BF\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    PublicationYear <\/span><span style=\"color: #C678DD\">INT<\/span><span style=\"color: #ABB2BF\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    Genre <\/span><span style=\"color: #C678DD\">VARCHAR<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #D19A66\">50<\/span><span style=\"color: #ABB2BF\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">);<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #C678DD\">CREATE<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #C678DD\">TABLE<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #61AFEF\">Authors<\/span><span style=\"color: #ABB2BF\"> (<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    AuthorID <\/span><span style=\"color: #C678DD\">INT<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #C678DD\">PRIMARY KEY<\/span><span style=\"color: #ABB2BF\"> AUTO_INCREMENT,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    FirstName <\/span><span style=\"color: #C678DD\">VARCHAR<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #D19A66\">50<\/span><span style=\"color: #ABB2BF\">),<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    LastName <\/span><span style=\"color: #C678DD\">VARCHAR<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #D19A66\">50<\/span><span style=\"color: #ABB2BF\">),<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    BirthDate <\/span><span style=\"color: #C678DD\">DATE<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">);<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #C678DD\">CREATE<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #C678DD\">TABLE<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #61AFEF\">Borrowers<\/span><span style=\"color: #ABB2BF\"> (<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    BorrowerID <\/span><span style=\"color: #C678DD\">INT<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #C678DD\">PRIMARY KEY<\/span><span style=\"color: #ABB2BF\"> AUTO_INCREMENT,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    FirstName <\/span><span style=\"color: #C678DD\">VARCHAR<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #D19A66\">50<\/span><span style=\"color: #ABB2BF\">),<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    LastName <\/span><span style=\"color: #C678DD\">VARCHAR<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #D19A66\">50<\/span><span style=\"color: #ABB2BF\">),<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    Email <\/span><span style=\"color: #C678DD\">VARCHAR<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #D19A66\">100<\/span><span style=\"color: #ABB2BF\">) <\/span><span style=\"color: #C678DD\">UNIQUE<\/span><span style=\"color: #ABB2BF\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    RegistrationDate <\/span><span style=\"color: #C678DD\">DATE<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">);<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #C678DD\">CREATE<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #C678DD\">TABLE<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #61AFEF\">BookAuthors<\/span><span style=\"color: #ABB2BF\"> (<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    ISBN <\/span><span style=\"color: #C678DD\">VARCHAR<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #D19A66\">13<\/span><span style=\"color: #ABB2BF\">),<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    AuthorID <\/span><span style=\"color: #C678DD\">INT<\/span><span style=\"color: #ABB2BF\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    <\/span><span style=\"color: #C678DD\">PRIMARY KEY<\/span><span style=\"color: #ABB2BF\"> (ISBN, AuthorID),<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    <\/span><span style=\"color: #C678DD\">FOREIGN KEY<\/span><span style=\"color: #ABB2BF\"> (ISBN) <\/span><span style=\"color: #C678DD\">REFERENCES<\/span><span style=\"color: #ABB2BF\"> Books(ISBN),<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    <\/span><span style=\"color: #C678DD\">FOREIGN KEY<\/span><span style=\"color: #ABB2BF\"> (AuthorID) <\/span><span style=\"color: #C678DD\">REFERENCES<\/span><span style=\"color: #ABB2BF\"> Authors(AuthorID)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">);<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #C678DD\">CREATE<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #C678DD\">TABLE<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #61AFEF\">BookLoans<\/span><span style=\"color: #ABB2BF\"> (<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    LoanID <\/span><span style=\"color: #C678DD\">INT<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #C678DD\">PRIMARY KEY<\/span><span style=\"color: #ABB2BF\"> AUTO_INCREMENT,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    ISBN <\/span><span style=\"color: #C678DD\">VARCHAR<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #D19A66\">13<\/span><span style=\"color: #ABB2BF\">),<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    BorrowerID <\/span><span style=\"color: #C678DD\">INT<\/span><span style=\"color: #ABB2BF\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    LoanDate <\/span><span style=\"color: #C678DD\">DATE<\/span><span style=\"color: #ABB2BF\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    DueDate <\/span><span style=\"color: #C678DD\">DATE<\/span><span style=\"color: #ABB2BF\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    ReturnDate <\/span><span style=\"color: #C678DD\">DATE<\/span><span style=\"color: #ABB2BF\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    <\/span><span style=\"color: #C678DD\">FOREIGN KEY<\/span><span style=\"color: #ABB2BF\"> (ISBN) <\/span><span style=\"color: #C678DD\">REFERENCES<\/span><span style=\"color: #ABB2BF\"> Books(ISBN),<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    <\/span><span style=\"color: #C678DD\">FOREIGN KEY<\/span><span style=\"color: #ABB2BF\"> (BorrowerID) <\/span><span style=\"color: #C678DD\">REFERENCES<\/span><span style=\"color: #ABB2BF\"> Borrowers(BorrowerID)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">);<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Example Entity-Relationship Diagram<\/h2>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/preview-php85.dzine.org\/five\/get-started\/\"><img width=\"1024\" height=\"573\" src=\"https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2024\/07\/Screenshot-2024-07-29-at-10.37.51-am-1024x573.png\" alt=\"\" class=\"wp-image-3426\" srcset=\"https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2024\/07\/Screenshot-2024-07-29-at-10.37.51-am-1024x573.png 1024w, https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2024\/07\/Screenshot-2024-07-29-at-10.37.51-am-300x168.png 300w, https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2024\/07\/Screenshot-2024-07-29-at-10.37.51-am-768x430.png 768w, https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2024\/07\/Screenshot-2024-07-29-at-10.37.51-am.png 1407w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">Instead of writing SQL to create your database schema, Five allows you to visually create your data model, which it then translates into a database structure.<\/figcaption><\/figure>\n<\/div>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\">The above Entity-Relationship Diagram (ERD) represents the library management system we described earlier.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Entities:\n<ul class=\"wp-block-list\">\n<li>BOOKS: Represents the books in the library.<\/li>\n\n\n\n<li>AUTHORS: Represents the authors of the books.<\/li>\n\n\n\n<li>BORROWERS: Represents the people who borrow books from the library.<\/li>\n\n\n\n<li>BOOK_AUTHOR: A junction table representing the many-to-many relationship between books and authors.<\/li>\n\n\n\n<li>BOOK_LOAN: Represents the borrowing transactions.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Attributes:\n<ul class=\"wp-block-list\">\n<li>Each entity has its attributes listed. The primary keys are marked with &#8220;PK&#8221; and foreign keys with &#8220;FK&#8221;.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Relationships:\n<ul class=\"wp-block-list\">\n<li>BOOKS ||&#8211;o{ BOOK_AUTHOR : This means a book can have many entries in the BOOK_AUTHOR table (i.e., can have multiple authors).<\/li>\n\n\n\n<li>AUTHORS ||&#8211;o{ BOOK_AUTHOR : An author can have many entries in the BOOK_AUTHOR table (i.e., can write multiple books).<\/li>\n\n\n\n<li>BOOKS ||&#8211;o{ BOOK_LOAN : A book can be involved in many loan transactions.<\/li>\n\n\n\n<li>BORROWERS ||&#8211;o{ BOOK_LOAN : A borrower can have many loan transactions.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">The notation &#8220;||&#8211;o{&#8221; represents a &#8220;<a href=\"https:\/\/preview-php85.dzine.org\/five\/blog\/how-to-create-one-to-many-relationships-in-sql\/\">one-to-many<\/a>&#8221; relationship. The &#8220;||&#8221; side is the &#8220;one&#8221; side, and the &#8220;o{&#8221; side is the &#8220;many&#8221; side.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This ERD visualizes the structure of our database, showing how the different entities are related to each other.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">Get Started with Five Today<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">To build your data driven web application with Five,\u00a0<a href=\"https:\/\/preview-php85.dzine.org\/five\/get-started\">sign up for free access<\/a>\u00a0and start the process. If you need assistance, visit our\u00a0<a href=\"https:\/\/five.org\/\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">forum<\/a>\u00a0and get help from our application development experts.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>How to Build a Database Schema A database schema is a crucial component in database design that defines the structure, organization, and relationships of data within a database. Let&#8217;s break this down into steps and create a simple example to illustrate the process. Why You Need a Database Schema A database schema is essentially the [&hellip;]<\/p>\n","protected":false},"author":11,"featured_media":3427,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_eb_attr":"","_uag_custom_page_level_css":"","footnotes":""},"categories":[21],"tags":[],"class_list":["post-3425","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog"],"acf":[],"uagb_featured_image_src":{"full":["https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2024\/07\/Five.Co-How-to-Build-a-Database-Schema.png",1280,720,false],"thumbnail":["https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2024\/07\/Five.Co-How-to-Build-a-Database-Schema-150x150.png",150,150,true],"medium":["https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2024\/07\/Five.Co-How-to-Build-a-Database-Schema-300x169.png",300,169,true],"medium_large":["https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2024\/07\/Five.Co-How-to-Build-a-Database-Schema-768x432.png",768,432,true],"large":["https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2024\/07\/Five.Co-How-to-Build-a-Database-Schema-1024x576.png",1024,576,true],"1536x1536":["https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2024\/07\/Five.Co-How-to-Build-a-Database-Schema.png",1280,720,false],"2048x2048":["https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2024\/07\/Five.Co-How-to-Build-a-Database-Schema.png",1280,720,false]},"uagb_author_info":{"display_name":"Ryan Forrester","author_link":"https:\/\/preview-php85.dzine.org\/five\/author\/f1v5_ed9_au\/"},"uagb_comment_info":0,"uagb_excerpt":"How to Build a Database Schema A database schema is a crucial component in database design that defines the structure, organization, and relationships of data within a database. Let&#8217;s break this down into steps and create a simple example to illustrate the process. Why You Need a Database Schema A database schema is essentially the&hellip;","_links":{"self":[{"href":"https:\/\/preview-php85.dzine.org\/five\/wp-json\/wp\/v2\/posts\/3425","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/preview-php85.dzine.org\/five\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/preview-php85.dzine.org\/five\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/preview-php85.dzine.org\/five\/wp-json\/wp\/v2\/users\/11"}],"replies":[{"embeddable":true,"href":"https:\/\/preview-php85.dzine.org\/five\/wp-json\/wp\/v2\/comments?post=3425"}],"version-history":[{"count":0,"href":"https:\/\/preview-php85.dzine.org\/five\/wp-json\/wp\/v2\/posts\/3425\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/preview-php85.dzine.org\/five\/wp-json\/wp\/v2\/media\/3427"}],"wp:attachment":[{"href":"https:\/\/preview-php85.dzine.org\/five\/wp-json\/wp\/v2\/media?parent=3425"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/preview-php85.dzine.org\/five\/wp-json\/wp\/v2\/categories?post=3425"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/preview-php85.dzine.org\/five\/wp-json\/wp\/v2\/tags?post=3425"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}