失效链接处理 |
SQL Queries For Beginners PDF 下蝲
本站整理下蝲Q?/strong>
链接Q?a target="_blank">https://pan.baidu.com/s/1F8mRLlmGkHA7mGjBV8I2CA
提取码:9wbz
相关截图Q?/strong>
![]()
主要内容Q?/strong>
Before we start we will first create a table and insert some sample data into it so we can use these
tables in our select class. I want to explain the table design with actual data since that will help
the reader to understand this in detail.
In database design the important phase is to create a table with proper normalization with
primary and foreign key relationships.
Now in this example we will assume we need to create a restaurant Order Management tables
with relationships.
For this we need an Order Master, an Order Detail and an Item Master as the major tables. We
will use these 3 tables in this article. First let's start by creating the tables. As I have said, we will
use the 3 tables here in this article so we start by creating the Item Master as the first table. As
the name suggests this table will be used to store the items.
Create Table
Item Master: Here we have created an ItemMaster with the necessary fields. As I already said,
we need to make a plan about our project. List all the necessary tables we need to create for the
project and describe and list all the fields to be created for each table. Here I used Item_Code as
a primary key field that will be used in another table for the reference to this main table.
1. CREATE TABLE [dbo].[ItemMasters](
2. [Item_Code] [varchar](20) NOT NULL,
3. [Item_Name] [varchar](100) NOT NULL,
4. [Price] Int NOT NULL,
5. [TAX1] Int NOT NULL,
6. [Discount] Int NOT NULL,
7. [Description] [varchar](200) NOT NULL,
8. [IN_DATE] [datetime] NOT NULL,
9. [IN_USR_ID] [varchar](20) NOT NULL,
10. [UP_DATE] [datetime] NOT NULL,
11. [UP_USR_ID] [varchar](20) NOT NULL,
12. CONSTRAINT [PK_ItemMasters] PRIMARY KEY CLUSTERED
13. (
14. [Item_Code] ASC
15. )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW
_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
16. ) ON [PRIMARY]
|