0
Create Table Customer(
CustomerID Int NOT NULL IDENTITY (1,1) , 
LastName Char(25) NOT NULL,
FirstName Char(25) NOT NULL,
EmailAddress VarChar(100) NOT NULL,
EncryptedPassword VarChar(50) NULL,
Phone Char(12) NOT NULL,
StreetAddress Char(35) NULL
City Char(35) NULL DEFAULT 'Dallas', 
[State] Char(2) NULL DEFAULT 'TX', 
ZIP Char(10) NULL DEFAULT '75201',
CONSTRAINT CUSTOMER_PK PRIMARY KEY(CUSTOMERID),
CONSTRAINT CUSTOMER_EMAIL UNIQUE(EMAILADDRESS)
) ;

CREATE TABLE SEMINAR(
SeminarID INT NOT NULL IDENTITY (1, 1), 
SeminarDate Date NOT NULL,
SeminarTime Time NOT NULL,
Location VarChar(100) NOT NULL,
SeminarTitle VarChar(100)
CONSTRAINT SEMINAR_PK PRIMARY KEY(SeminarID)
) ;

Create Table SEMINAR_CUSTOMER(
SeminarID Int NOT NULL,
CustomerID Int NOT NULL,
CONSTRAINT S_C_PK PRIMARY KEY(SeminarID, CustomerID), 
CONSTRAINT S_C_SEMINAR_FK FOREIGN KEY(SeminarID)
              REFERENCES SEMINAR(SeminarID)
                 ON UPDATE NO ACTION
                 ON DELETE NO ACTION
CONSTRAINT S_C_CUSTOMER_FK FOREIGN KEY (CustomerID)
              REFERENCES CUSTOMER(CustomerID)
                 ON UPDATE NO ACTION
                 ON DELETE NO ACTION
) ;   
CREATE TABLE CONTACT(
CustomerID Int NOT NULL,
ContactNumber Int NOT NULL,
ContactDate Date NOT NULL,
ContactType VarChar(30) NOT NULL,
SeminarID Int NULL,
CONSTRAINT CONTACT_PK PRIMARY KEY(CustomerID, ContactNumber),
CONSTRAINT CONTACT_ContactType
              CHECK (ContactType IN ('Seminar',
                     'WebAccountCreation', 'WebPurchase',
                     'EmailAccountMessage', 'EmailSeminarMessage',
                     'EmailPurcahseMessage',
                     'EmailMessageExchange', 'FormLetterSeminar',
                     'PhoneConversation')),
CONSTRAINT CONTACT_SEMINAR_FK FOREIGN KEY(SeminarID)
              REFERENCES SEMINAR(SeminarID)
                 ON UPDATE NO ACTION
                 ON DELETE NO ACTION,
CONSTRAINT CONTACT_SEMINAR_FK FOREIGN KEY(SeminarID)
              REFERENCES SEMINAR(CustomerID)
                 ON UPDATE NO ACTION
                 ON DELETE NO ACTION
);

CREATE TABLE PRODUCT(
ProductNumber Char(35) NOT NULL,
ProductType Char(24) NOT NULL,
ProductDescription VarChar(100) NOT NULL,
UnitPrice Numeric(9,2) NOT NULL
QuantityOnHand Int NULL
CONSTRAINT PRODUCT_PK PRIMARY KEY(ProductNumber),
CONSTRAINT PRODUCT_ProductType
              CHECK (ProductType) IN ('Video', 
                    'Video Companion', 'Book'))
);
CREATE TABLE INVOICE(
InvoiceNumber Int NOT NULL IDENTITY  (35000, 1),
  InvoiceDate Date NOT NULL,
  CustomerID Int NOT NULL,
  PaymentType Char(25) NOT NULL DEFAULT 'Cash',
  SubTotal Numeric(9,2) NULL,
  Shipping Numeric(9,2) NULL,
  Tax Numeric(9,2) NULL,
  Total Numeric(9,2) NULL,
  CONSTRAINT INVOICE_PK PRIMARY KEY (InvoiceNumber),
  CONSTRAINT INVOICE_PaymentType
                CHECK (PaymentType IN ('VISA',
                       'MasterCard', 'American Express',
                       'PayPal', 'Check', 'Cash')),
  CONSTRAINT INVOICE_CUSTOMER_FK FOREIGN KEY(CustomerID)
                REFERENCES CUSTOMER(CustomerID)
                   ON UPDATE NO ACTION
                   ON DELETE NO ACTION
);

CREATE TABLE LINE_ITEM(
      InvoiceNumber Int NOT NULL,
      LineNumber Int NOT NULL,
      ProductNumber Char(35) NOT NULL,
      Quantity Int NOT NULL
      UnitPrice Numeric(9,2) NULL
      Total Numeric(9,2) NULL
      CONSTRAINT LINE_ITEM_PK PRIMARY KEY (InvoiceNumber, LineNumber),
      CONSTRAINT L_I_INVOICE_FK FOREIGN KEY (InvoiceNumber)
                    REFERENCES INVOICE(InvoiceNumber)
                       ON UPDATE NO ACTION
                       ON DELETE NO ACTION
      CONSTRAINT L_I_PRODUCT_FK FOREIGN KEY (ProductNumber)
                    REFERENCES Product (ProductNumber)
                       ON UPDATE NO ACTION
                       ON DELETE NO ACTION
);

There is my entire code. Copied directly from the book for a class. My professor will not help me, so I am hoping here would be kind enough to help. I have done nothing but work on this the last 3 days. This is the error message I keep getting for all the 'IDENTITY':

IDENTITY is not valid input at this position, expecting: ')'

Please help, I need this today.

Lelio Faieta
  • 6,457
  • 7
  • 40
  • 74
  • Not MySQL syntax. Try googling mysql select and look at the proper syntax – Sloan Thrasher May 23 '18 at 15:21
  • This looks more like Transact-SQL (Microsoft SQL Server) than MySQL. And the error message doesn't look like a MySQL error message... we'd expect error `1064 You have an error in your SQL syntax; ...` – spencer7593 May 23 '18 at 15:21
  • After [doing more research](https://meta.stackoverflow.com/q/261592/1011527) if you have a problem **post what you've tried** with a **clear explanation of what isn't working** and provide [a Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve). Read [How to Ask a good question](http://stackoverflow.com/help/how-to-ask). Be sure to [take the tour](http://stackoverflow.com/tour) and read [this](https://meta.stackoverflow.com/q/347937/1011527). – Sloan Thrasher May 23 '18 at 15:22
  • Make sure all your parentheses are opened/closed in the proper locations... – vielkind May 23 '18 at 15:28
  • it took me exactly 30 seconds to google for "mysql IDENTITY", find [this answer](https://stackoverflow.com/questions/10283780/equivalent-of-mssql-identity-column-in-mysql) and post this comment – Lelio Faieta May 23 '18 at 15:28
  • @LelioFaieta: but the error message reported by OP does not appear to be a MySQL error message. – spencer7593 May 23 '18 at 15:45
  • I agree but the user tagged the question as mysql... – Lelio Faieta May 23 '18 at 15:47

0 Answers0