Certainly! Let's take a practical example of a database for a bookstore. We'll create a table to store information about books. Here's how the SQL code might look:
CREATE TABLE Books (
BookID INT,
Title VARCHAR(100),
Author VARCHAR(100),
ISBN VARCHAR(13),
Price DECIMAL(5,2),
InStock BOOLEAN
);
In this Books table:
-
BookIDis an integer that uniquely identifies each book. -
Titleis a variable character string that can store book titles up to 100 characters. -
Authoris a variable character string for the name of the author, also up to 100 characters. -
ISBNis the International Standard Book Number, a unique code for books. -
Priceis a decimal value that represents the cost of the book, with two digits after the decimal point. -
InStockis a boolean value indicating whether the book is currently in stock (true or false).
This table structure allows the bookstore to keep track of their inventory and book details efficiently.
Top comments (0)