RDB Creation Guidelines

  • Underscores are used to indicate something about the data, rather than being used to name the data
  • Tables names are singular, with the suffix _tbl
  • Sequences are named from tables, with _tbl suffix replaced with _seq
  • All tables have a field named id – BIGINT
  • Foreign key fields are named [referencedtablename]id
  • Foreign key fields should be listed immediately under the id field

example for postgresql,

CREATE SEQUENCE test_seq;
CREATE TABLE test_tbl (
id BIGINT NOT NULL,
farm_id BIGINT NOT NULL,
label VARCHAR(50),
PRIMARY KEY ( id ),
FOREIGN KEY ( farm_id ) REFERENCES farm_tbl ( id ) );

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s