database design SQL prob.

Поиск
Список
Период
Сортировка
Искать

database design SQL prob.

От:
Frederic.De.Leersnijder@pandora.be
Дата:
The idea of the table below is to keep track of members. They have to register themself so I want to prevent them from subscribing twice. That's why I used a primary key on the fields firstname, lastname, adres, zipcode. But I would really want member_id to be my primary key as the table is referenced by other tables. Can I make firstname, lastname... a unique value in another way?
Like constraint UNIQUE (firstname, lastname,adres,zipcode)
I just made that last one up but is it possible to enforce the uniqueness of a couple of fields together?

CREATE TABLE "member" (
	"member_id" int4 DEFAULT nextval ( 'lid_id_seq' ) UNIQUE NOT NULL,
	"firstname" text,
	"lastnaam" text,
	"adress" text,
	"zipcoder" character(4),
	"telephone" text,
	"email" text,
	"registration_date" date DEFAULT current_date NOT NULL,
	"student_id" text,
	"dep_id" text,
	"password" text NOT NULL,
	"validated" bool DEFAULT 'f' NOT NULL,
	PRIMARY KEY (firstname, lastname, adres, zipcode));
FAQ