hi all

From: Kusuma Pabba <kusumap(at)ncoretech(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: hi all
Date: 2009-02-17 12:54:02
Message-ID: 499AB36A.3050401@ncoretech.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

when creating tables,

in my sql i have used create table
CREATE TABLE `users` (
`user_id` int(11) NOT NULL auto_increment,
`user_name` varchar(50) NOT NULL,
`first_name` varchar(50) default NULL,
`middle_name` varchar(50) default NULL,
`last_name` varchar(50) default NULL,
`password` varchar(50) default NULL,
`salt` varchar(50) default NULL,
`secret_question` varchar(255) default NULL,
`secret_answer` varchar(255) default NULL,
`creator` int(11) default NULL,
`date_created` datetime NOT NULL default '0000-00-00 00:00:00',
`changed_by` int(11) default NULL,
`date_changed` datetime default NULL,
`voided` tinyint(1) NOT NULL default '0',
`voided_by` int(11) default NULL,
`date_voided` datetime default NULL,
`void_reason` varchar(255) default NULL,
PRIMARY KEY (`user_id`),
KEY `users_user_creator` (`creator`),
KEY `users_user_who_changed_user` (`changed_by`),
KEY `users_user_who_voided_user` (`voided_by`),
CONSTRAINT `users_user_creator` FOREIGN KEY (`creator`) REFERENCES
`users` (`user_id`),
CONSTRAINT `users_user_who_changed_user` FOREIGN KEY (`changed_by`)
REFERENCES `users` (`user_id`),
CONSTRAINT `users_user_who_voided_user` FOREIGN KEY (`voided_by`)
REFERENCES `users` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

while in pgsql i am thinking of to use the same as follows:

CREATE TABLE users (
user_id int(11) NOT NULL serial,
user_name varchar(50) NOT NULL,
first_name varchar(50) default NULL,
middle_name varchar(50) default NULL,
last_name varchar(50) default NULL,
password varchar(50) default NULL,
salt varchar(50) default NULL,
secret_question varchar(255) default NULL,
secret_answer varchar(255) default NULL,
creator int(11) default NULL,
date_created datetime NOT NULL default '0000-00-00 00:00:00',
changed_by int(11) default NULL,
date_changed datetime default NULL,
voided smallint(1) NOT NULL default '0',
voided_by int(11) default NULL,
date_voided datetime default NULL,
void_reason varchar(255) default NULL,
PRIMARY KEY (user_id),
KEY users_user_creator (creator),
KEY users_user_who_changed_user (changed_by),
KEY users_user_who_voided_user (voided_by),
CONSTRAINT users_user_creator FOREIGN KEY (creator) REFERENCES users
(user_id),
CONSTRAINT users_user_who_changed_user FOREIGN KEY (changed_by)
REFERENCES users (user_id),
CONSTRAINT users_user_who_voided_user FOREIGN KEY (voided_by)
REFERENCES users (user_id)
) ;

will that be valid to create a table like this
if no what all have to be replaced
thanks for any help

Regards
kusuma.p

Responses

  • Re: hi all at 2009-02-17 13:24:38 from Grzegorz Jaśkiewicz
  • Re: hi all at 2009-02-17 13:24:53 from Ashish Karalkar
  • Re: hi all at 2009-02-17 13:28:38 from Thomas Kellerer
  • Re: hi all at 2009-02-17 22:31:25 from Scott Marlowe
  • Re: hi all at 2009-02-18 05:18:19 from Craig Ringer

Browse pgsql-general by date

  From Date Subject
Next Message Grzegorz Jaśkiewicz 2009-02-17 13:24:38 Re: hi all
Previous Message Jerry Stuckle 2009-02-17 12:27:01 Re: Which SQL is the best for servers?