The OpenNET Project / Index page

[ ÎÏ×ÏÓÔÉ /+++ | ÆÏÒÕÍ | ÔÅÇÉ | ]

ëÁÔÁÌÏÇ ÄÏËÕÍÅÎÔÁÃÉÉ / òÁÚÄÅÌ "âÁÚÙ ÄÁÎÎÙÈ, SQL" / ïÇÌÁ×ÌÅÎÉÅ ÄÏËÕÍÅÎÔÁ

ðÒÉÍÅÒ ÂÁÚÙ ÄÁÎÎÙÈ

üÔÏ ÐÒÏÓÔÏÊ ÐÒÉÍÅÒ ÔÏÇÏ, ËÁË ÍÏÖÅÔ ×ÙÇÌÑÄÅÔØ ×ÐÏÌÎÅ ÔÉÐÉÞÎÁÑ ÂÁÚÁ ÄÁÎÎÙÈ.

÷ ÐÒÏÅËÔÉÒÏ×ÁÎÉÉ ÂÁÚÙ ÄÁÎÎÙÈ ÐÅÒ×ÏÅ ÄÅÌÏ, ËÏÔÏÒÏÅ ÷Ù ÄÏÌÖÎÙ ÓÄÅÌÁÔØ, ÜÔÏ ×ÙÞÉÓÌÉÔØ ÐÏÓÌÅÄÏ×ÁÔÅÌØÎÏÓÔØ ÄÅÊÓÔ×ÉÊ, ÎÅÏÂÈÏÄÉÍÙÈ ÷ÁÍ ÄÌÑ ÒÅÛÅÎÉÑ ÐÏÓÔÁ×ÌÅÎÎÏÊ ÚÁÄÁÞÉ. ÷ SQL ÜÔÏ ÍÏÖÅÔ ×ÙÇÌÑÄÅÔØ ÔÁË:

ôÁÂÌÉÃÙ

# The Widget table.
#
# Detailed information on a widget.  Linked to by Purchase_Order_Item
# by way of the widget_id field.  Linked to Widget_Color by way of
# the widget_color field, and to the Widget_Size table by way of the
# widget_size field.
CREATE TABLE Widget_Table (
  widget_id MEDIUMINT(8) NOT NULL AUTO_INCREMENT,
  widget_name CHAR(60) NOT NULL,
  widget_color_id MEDIUMINT(8) NOT NULL,
  widget_size_id MEDIUMINT(8) NOT NULL,
  widgets_on_hand SMALLINT NOT NULL,
  widget_price FLOAT(8,2) NOT NULL,
  commission_percent FLOAT(2,2) NOT NULL,
  PRIMARY KEY (widget_id),
  KEY (widget_name),
  KEY (widget_color_id,widget_size_id)
);

ðÅÒ×ÁÑ ÓÔÒÏËÁ ÓÏÏÂÝÁÅÔ óõâä MySQL, ÞÔÏ ÍÙ ÏÐÒÅÄÅÌÑÅÍ ÔÁÂÌÉÃÕ ÐÏ ÉÍÅÎÉ Widget_Table. óÌÅÄÕÀÝÉÅ ÛÅÓÔØ ÓÔÒÏË ÏÐÒÅÄÅÌÑÀÔ ÐÏÌÑ, ËÏÔÏÒÙÅ ÔÁÂÌÉÃÁ ÓÏÄÅÒÖÉÔ, ÔÉÐ ÄÁÎÎÙÈ, ËÏÔÏÒÙÅ ×ÈÏÄÑÔ × ÎÉÈ, É ËÁËÉÅ ÁÔÒÉÂÕÔÙ ÜÔÉ ÐÏÌÑ ÉÍÅÀÔ.

ðÒÅÖÄÅ, ÞÅÍ ÷Ù ÓÍÏÖÅÔÅ ÓÏÚÄÁÔØ ÜÔÕ ÔÁÂÌÉÃÕ, ÷Ù ÄÏÌÖÎÙ ÓÏÚÄÁÔØ ÐÕÓÔÕÀ ÂÁÚÕ ÄÁÎÎÙÈ. ÷ MySQL ÜÔÏ ×ÙÐÏÌÎÅÎÏ ÐÏÓÒÅÄÓÔ×ÏÍ ÐÒÏÇÒÁÍÍÙ mysqladmin.


prompt> mysqladmin create Widget-DB

ïÄÎÁ ÉÚ ÍÎÏÖÅÓÔ×Á ÏÓÎÏ×ÎÙÈ ËÏÎÃÅÐÃÉÊ × ÈÏÒÏÛÅÍ ÐÒÏÅËÔÅ ÒÅÌÑÃÉÏÎÎÏÊ ÂÁÚÙ ÄÁÎÎÙÈ ÜÔÏ ÔÏ, ÞÔÏ ÷Ù ÎÉËÏÇÄÁ ÎÅ ÄÏÌÖÎÙ ÈÒÁÎÉÔØ ÉÚÂÙÔÏÞÎÙÅ ÄÁÎÎÙÅ. ÷ ÓÌÕÞÁÅ Widget_Table ÜÔÏ ÏÔÒÁÖÅÎÏ × ÐÏÌÑÈ Widget_color_id É widget_size_id. üÔÉ Ä×Á ÐÏÌÑ ÍÏÇÌÉ ÂÙ ÂÙÔØ ÓÔÒÏËÁÍÉ. ÷ÚÁÍÅÎ ÍÙ ÄÅÌÁÅÍ ÉÈ ÕËÁÚÁÔÅÌÑÍÉ ÎÁ ÄÒÕÇÉÅ ÔÁÂÌÉÃÙ, ËÏÔÏÒÙÅ ÂÕÄÕÔ ÓÏÄÅÒÖÁÔØ ÏÄÎÕ ÚÁÐÉÓØ ÄÌÑ ËÁÖÄÏÇÏ ×ÏÚÍÏÖÎÏÇÏ ÚÎÁÞÅÎÉÑ, ËÏÔÏÒÏÅ ÍÏÖÅÔ ÓÏÄÅÒÖÁÔØ ÔÁËÏÅ ÐÏÌÅ.

üÔÏ ÓÄÅÌÁÎÏ ÐÏ Ä×ÕÍ ÐÒÉÞÉÎÁÍ:

ðÅÒ×ÁÑ ÐÒÉÞÉÎÁ - ÆÁËÔÉÞÅÓËÉ ÐÏÄÓÌÕÞÁÊ ×ÔÏÒÏÊ. çÏÒÁÚÄÏ ÐÒÏÝÅ ÐÏÄÄÅÒÖÁÔØ ÎÅÐÒÏÔÉ×ÏÒÅÞÉ×ÏÓÔØ × ÂÁÚÅ ÄÁÎÎÙÈ, ÅÓÌÉ ÷Ù ÉÓÐÏÌØÚÕÅÔÅ ÔÁÂÌÉÃÙ, ÞÔÏÂÙ ÉÓËÁÔØ ÚÎÁÞÅÎÉÑ. üÔÏ ÂÕÄÅÔ ÐÒÅÄÏÈÒÁÎÑÔØ ÌÀÄÅÊ ÏÔ ÓÏÚÄÁÎÉÑ ÐÒÉËÌÁÄÎÙÈ ÐÒÏÇÒÁÍÍ, ËÏÔÏÒÙÅ ÉÓÐÏÌØÚÕÀÔ ×ÓÅ ÏÔ "L" ÄÏ "HUGE", ÞÔÏÂÙ ÏÂÏÚÎÁÞÉÔØ, ÞÔÏ ÒÁÚÍÅÒ ÒÁÓÓÍÁÔÒÉ×ÁÅÍÏÇÏ ÏÂßÅËÔÁ ÂÏÌØÛÏÊ.

Widget_id ÐÏÌÅ - ÓÒÅÄÁ (3 ÂÁÊÔ) ÕÓÔÁÎÏ×ÌÅÎÎÏÅ ÐÏ ÒÁÚÍÅÒÕ ÃÅÌÏÅ ÞÉÓÌÏ. üÔÏ ÉÍÅÅÔ ÓÐÅÃÉÁÌØÎÙÅ ÁÔÒÉÂÕÔÙ NOT NULL É AUTO_INCREMENT. NOT NULL Ñ×ÌÑÅÔÓÑ ANSI SQL ÓÔÁÎÄÁÒÔÏÍ É ÏÐÒÅÄÅÌÑÅÔ ÞÔÏ, ËÏÇÄÁ ËÔÏ-ÔÏ ××ÏÄÉÔ widget ÉÎÆÏÒÍÁÃÉÀ × ÜÔÕ ÔÁÂÌÉÃÕ, ÏÎÉ ÄÏÌÖÎÙ ÄÁÔØ ÎÅËÏÔÏÒÏÅ ÚÎÁÞÅÎÉÅ ÄÌÑ ÜÔÏÇÏ ÐÏÌÑ. åÓÌÉ ÎÅ ÄÁÌÉ, MySQL ÎÁÚÎÁÞÉÔ ÐÏÌÀ ÚÎÁÞÅÎÉÅ ÐÏ ÕÍÏÌÞÁÎÉÀ. ëÏÎÅÞÎÏ, ÅÓÌÉ ÚÎÁÞÅÎÉÅ ÐÏ ÕÍÏÌÞÁÎÉÀ ÂÙÌÏ ÏÐÒÅÄÅÌÅÎÏ, ÔÏ ÂÕÄÅÔ ÉÓÐÏÌØÚÏ×ÁÔØÓÑ ÏÎÏ, ËÏÇÄÁ ÎÅ ÚÁÄÁÎÏ ÎÉËÁËÏÇÏ ÚÎÁÞÅÎÉÑ. åÓÌÉ ÖÅ ÏÎÏ ÎÅ ÏÐÒÅÄÅÌÅÎÏ, ÔÏ ÐÏÌÅ ÐÏÌÕÞÉÔ ÚÎÁÞÅÎÉÅ, ÉÓÈÏÄÑ ÉÚ ÅÇÏ ÔÉÐÁ.

AUTO_INCREMENT ÓÐÅÃÉÆÉÞÅÓËÉÊ ÁÔÒÉÂÕÔ MySQL. åÓÌÉ ÷Ù ×ÓÔÁ×ÌÑÅÔÅ ÎÏÌØ × ÜÔÏ ÐÏÌÅ MySQL, Á×ÔÏÍÁÔÉÞÅÓËÉ ÎÁÚÎÁÞÉÔ ÚÎÁÞÅÎÉÅ, ËÏÔÏÒÏÅ ÎÁ ÅÄÉÎÉÃÕ ×ÙÛÅ, ÞÅÍ ÓÁÍÏÅ ×ÙÓÏËÏÅ ÐÒÅÄÙÄÕÝÅÅ ÚÎÁÞÅÎÉÅ, ÎÁÚÎÁÞÅÎÎÏÅ Ë ÜÔÏÍÕ ÐÏÌÀ × ÜÔÏÊ ÔÁÂÌÉÃÅ. üÔÏ ÐÒÏÓÔÏÊ ÍÅÔÏÄ ÄÌÑ ÐÒÏÉÚ×ÏÄÓÔ×Á ÕÎÉËÁÌØÎÙÈ ÉÄÅÎÔÉÆÉËÁÔÏÒÏ× ÄÌÑ ÎÏ×ÏÇÏ widgets, ÐÏÓËÏÌØËÕ ÏÎÉ ××ÅÄÅÎÙ × ÔÁÂÌÉÃÕ.

íÙ ÔÁËÖÅ ÏÐÒÅÄÅÌÑÅÍ ÎÅÓËÏÌØËÏ ËÌÀÞÅÊ. ëÏÇÄÁ ÷Ù ÎÁÚÎÁÞÁÅÔÅ ÐÏÌÀ ÁÔÒÉÂÕÔ AUTO_INCREMENT, ÷Ù ÄÏÌÖÎÙ ÔÁËÖÅ ÏÐÒÅÄÅÌÉÔØ ÜÔÏ ÐÏÌÅ ËÁË ÐÅÒ×ÉÞÎÙÊ ËÌÀÞ. ÷Ù ÍÏÖÅÔÅ ÉÍÅÔØ ÔÏÌØËÏ ÏÄÉÎ ÐÅÒ×ÉÞÎÙÊ ËÌÀÞ ÎÁ ÔÁÂÌÉÃÕ. ôÏÌØËÏ ÏÄÎÏ ÐÏÌÅ ÎÁ ÔÁÂÌÉÃÕ ÍÏÖÅÔ ÉÍÅÔØ AUTO_INCREMENT ÁÔÒÉÂÕÔ.

íÙ ÔÁËÖÅ ÓÏÚÄÁÅÍ ×ÔÏÒÉÞÎÙÅ ÉÎÄÅËÓÙ ÉÓÐÏÌØÚÏ×ÁÎÉÅÍ ÓÌÏ×Á KEY. éÎÄÅËÓÉÒÏ×ÁÎÉÅ ÚÎÁÞÉÔÅÌØÎÏ Õ×ÅÌÉÞÉ×ÁÅÔ ÂÙÓÔÒÏÄÅÊÓÔ×ÉÅ ÚÁÐÒÏÓÏ× É ÏÂßÅÄÉÎÅÎÉÊ. éÎÄÅËÓÙ ÍÏÇÕÔ ×ËÌÀÞÁÔØ ÂÏÌØÛÅ ÞÅÍ ÏÄÎÏ ÐÏÌÅ. åÓÌÉ ÷Ù ÉÍÅÅÔÅ ÉÎÄÅËÓ, ËÏÔÏÒÙÊ ×ËÌÀÞÁÅÔ ÂÏÌØÛÅ ÞÅÍ ÏÄÎÏ ÐÏÌÅ, ÷Ù ÎÅ ÎÕÖÄÁÅÔÅÓØ × ÓÏÚÄÁÎÉÉ ÄÒÕÇÏÇÏ ÉÎÄÅËÓÁ Ó ÐÅÒ×ÙÍ ÐÏÌÅÍ × ÓÏÓÔÁ×ÎÏÍ ÉÎÄÅËÓÅ.

íÙ ÏÐÒÅÄÅÌÉÌÉ Widget_Table. ôÅÐÅÒØ ÎÁÄÏ ÏÐÒÅÄÅÌÉÔØ ÐÕÔØ ÓÌÅÖÅÎÉÑ ÚÁ ÚÁËÁÚÁÍÉ. äÌÑ ÜÔÏÊ ÃÅÌÉ ÍÙ ÏÐÒÅÄÅÌÑÅÍ ÔÁÂÌÉÃÕ Purchase_Order.

# The Purchase Order table.
#
# customer_id links us to the Customer_Table
# Where we can get more information about the customer.
#
# To allow for N items on a Purchase order we have to
# have another table called Purchase_Order_Item that
# we link to be way of purchase_order.
CREATE TABLE Purchase_Order (
  purchase_order MEDIUMINT(8) NOT NULL AUTO_INCREMENT,
  customer_id SMALLINT NOT NULL,
  order_date DATE NOT NULL,
  due_date DATE NOT NULL,
  close_date DATE NOT NULL,
  status_code TINYINT(2) UNSIGNED NOT NULL,
  last_action_date TIMESTAMP,
  PRIMARY KEY (purchase_order),
  KEY (customer_id,order_date,status_code)
);

íÙ ÓÞÉÔÁÅÍ, ÞÔÏ ÚÁËÁÚÞÉË ÓÏÂÉÒÁÅÔÓÑ ÚÁËÁÚÙ×ÁÔØ Õ ÎÁÓ ÔÏ×ÁÒ ÂÏÌÅÅ ÞÅÍ ÏÄÎÁÖÄÙ. ðÏ ÜÔÏÊ ÐÒÉÞÉÎÅ ×ÍÅÓÔÏ ÚÁÐÉÓÅÊ Ï ÁÄÒÅÓÅ É ÉÍÅÎÉ ÚÁËÁÚÞÉËÁ, ÍÙ ÎÁÚÎÁÞÁÅÍ ËÁÖÄÏÍÕ ÚÁËÁÚÞÉËÕ ÕÎÉËÁÌØÎÙÊ ÎÏÍÅÒ ÉÄÅÎÔÉÆÉËÁÃÉÉ, ËÏÔÏÒÙÊ Ó×ÑÚÙ×ÁÅÔ ÎÁÓ ÓÏ ×ÈÏÄÏÍ × ÔÁÂÌÉÃÅ, ËÏÔÏÒÁÑ ÓÏÄÅÒÖÉÔ ÜÔÕ ÉÎÆÏÒÍÁÃÉÀ. íÙ ÎÁÚÏ×ÅÍ ÜÔÕ ÔÁÂÌÉÃÕ Customer. ï ÎÅÊ ÐÏÇÏ×ÏÒÉÍ ÎÅÍÎÏÇÏ ÐÏÚÖÅ. ôÁËÖÅ ÏÂÒÁÔÉÔÅ ×ÎÉÍÁÎÉÅ, ÞÔÏ ÍÙ ÎÅ ÉÍÅÅÍ ÎÉËÁËÏÇÏ ÕÐÏÍÉÎÁÎÉÑ Ï widgets × ÜÔÏÊ ÔÁÂÌÉÃÅ. üÔÏ ÐÏÔÏÍÕ, ÞÔÏ ÐÏÒÑÄÏË ÐÒÉÏÂÒÅÔÅÎÉÑ ÍÏÖÅÔ ÂÙÔØ ÒÁÚÎÙÍ. íÙ ÍÏÇÌÉ ÂÙ ÔÏÌØËÏ ÏÐÒÅÄÅÌÉÔØ ÎÅËÏÔÏÒÏÅ ÆÉËÓÉÒÏ×ÁÎÎÏÅ ÞÉÓÌÏ ÓÐÏÓÏÂÏ× ÐÏËÕÐËÉ, ÎÏ ÜÔÏ ÎÅ ÂÕÄÅÔ ÏÞÅÎØ ÇÉÂËÏ. ÷ÚÁÍÅÎ ÜÔÏÇÏ ÍÙ ÏÐÒÅÄÅÌÑÅÍ ÐÏÌÅ, ÎÁÚ×ÁÎÎÏÅ purchase_order, ËÏÔÏÒÏÅ ÂÕÄÅÔ ÓÏÄÅÒÖÁÔØ ÕÎÉËÁÌØÎÙÊ ÎÏÍÅÒ ÄÌÑ ËÁÖÄÏÇÏ ÓÐÏÓÏÂÁ ÐÒÉÏÂÒÅÔÅÎÉÑ. úÁÔÅÍ ÍÙ ÏÐÒÅÄÅÌÑÅÍ ÄÒÕÇÕÀ ÔÁÂÌÉÃÕ, ËÏÔÏÒÁÑ ÂÕÄÅÔ ÓÏÄÅÒÖÁÔØ ÏÄÉÎ ×ÈÏÄ ÄÌÑ ËÁÖÄÏÇÏ ÚÎÁÞÅÎÉÑ ÐÏÒÑÄËÁ ÐÏËÕÐËÉ.

åÝÅ ÏÄÎÏ ÉÎÔÅÒÅÓÎÏÅ ÐÏÌÅ last_action_date. üÔÏ ÐÏÌÅ ÉÍÅÅÔ ÔÉÐ TIMESTAMP. ðÏÌÑ ÜÔÏÇÏ ÔÉÐÁ Á×ÔÏÍÁÔÉÞÅÓËÉ ÍÏÄÉÆÉÃÉÒÕÀÔÓÑ ×ÓÑËÉÊ ÒÁÚ, ËÏÇÄÁ ÎÁ ÎÉÈ ×ÙÐÏÌÎÑÅÔÓÑ ËÏÍÁÎÄÁ INSERT ÉÌÉ UPDATE. üÔÏ ÐÏËÁÚÙ×ÁÅÔ, ËÏÇÄÁ ÚÁÐÉÓØ ÂÙÌÁ × ÐÏÓÌÅÄÎÉÊ ÒÁÚ ÉÚÍÅÎÅÎÁ.

ôÁÂÌÉÃÁ ÄÌÑ Purchase_Order_Item:

# The Purchase_Order_Item table.
#
# Since there can be more than one item on a purchase order
# we need a table that contains a single item.  We link back to
# The main Purchase_Order table by use of the purchase_order field.
#
# We can also link back to the Widget_Table table by use of the
# widget_id field.
#
# Last of all we link to the Status table by way of the status_code field.
CREATE TABLE Purchase_Order_Item (
  purchase_order SMALLINT NOT NULL,
  order_sequence SMALLINT NOT NULL,
  widget_id MEDIUMINT(8) NOT NULL,
  quantity SMALLINT(4) UNSIGNED NOT NULL,
  status_code TINYINT(2) UNSIGNED NOT NULL,
  order_date DATE NOT NULL,
  item_due_date DATE NOT NULL,
  deliver_date DATE NOT NULL,
  last_action_date TIMESTAMP,
  PRIMARY KEY (purchase_order,order_sequence),
  KEY (widget_id),
  KEY (status_code,order_date)
);

÷ ÔÁÂÌÉÃÅ Purchase_Order_Item ÈÒÁÎÉÔÓÑ ÉÎÆÏÒÍÁÃÉÑ Ï ×ÓÅÈ ÜÌÅÍÅÎÔÁÈ ÐÏÌÑ ÓÐÏÓÏÂÁ ÐÏËÕÐËÉ. úÄÅÓØ ÈÒÁÎÉÔÓÑ ÉÎÆÏÒÍÁÃÉÑ Ï ÔÏÍ ËÔÏ, ËÏÇÄÁ, ÞÔÏ É ÓËÏÌØËÏ ÚÁËÁÚÙ×ÁÌ.

ôÁÂÌÉÃÁ Customer:

# The Customer table.
#
# We need to know where to send those widgets.
#
# Links back to Purchase_Order by way of customer_id.
CREATE TABLE Customer (
  customer_id SMALLINT NOT NULL AUTO_INCREMENT,
  customer_name VARCHAR(80) NOT NULL,
  customer_contact VARCHAR(80) NOT NULL,
  customer_address VARCHAR(80),
  customer_city VARCHAR(80),
  customer_zip VARCHAR(10),
  customer_phone VARCHAR(20),
  customer_fax VARCHAR(20),
  PRIMARY KEY (customer_id),
  KEY (customer_name)
);

üÔÏ É ÓÏ×ÓÅÍ ÐÒÏÓÔÏ. úÄÅÓØ ÈÒÁÎÉÔÓÑ ÉÎÆÏÒÍÁÃÉÑ Ï ËÁÖÄÏÍ ÚÁËÁÚÞÉËÅ: ÅÇÏ ÉÍÑ, Ó ËÅÍ Ó×ÑÚÁÔØÓÑ × ÓÌÕÞÁÅ ÐÒÏÂÌÅÍ, ÁÄÒÅÓ, ÔÅÌÅÆÏÎ É ÆÁËÓ.

ôÅÐÅÒØ ÄÁ×ÁÊÔÅ ÐÏÄÕÍÁÅÍ. óÒÅÄÉ ÚÁËÁÚÞÉËÏ× ÎÁ×ÅÒÎÑËÁ ÎÁÊÄÕÔÓÑ Ó×ÏÂÏÄÎÙÅ ÔÏÒÇÏ×ÃÙ, ËÏÔÏÒÙÅ ÒÁÄÙ ÐÒÏÄÁ×ÁÔØ ÷ÁÛ ÔÏ×ÁÒ ÐÏ Ó×ÏÉÍ ÃÅÎÁÍ. îÅÐÌÏÈÏ ÂÙ ÉÈ ÐÒÉ×ÌÅÞØ Ë ÓÅÂÅ, ÎÁÐÒÉÍÅÒ, ÎÅÂÏÌØÛÏÊ ÓËÉÄÏÞËÏÊ. îÏ ÄÌÑ ÜÔÏÇÏ ÎÁÄÏ ÈÏÔÑ ÂÙ ÐÒÉÍÅÒÎÏ ÐÒÅÄÓÔÁ×ÌÑÔØ, ËÔÏ ËÕÐÉÌ ÔÏ×ÁÒ ÄÌÑ ÓÅÂÑ, Á ËÔÏ ÎÁ ÐÒÏÄÁÖÕ. ïÔÌÉÞÎÏ, ÎÁËÒÏÅÍ ÉÈ ËÏÌÐÁËÏÍ.

# The Sales_droid table.
#
# Keep track of the people who sell the widgets.
#
CREATE TABLE Sales_Droid (
  sales_droid_id SMALLINT NOT NULL AUTO_INCREMENT,
  sales_droid_first_name VARCHAR(80) NOT NULL,
  sales_droid_last_name VARCHAR(80) NOT NULL,
  sales_droid_phone VARCHAR(20) NOT NULL,
  PRIMARY KEY (sales_droid_id)
);

îÕÖÎÙ ÅÝÅ ÔÒÉ ÐÒÏÓÔÙÅ ÔÁÂÌÉÃÙ ÄÌÑ ÓÌÕÖÅÂÎÏÊ ÉÎÆÏÒÍÁÃÉÉ:

# The Status table.
#
# Table to contain all valid status codes.
#
# Links to to Purchase_Order_Item and Purchase_Item by way of status_code.
CREATE TABLE Status (
  status_code TINYINT NOT NULL AUTO_INCREMENT,
  status_text VARCHAR(80) NOT NULL,
  PRIMARY KEY(status_code)
);

ôÁÂÌÉÃÁ Status ÏÞÅÎØ ÐÒÏÓÔÁÑ. îÁÍ ÎÕÖÅÎ ÕÎÉËÁÌØÎÙÊ ÞÉÓÌÏ×ÏÊ ID, ËÏÔÏÒÙÊ Ó×ÑÚÁÎ Ó ËÏÒÏÔËÉÍ ÔÅËÓÔÏ×ÙÍ ÐÏÌÅÍ, ËÏÔÏÒÏÅ ÓÏÄÅÒÖÉÔ ÔÅËÓÔ ËÏÄÁ ÓÏÓÔÏÑÎÉÑ.

# The Widget_Color table.
#
# Table to contain all valid color codes.
CREATE TABLE Widget_Color (
  widget_color_id TINYINT NOT NULL AUTO_INCREMENT,
  color_text VARCHAR(80) NOT NULL,
  PRIMARY KEY(widget_color_id)
);

# The Widget_Size table.
#
# Table to contain all valid color codes.
CREATE TABLE Widget_Size (
  widget_size_id TINYINT NOT NULL AUTO_INCREMENT,
  size_text VARCHAR(80) NOT NULL,
  PRIMARY KEY(widget_size_id)
);

ôÁÂÌÉÃÙ Widget_Color É Widget_Size ÐÏÞÔÉ ÉÄÅÎÔÉÞÅÎ ÔÁÂÌÉÃÅ Status. ôÏÌØËÏ ÉÍÅÎÁ ÉÚÍÅÎÅÎÙ.

÷ÓÅ! íÏÖÎÏ ××ÏÄÉÔØ ÄÁÎÎÙÅ.

÷ ÚÁËÌÀÞÅÎÉÅ ÈÏÞÅÔÓÑ ÐÏÐÒÏÓÉÔØ ÷ÁÓ, ÅÓÌÉ ÷ÁÍ ÐÏÎÒÁ×ÉÌÁÓØ ÜÔÁ ÓÔÒÁÎÉÞËÁ ÉÌÉ ÐÒÉÇÏÄÉÌÁÓØ ÉÚÌÏÖÅÎÎÁÑ ÚÄÅÓØ ÉÎÆÏÒÍÁÃÉÑ, ÐÏÓÌÁÔØ ÂÌÁÇÏÄÁÒÎÏÓÔØ Á×ÔÏÒÕ. üÔÏ ÐÏÍÏÖÅÔ ÍÎÅ ×ÅÓÔÉ ÓÔÁÔÉÓÔÉËÕ ÔÏÇÏ, ÓËÏÌØËÉÍ ÌÀÄÑÍ ÐÒÉÇÏÄÉÌÏÓØ ÈÏÔØ ÞÔÏ-ÔÏ ÉÚ ÍÏÉÈ ÔÒÕÄÏ×.

îÁ ÇÌÁ×ÎÕÀ ÓÔÒÁÎÉÞËÕ.


ðÁÒÔΣÒÙ:
PostgresPro
Inferno Solutions
Hosting by Hoster.ru
èÏÓÔÉÎÇ:

úÁËÌÁÄËÉ ÎÁ ÓÁÊÔÅ
ðÒÏÓÌÅÄÉÔØ ÚÁ ÓÔÒÁÎÉÃÅÊ
Created 1996-2024 by Maxim Chirkov
äÏÂÁ×ÉÔØ, ðÏÄÄÅÒÖÁÔØ, ÷ÅÂÍÁÓÔÅÒÕ