0% found this document useful (0 votes)
97 views8 pages

RDBMS Naming Conventions Guide

The document outlines naming conventions for RDBMS, emphasizing consistency, the use of lowercase and underscores for multi-word names, and the preference for singular table names. It also discusses ER design issues, including the choice between entity sets and attributes, relationships, and the placement of relationship attributes. Additionally, it highlights common non-technical and technical database design errors, such as poor planning and normalization issues.

Uploaded by

anujwagle31
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
97 views8 pages

RDBMS Naming Conventions Guide

The document outlines naming conventions for RDBMS, emphasizing consistency, the use of lowercase and underscores for multi-word names, and the preference for singular table names. It also discusses ER design issues, including the choice between entity sets and attributes, relationships, and the placement of relationship attributes. Additionally, it highlights common non-technical and technical database design errors, such as poor planning and normalization issues.

Uploaded by

anujwagle31
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

RDBMS Naming Convention

The following convention should be followed for naming RDBMS:


Consistency is the best approach.
• Use lowercase names. e.g. user, username
• If the name of the table or column must consist of more than one word,
use an underscore(_) to connect them(i.e. snake_case). e.g. user_account
• Use UPPERCASE for SQL keywords (e.g. SELECT, INSERT) and built-
in functions (e.g. LOWER(), COUNT()).
• Avoid use of dots, spaces, or dashes in database, schema, table, or column
names.
• When naming objects, balance the objective of keeping names short and
easy to use with the objective of making names as descriptive as possible.
When in doubt, choose the more descriptive name, because the objects in
the database may be used by many people over a period of time. For
example use payment_due_date instead of pmdd.
Database

Example dvd_rental.
Table

When naming tables, you have two options – either to use the singular
name (e.g. user) or to use a plural name (e.g. users). Singular table name
is preferred.
View

Prefix views with vw_ to make them obvious.


Constraints

Two popular way of naming a constraints uses either abbreviation or the


short name of the constraint type. It's a user preference to use one or the
other but make sure they are used consistently everywhere.
Constraints Abbreviation Short Name
Primary Key pk primary
Foreign Key fk foreign
Unique uc unique
Check chk check

When naming a constraint use the following template


(replace <key_type> using the above table) as reference:

DBMS – ER Design Issues


Here are some of the issues that can occur while ER diagram design
process:
1. Choosing Entity Set vs Attributes

• How choosing an entity set vs an attribute can change the whole ER


design semantics.

• To understand this lets take an example, let’s say we have an entity set
Student with attributes such as student-name and student-id. Now we can
say that the student-id itself can be an entity with the attributes like
student-class and student-section.

• Now if we compare the two cases we discussed above, in the first case we
can say that the student can have only one student id, however in the
second case when we chose student id as an entity it implied that a student
can have more than one student id.

2. Choosing Entity Set vs. Relationship Sets

• It is hard to decide that an object can be best represented by an entity set


or relationship set.

• To comprehend and decide the perfect choice between these two (entity vs
relationship), the user needs to understand whether the entity would need a
new relationship if a requirement arise in future, if this is the case then it is
better to choose entity set rather than relationship set.

• Let’s take an example to understand it better: A person takes a loan from a


bank, here we have two entities person and bank and their relationship is
loan.

• This is fine until there is a need to disburse a joint loan, in such case a new
relationship needs to be created to define the relationship between the two
individuals who have taken joint loan. In this scenario, it is better to
choose loan as an entity set rather than a relationship set.

3. Choosing Binary vs n-ary Relationship Sets

• In most cases, the relationships described in an ER diagrams are binary.


• The n-ary relationships are those where entity sets are more than two, if
the entity sets are only two, their relationship can be termed as binary
relationship.

• The n-ary relationships can make ER design complex, however the good
news is that we can convert and represent any n-ary relationship using
multiple binary relationships.

• This may sound confusing so let's take an example to understand how we


can convert an n-ary relationship to multiple binary relationships. Now
lets say we have to describe a relationship between four family members:
father, mother, son and daughter. This can easily be represented in forms
of multiple binary relationships, father-mother relationship as “spouse”,
son and daughter relationship as “siblings” and father and mother
relationship with their child as “child”.

4. Placing Relationship Attributes

• The cardinality ratio in DBMS can help us determine in which scenarios


we need to place relationship attributes.

• It is recommended to represent the attributes of one to one or one to


many relationship sets with any participating entity sets rather than a
relationship set.

• For example, if an entity cannot be determined as a separate entity rather


it is represented by the combination of participating entity sets. In such
case it is better to associate these entities to many-to-many relationship
sets.
ER Design Issues
• We learned to design an ER diagram.

• We also discussed different ways of defining entity sets and relationships


among them.

• We also understood the various designing shapes that represent a


relationship, an entity, and its attributes.

• However, users often mislead the concept of the elements and the design
process of the ER diagram.

• Thus, it leads to a complex structure of the ER diagram and certain issues


that does not meet the characteristics of the real-world enterprise model.

Here, we will discuss the basic design issues of an ER database schema in


the following points:

1) Use of Entity Set vs Attributes

• The use of an entity set or attribute depends on the structure of the real-
world enterprise that is being modelled and the semantics associated with
its attributes.
• It leads to a mistake when the user uses the primary key of an entity set as
an attribute of another entity set. Instead, s/he should use the relationship to
do so.
• Also, the primary key attributes are implicit in the relationship set, but we
designate it in the relationship sets.
2) Use of Entity Set vs. Relationship Sets

• It is difficult to examine if an object can be best expressed by an entity set


or relationship set.
• To understand and determine the right use, the user need to designate a
relationship set for describing an action that occurs in-between the entities.
• If there is a requirement of representing the object as a relationship set, then
it is better not to mix it with the entity set.
3) Use of Binary vs N-ary Relationship Sets

• Generally, the relationships described in the databases are binary


relationships.
• However, non-binary relationships can be represented by several binary
relationships.
• For example, we can create and represent a ternary relationship 'parent' that
may relate to a child, his father, as well as his mother. Such relationship can
also be represented by two binary relationships i.e, mother and father, that
may relate to their child. Thus, it is possible to represent a non-binary
relationship by a set of distinct binary relationships.
4) Placing Relationship Attributes
• The cardinality ratios can become an effective measure in the placement of
the relationship attributes.
• So, it is better to associate the attributes of one-to-one or one-to-many
relationship sets with any participating entity sets, instead of any
relationship set.
• The decision of placing the specified attribute as a relationship or entity
attribute should possess the characteristics of the real-world enterprise that
is being modelled.
• For example, if there is an entity which can be determined by the
combination of participating entity sets, instead of determining it as a
separate entity, such type of attribute must be associated with the many-to-
many relationship sets.
❖ Thus, it requires the overall knowledge of each part that is involved in
designing and modelling an ER diagram.
❖ The basic requirement is to analyze the real-world enterprise and the
connectivity of one entity or attribute with other.

Database Design Issues

Non-Technical Database Design Errors

• Poor Planning
• Insufficient Communication with Clients and Developers
• Poor or Missing Documentation

Technical Database Design Mistakes

• Not Using a Naming Convention


• Normalization Issues
• Insufficient Indexing
• Improper use of Primary Key
• Redundant Data

Common questions

Powered by AI

Evaluating whether an object should be an entity set or a relationship set in an ER diagram is crucial because the choice impacts the flexibility and scalability of the database model. If a requirement arises in the future that necessitates a new relationship, defining the object as an entity set allows for easier elaboration and addition of related attributes or entities. For example, a 'loan' initially described as a relationship set between 'person' and 'bank' would become rigid if a joint loan requirement emerges. Redefining 'loan' as an entity set accommodates such changes seamlessly by allowing relationships between the individuals and the entity 'loan' .

Consistent naming conventions in RDBMS enhance the maintainability and readability of the database schema, making it easier for developers to understand and work with the database over time. By choosing descriptive names over shorter ones, developers can improve clarity, aiding users in quickly understanding the role and purpose of each table or column, especially when various users access the database over extended periods. Descriptive names like 'payment_due_date' are advantageous as they inherently convey meaning, reducing the cognitive load and potential errors associated with interpreting ambiguous abbreviations such as 'pmdd' .

Cardinality ratios help determine where to place relationship attributes by indicating the nature and extent of linkages between entities. For one-to-one or one-to-many relationships, it’s advisable to associate attributes with participating entity sets rather than relationship sets to maintain clear associations and simplify designs. By linking attributes directly to entities in these cases, we ensure that the structure of the real-world enterprise is accurately represented. Conversely, attributes in many-to-many relationships should be placed within the relationship set itself, allowing for proper handling and querying of complex data combinations .

Improperly using a primary key of an entity set as an attribute in another entity set can lead to incorrect representations of real-world relationships in an ER diagram, leading to inefficiencies and potential data anomalies. This practice could inadvertently imply additional semantics not intended by the design. These should ideally be represented as relationships rather than attributes, where the primary key inherently acts as a unique identifier linking two entity sets. Such an approach ensures that the design models real-world enterprise characteristics accurately and maintains the integrity and normalization of the database .

The choice between using entity sets or attributes determines how primary keys are represented, crucially impacting database normalization. If a primary key is mistakenly used as an attribute in another set rather than establishing a clear relationship, it could lead to a design prone to redundancy and update anomalies. Proper normalization requires separating concerns where entity sets are linked by their unique primary keys through defined relationships. This maintains data integrity and eliminates redundancy, ensuring that each piece of data is stored only once and without ambiguity in an optimally structured environment .

Not using proper indexing can result in inefficient querying performance, lengthy response times, and increased load during data retrieval processes. Indexing errors may lead to slow database operations, adversely affecting user experience and system effectiveness. Naming conventions contribute to mitigating these errors by providing clarity and consistency, making it easier to implement and maintain indexes. With standardized naming, developers can quickly and accurately apply indexes to appropriate columns, ensuring the database operates optimally without redundant or overlooked indexes .

Recognizing the distinctions between entity sets and relationship sets enhances the design of complex enterprise ER diagrams by enabling precise modeling of real-world interactions and dependencies. By accurately distinguishing these two, designers can effectively represent complex structures and relationships, ensuring that entities and their interactions coincide with real-world processes. This discernment prevents design errors and facilitates future changes or expansions, as it allows the model to adapt without substantial redesign, maintaining a robust and scalable database architecture aligned with organizational processes .

Choosing between singular and plural naming for tables impacts the perception and use of entities within the database. Singular naming, such as 'user' instead of 'users', is often preferred for its consistency, aligning with object-oriented naming conventions where each instance represents a single entity. This approach can enhance database design consistency by providing uniformity, reducing confusion, and aligning tables conceptually with well-established naming practices within programming environments. Singular naming clarifies that each record represents one instance, promoting clarity and straightforward translations into application code .

Poor or missing documentation can lead to misunderstandings, inefficiencies, and errors during database development and maintenance. Such documentation gaps complicate understanding the database's original intent and structure, hindering modifications and scaling. Consistent naming conventions alleviate these issues by providing self-documenting clarity, with more descriptive and systematically named tables and columns serving as a form of implicit documentation. This clarity aids developers and maintainers in comprehending the database structure and facilitates accurate communication between teams .

Choosing between binary and n-ary relationship sets significantly affects an ER diagram's complexity. Binary relationships, involving only two entity sets, tend to be simpler and clearer. In contrast, n-ary relationships, which involve more than two entities, complicate the model. However, n-ary relationships can be decomposed into multiple binary relationships to simplify the design. For instance, a relationship among family members (father, mother, son, daughter) can be broken into binaries: father-mother ('spouse'), child-parent ('child'), and siblings ('siblings'), which makes the diagram easier to understand and manage .

You might also like