SQL Class project

  • I am trying to create a database for a lass project and not having much luck. Any help would be appreciate. I am having a bunch on syntax errors.

    Here is what I have so far--

    CREATE DATABASE Example

    CREATETABLE Product (

    ProductIDINTNOT NULL,

    Price MONEYNOT NULL,

    Author$EmailVARCHAR(100)NOT NULL,

    TypeCHAR(15)NOT NULL,

    FilePathVARCHAR(125)NOT NULL,

    DocPathVARCHAR(125)NOT NULL,

    RevDateDATETIMENULL,

    VerNumVARCHAR(25)NULL,

    RoyaltyMONEYNOT NULL,

    CONSTRAINTProduct_PKPRIMARY KEY (ProductID),

    CONSTRAINTAuthor_FKFOREIGN KEY(Author$Email)REFERENCES Author(Email)

    );

    CREATE TABLE Author (

    EmailVARCHAR(100)NOT NULL,

    FnameCHAR(20)NOT NULL,

    LnameCHAR(20)NOT NULL,

    AddressCHAR(30)NOT NULL,

    PhoneCHAR(12)NOT NULL,

    ZIPCHAR(5)NOT NULL,

    CityCHAR(20)NOT NULL,

    StateCHAR(2)NOT NULL,

    CONSTRAINTAUTHOR_PKPRIMARY KEY(EMAIL)

    );

    CREATE TABLE Customer (

    CustomerIDINTNOT NULL,

    EmailVARCHAR(100)NOT NULL,

    FnameCHAR(20)NOT NULL,

    LnameCHAR(20)NOT NULL,

    AddressCHAR(30)NOT NULL,

    PhoneCHAR(12)NOT NULL,

    ZIPCHAR(5)NOT NULL,

    CityCHAR(20)NOT NULL,

    StateCHAR(2)NOT NULL,

    CONSTRAINTCUSTOMER_PKPRIMARY KEY(CustomerID)

    );

    CREATE TABLE Orders (

    OrderIDINTNOT NULL,

    TotalMONEYNOT NULL,

    Customer$CustomerIDINTNOT NULL,

    PayMethodCHAR(6)NOT NULL,

    OrderDateDATETIMENOT NULL,

    CONSTRAINTOrder_PKPRIMARY KEY(OrderID),

    CONSTRAINTOrder_FKFOREIGN KEY(Customer$CustomerID)

    REFERENCES Customer(CustomerID)

    );

    CREATE TABLE LineItem (

    Order$OrderIDINTNOT NULL,

    Product$ProductIDINTNOT NULL,

    CONSTRAINTLineItem_PKPRIMARY KEY(Order$OrderID, Product$ProductID),

    CONSTRAINTLineItem_Order_FKFOREIGN KEY(Order$OrderID)

    REFERENCES Orders(OrderID),

    CONSTRAINTLineItem_Product_FKFOREIGN KEY(Product$ProductID)

    REFERENCES Product(ProductID)

    );

  • Well firstly you need to USE the newly created DB or your tables go elsewhere, likely master.

    CREATE DATABASE Example

    GO

    USE DATABASE Example

    GO

    CREATE TABLE Product (...

    As for the rest, post the syntax errors.

    We won't do your work for you, seeing as it's school work, but we'll give hints and suggestions.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply