Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

CELKO vs. TOTH in SS T-SQL Table Design

$
0
0

The designs, based on minimal & incomplete information, are from the following thread:

http://social.msdn.microsoft.com/Forums/en-US/bbc229aa-f763-4c7d-9d83-d6c6f17303f2/i-have-created-a-database-what-is-data-structure-and-relationship?forum=transactsql

While Joe is a top-notch world-class database designer, I see issues with his SS database design approach. But for the time being, I keep my opinion to myself.

What is your opinion?  Thanks.

TOTH

CREATE TABLE Employee (EmployeeID INT IDENTITY(1,1) PRIMARY KEY,
SSNO CHAR(9) not null UNIQUE,
FirstName varchar(40) NOT NULL,
LastName varchar(40) NOT NULL,
Email varchar(70) NOT NULL,
ModifiedDate datetime2 default ( sysdatetime()));

CREATE TABLE Project (ProjectID INT IDENTITY(1,1) PRIMARY KEY,
Title nvarchar(255) not null UNIQUE,
ModifiedDate datetime2 default ( sysdatetime()));

CREATE TABLE Customer (CustomerID INT IDENTITY(1,1) PRIMARY KEY,
FederalTaxID CHAR(9) NOT NULL UNIQUE,
Company nvarchar(255) NOT NULL,
ContactFirstName nvarchar(40) NOT NULL,
ContactLastName nvarchar(40) NOT NULL,
Email varchar(70) NOT NULL,
ModifiedDate datetime2 default ( sysdatetime()));

CREATE TABLE Sales (SalesID INT IDENTITY(1,1) PRIMARY KEY,
CustomerID INT NOT NULL REFERENCES Customer,
SalesStaffID INT NOT NULL REFERENCES Employee,
ProjectID INT NOT NULL REFERENCES Project,
OrderDate date NOT NULL,
Descr varchar(512)  NOT NULL,
Amount money  NOT NULL,
ModifiedDate datetime2 default ( sysdatetime()));
GO

CELKO

CREATE TABLE Personnel --- collective name
 (ssn CHAR(9) NOT NULL PRIMARY KEY,
  first_name VARCHAR(20) NOT NULL,
  last_name VARCHAR(20) NOT NULL,
  emp_email_address VARCHAR(245) NOT NULL);

 CREATE TABLE Projects --- talk to accounting for project nbr
 (project_nbr CHAR(15) NOT NULL PRIMARY KEY,
  project_title NVARCHAR(255) NOT NULL);

 -- You assume a customer is a company, so: 
 CREATE TABLE Customers --- use the DUNS or tax id
 (customer_duns CHAR(9) NOT NULL PRIMARY KEY,
  company_name NVARCHAR(35) NOT NULL,
  company_email_address VARCHAR(245) NOT NULL);

 CREATE TABLE Sales 
 (customer_duns CHAR(9) NOT NULL REFERENCES Customers (customer_duns),
  saleman_ssn CHAR(9) NOT NULL REFERENCES Personnel(ssn),
  project_nbr CHAR(15) NOT NULL REFERENCES Projects,
  sale_date DATE NOT NULL,
  PRIMARY KEY (customer_duns, saleman_ssn, project_nbr, sale_date),
  sale_amt DECIMAL(12,2) NOT NULL
   CHECK (sales_amt >= 0.00));


Kalman Toth Database & OLAP Architect SELECT Video Tutorials 4 Hours
New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012




Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>