How to design SQL database Schema

Steps:

  1. Write down all the possible tables
  2. Identify which is child and which is parent
    (Note: Child cannot exist without parent, example: user comments in facebook cannot exist without user, so comments is child and user is parent)
  3. Add Foreign Keys to child tables
    (Note: Always Child will have the Foreign Key)
  4. Identify one to one relationships
    (Note: user and passport details is one to one relationship, if both primary keys are mapped (FK) then the relation becomes one to one)

Tips:

  • Tables with surrogate keys should never be Parent.
  • Go through Oracle schemas and think over the design
  • Question yourself after you did the design
    (Note: If parent deletes child also deletes)
Advertisements
How to design SQL database Schema

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s