Database Management Systems and SQL – Tutorial for Beginners

Bikash Daga (Jain)

Database Management Systems and SQL are two of the most important and widely used tools on the internet today.

You use a Database Management System (DBMS) to store the data you collect from various sources, and SQL to manipulate and access the particular data you want in an efficient way.

Many different businesses use these tools to increase their sales and improve their products. Other institutions like schools and hospitals also use them to improve their administrative services.

In this article, you will learn about:

  • The basics of DBMS and SQL
  • The most important features of DBMS and SQL
  • The reasons you should learn DBMS and SQL.

What Does a DBMS Do?

DBMS stands for Database Management System, as we mentioned above. SQL stands for Structured Query Language.

If you have lots of data that you need to store, you don't just want to keep it anywhere – then there would be no sense of what that huge amount of data means or can tell you. That's why we use a DBMS.

A database is basically where we store data that are related to one-another – that is, inter-related data. This inter-related data is easy to work with.

A DBMS is software that manages the database. Some of the commonly used DBMS (software) are MS ACCESS, MySQL, Oracle, and others.

Suppose you have some data like different names, grades, and ID numbers of students. You'd probably prefer to have that data in a nice table where a particular row consists of students’ names, grades, and ID numbers. And to help you organize and read that data efficiently, you'll want to use a DBMS.

Using a DBMS goes hand in hand with SQL. This is because when you store data and want to access and alter it, you'll use SQL.

A database stores data in various forms like schemas, views, tables, reports, and more.

Types of DBMS

There are two types of DBMS.

First, you have Relational Databases (RDBMS). In these types of databases, data is stored in the format of tables by the software. In an RDBMS, each row consists of data from a particular entity only.

Some of the RDBMS commonly used are MySQL, MSSQL, Oracle, and others.

Then you have Non-Relational Databases. In these databases, data is stored in the form of key and value pairs.

Some of the Non-Relational DBMSs commonly used are MongoDB, Amazon, Redis, and others.

Components of a DBMS

There are mainly four components of a DBMS which you can understand by checking out the image below:

Screen-Shot-2022-10-11-at-1.54.06-PM

You have your Users. There can be multiple users, like someone who manages the database (the database administrator), system developers, and also those who are just regular users like the customer.

You also have the Database Application. The application of a database can be either departmental or personal or may be for internal use in an organization.

Then you have the DBMS, which we've been discussing. This is software that helps the users create the database and access the data inside it in an efficient manner.

Finally, you have the Database, which is a collection of data stored in the form of a single unit.

One important feature of a DBMS is that it helps reduce the redundancy in the data stored. Having the same data stored at multiple locations in a database is called redundancy.

To eliminate and reduce the redundancy in the database, normalization is used.

Normalization is the process of structuring the data in an RDBMS by removing anomalies. It is important to enable easy retrieval of data from the database as well as to add or delete data without losing consistency. This might be implemented with the help of “Normal Forms” in DBMS. These normal forms help in establishing relations in a relational database instead of having to redefine existing fields again and again. In this way, normalization reduces redundancy.

What is SQL?

SQL is a database language. SQL is used widely and almost all Relational Database Management Systems can recognize it.

SQL contains a set of commands that enable you to create a database. You can also use it to execute commands in your Relational Database Management System.

SQL has certain advantages which have helped it thrive from the 1970s until now. It is widely accepted by both people and platforms, in part because of the following features:

  • SQL is fast
  • SQL is a very high-level language
  • SQL is a platform-independent language
  • SQL is a standardized language
  • SQL is a portable language

Along with all the features mentioned above, you need almost no coding skills to work with SQL.

SQL performs a variety of tasks like creating, altering, maintaining and retrieving data, setting properties, and so on. All the tasks are done based on the commands you write, and these commands are grouped into various categories like DDL commands, DML commands, DCL commands, and so on.

Let's discuss some of the frequently used commands and their types.

DDL commands

DDL stands for Data Definition Language. It includes the set of commands that you use to perform various tasks related to data definition. You use these commands to specify the structure of the storage and methods through which you can access the database system.

You use DDL commands to perform the following functions:

  • To create, drop, and alter.
  • To grant and revoke various roles and privileges.
  • Maintenance commands

Example DDL commands include CREATE , ALTER , DROP , and TRUNCATE .

DML commands

DML stands for Data Manipulation Language. As the name suggests, it consists of commands which you use to manipulate the data.

You use these commands for the following actions:

  • Modification

Example DML commands are SELECT , INSERT , UPDATE , and DELETE .

TCL commands

TCL stands for Transaction Control Language. As the name says, you use these commands to control and manage transactions.

One complete unit of work that involves various steps is called a transaction.

You use these commands for the following purposes:

  • To create savepoints
  • To set properties of the transaction going on
  • To undo the changes to the database (permanent)
  • To make changes in the database (permanent)

Example TCL commands include COMMIT , ROLLBACK , and SAVE TRANSACTION .

How to Write Basic Queries in SQL

There are various keywords you use in SQL like SELECT, FROM, WHERE, and others. These SQL keywords are not case-sensitive.

To create a table called Student that has a name, roll numbers, and marks in it, you can write:

Here CREATE, TABLE, and NOT NULL are keywords. You use CREATE and TABLE to create a table and NOT NULL to specify that the column cannot be left blank while making a record.

To make a query from a table, you'll write:  

You use the ‘select’ keyword to pull the information from a table. The ‘From’ keyword selects the table from which the information is to be pulled. The ‘where’ keyword specifies the condition to be specified.

For example, say we want to retrieve the marks from the student table that has data for marks, roll numbers, and names. The command would be as follows:

If you want to learn more about SQL for beginners, you can check out this cheatsheet that'll teach you the basics pretty quickly.

You can also go through this Relational Database Course for Beginners to get a more solid understanding of the query language.

Why Are DBMS and SQL Important?

Being able to work with DBMS and SQL are some of the most critical skills in today’s world. After all, you know what they say - "Data is the new oil." So you should know how to work with it effectively.

Here are a few reasons why you should learn how to use at least one DBMS and SQL.

Reasons to Learn How to Use a DBMS

If you're storing an extremely large amount of data.

If your organization needs to store a huge amount of data, you'll want to use a DBMS to keep them organized and be able to access them easily.

DBMS store the data in a very logical manner making it very easy to work with a humongous amount of Data. You can read more about database management systems in this tutorial by freeCodeCamp , in this Wiki , and on Scaler for a better understanding of data storage in DBMS.

If you're doing data mining

Data mining is the process of extracting usable data that includes only relevant information from a very large dataset. Using a DBMS, you can perform data mining very efficiently. For managing the data, you use CRUD operations which stands for Create, Read, Update, and Delete. You can perform these operations with a DBMS easily and efficiently.

Integrity constraint and scalability

The data you store in your database satisfies integrity constraints. Integrity constraints are the set of rules that are already defined and which are responsible for maintaining the quality and consistency of data in that database. The DBMS makes sure that the data is consistent. Scalability is another important feature of a DBMS. You can insert a lot of data into a database very easily and it will be accessible to the user quickly and with some basic queries. You do not need to write new code and spend lots of time and money on expanding the same database.

When you have multiple user interfaces

When you're using a DBMS, you can have multiple users access the system at the same time. Just like in a UNIX operating system two users can log into a single account at the same time.

DBMS makes storing data simple. You can also add security permissions on data access to make sure access is restricted and the privacy of the data remains intact. DBMS protects the confidentiality, availability, integrity, and consistency of the data stored in it. Along with making the data secure it reduces the time taken to develop an application and makes the process efficient.

Learning a DBMS is an in-demand skill:

Most companies out there – big or small – have lots of data to work with. And so they'll need people to analyze it.

If you know how to use a DBMS, you can use those skills in almost all data-oriented technologies. So once you learn DBMS, it will be easy to work on any data-driven technology.

Reasons to Learn SQL

Since SQL is a language that is used for database management, some of the above points also apply to learning it (such as data storage, data mining, and so on).

Here are some of the additional reasons you should learn SQL.

SQL is relatively easy to learn

SQL is quite easy to learn in the context of database management. SQL queries resemble the simple English we use in our day-to-day life. For example, if we want to make a table named Topics, we just have to use the command:

Understanding how a computer works helps you learn other skills related to computers like any programming language, spreadsheet software like MS Excel, and word processing software like MS word.

You also use SQL to manage data on various platforms like SQLite .

SQL is standardized

SQL was developed in the 1970s and has been extensively used for more than 50 years without many significant changes made to it. This makes it a standard skill for working with data, so typically when you apply for a job, they will be using SQL for data storage and management purposes. This general standardization also makes it easier to learn because you don't need to constantly update your knowledge, again and again, to be adept at it.

SQL is easy to troubleshoot

Any error you get while using SQL will show a clear message about what's going on in very simple English.

For example, if you are trying to use a table or any database that does not exist, it will show the error that the table or the database you are trying to access does not exist.

There is the concept of exception handling in SQL also just like any other           programming language.

Exception handling is used for handling query runtime errors with the TRY CATCH construct. The TRY block is used to specify the set of statements that need to be checked for an error, while CATCH block executes certain statements in case an error has occurred. Exception handling is crucial for writing bug-free code.

Easy to manipulate data

Data manipulation refers to Adding (or inserting), deleting (removing), and modifying (updating) the data in a database. The data you store in the SQL is dynamic in nature which makes it easy for you to manipulate the data at any point in time.

You can also retrieve data easily using a single-line SQL command.And if you want to present the data in the form of charts or graphs, then SQL plays a key role in that and makes data visualization easy for you.

Client and server data sharing

Whenever an application is used, the data stored in the database management system is retrieved based on the option selected by the user. To create and manage the servers, SQL is used. SQL is used to navigate through the large amount of data stored in the database management system.

Easy to sync data from multiple sources

You'll come across many cases when you have to get data from multiple sources and combine them to get the desired output. This means you'll be dealing with outputs from multiple sources at one time, which can be time-consuming and a tedious job.

But when you use SQL, it is much easier to handle data from multiple sources at the same time and combine them to get the desired output.

In SQL you can use the UNION operation to combine data, like this:

Using this combines the columns “name” and “order_id” from the “customers” and “orders” tables, respectively, and renders the combined table.

Flexibility, versatility, and data analysis

SQL is a programming language, but the scope of this language is not only limited to programming tasks. You can use it for various purposes like in the finance sector and in sales and marketing, as well. By executing a few queries you can get the data you need and analyze it for your purposes.

There are various roles that are specific to SQL like SQL developer, SQL database Administrator, Database Tester, SQL Data analyst DBA, Data Modeler, and more. You can learn more about salary insights here .

Another important role is that of a data analyst. The process of cleansing, modeling, and transforming data to draw conclusions from it based on certain information is called Data analysis.

The role of a data analyst is important in any organization as it helps in analyzing trends and making fast and flexible decisions on the basis of the available data.

SQL and DBMS are two of the most in-demand skills for Data Analysis.

How DBMS and SQL Work Together

DBMS and SQL are interdependent and cooperate to make the data organized and accessible. Now, let's understand how SQL works in synchronization with a Database Management System.

How-Does-SQL-Work

SQL is the way you interact with the database management system. You use it to retrieve, insert, update, or delete data (CRUD operations), among other things.

When you execute a SQL command, the DBMS figures out the most efficient way to execute that command. The interpretation of the task to be performed is determined by the SQL engine.

The classic query engine is used to handle all the non-SQL queries, but it will not handle any logical files.

The query processor interprets the queries of the user and translates them into a database-understandable format.

The parser is used for translation purposes (in query processing). It also checks the syntax of the query and looks for errors, if present.

The optimisation engine, as the name suggests, optimises the performance of the database with the help of useful insights.

The DBMS engine is the underlying software component for performing CRUD operations on the database.

The file manager is used for managing the files in the database, one at a time.

And the transaction manager is used for managing the transactions to maintain concurrency while accessing data.

In this article, we have discussed the basics of DBMS and SQL and why you should learn these skills.

We have discussed the purpose and importance of DBMS and SQL, what they're used for, and what professionals who work with databases and SQL do.

After reading this article you have a good understanding of where knowledge of DBMS and SQL can take you. Happy Learning!

Writing about tech is my side hustle, I learn by writing.

If you read this far, thank the author to show them you care. Say Thanks

Learn to code for free. freeCodeCamp's open source curriculum has helped more than 40,000 people get jobs as developers. Get started

Browse Course Material

Course info, instructors.

  • Prof. Samuel Madden
  • Prof. Robert Morris
  • Prof. Michael Stonebraker
  • Dr. Carlo Curino

Departments

  • Electrical Engineering and Computer Science

As Taught In

  • Information Technology
  • Algorithms and Data Structures
  • Data Mining
  • Software Design and Engineering

Learning Resource Types

Database systems, assignments.

This section contains problem sets, labs, and a description of the final project. Some assignments require access to online development tools and environments that may not be freely available to OCW users. The assignments are included here as examples of the work MIT students were expected to complete.

Problem Sets

SimpleDB overview ( PDF )

SimpleDB documentation

Final Project Assignment and Ideas

facebook

You are leaving MIT OpenCourseWare

  • Mastering Database Assignments: Best Practices for Success and Understanding

Avoiding Common Mistakes in Database Assignments: Best Practices

David Hernandez

In the dynamic realm of database management, students often find themselves grappling with intricate assignments that demand a profound understanding of both theoretical concepts and practical applications. The complexity of these tasks frequently leads students into inadvertent pitfalls, potentially impacting their academic grades and hindering their overall comprehension of the subject matter. Recognizing the crucial intersection of theoretical knowledge and hands-on application, this blog seeks to illuminate the common mistakes students make in navigating these challenging assignments and, more importantly, to provide a comprehensive set of best practices for overcoming these hurdles successfully. Beyond the immediate academic context, mastery of database management skills holds paramount importance in both academic and real-world scenarios, emphasizing the need for students to not only excel in their assignments but to cultivate a deeper understanding that will serve them in their future careers. By delving into these common pitfalls and presenting effective strategies for their avoidance, this blog aims to empower students with the knowledge and tools necessary to navigate the intricate landscape of database assignments with confidence and competence.

Navigating the complex terrain of database management assignments requires more than just a theoretical grasp of concepts; it demands a strategic approach to problem-solving and a meticulous understanding of the assignment requirements. As students delve into the intricacies of these tasks, they often encounter challenges such as misinterpreting instructions, overlooking key design principles, and making coding errors during implementation. These pitfalls not only jeopardize their grades but also hinder the development of a robust foundation in database management. Hence, the need for a proactive approach to address these challenges becomes evident from the outset.

Common Mistakes in Database Assignments

The essence of success lies in the initial stages, where a careful reading of assignment instructions is paramount. Many students, eager to jump into the technical aspects, overlook the subtleties embedded in the guidelines. This oversight can lead to a misguided approach and, subsequently, an inaccurate solution. By emphasizing the importance of reading instructions carefully, students can establish a strong foundation for the rest of their assignment endeavors. Furthermore, the practice of seeking clarification when aspects of the assignment are unclear is instrumental in preventing misunderstandings that may cascade into critical errors later in the process.

Moving into the planning and design phase, students must recognize the pivotal role of Entity-Relationship Diagrams (ERDs) and normalization in establishing a robust database structure. Creating a comprehensive ERD facilitates a visual representation of the relationships between entities, serving as a roadmap for the subsequent stages. Normalization, often underestimated, is key to optimizing the database structure, eliminating redundancy, and averting dependency issues. Neglecting these critical design principles can result in databases that are inefficient, unoptimized, and prone to data anomalies.

Transitioning to the implementation and coding phase, meticulous attention to detail is crucial. Syntax errors, often stemming from simple typos, can lead to time-consuming debugging sessions that could have been avoided with a careful review. Testing and debugging should be ongoing processes, with the creation of diverse test cases to ensure the robustness of the code. This iterative approach minimizes the chances of overlooking errors and enhances the overall reliability of the database implementation.

Beyond the coding aspect, documentation plays a pivotal role in the success of a database assignment. Meaningful comments within the code and a comprehensive README file not only serve as a guide for others but also facilitate a deeper understanding of the code for the original creator. Documentation is the bridge between the creator's intentions and the reader's comprehension, fostering transparency and replicability.

Effective time management is the final pillar supporting a successful database assignment. Breaking the assignment into manageable tasks and setting realistic deadlines ensures a steady and systematic approach. Starting early mitigates the risk of procrastination, providing ample time for thoughtful consideration, testing, and refinement. To enhance your efficiency, consider seeking assistance or resources, such as online tutorials or dedicated platforms, that can help you solve your database homework effectively.

Understanding the Assignment Requirements

In the intricate landscape of database management assignments, the first crucial step towards success lies in a comprehensive understanding of the assignment requirements. This initial phase serves as the cornerstone for the entire process, requiring students to refrain from hastily plunging into the technical intricacies without a clear grasp of the assignment's full scope. The importance of this stage cannot be overstated, as students who neglect to fully comprehend the nuances of the task at hand may find themselves producing solutions that are either incomplete or inaccurately aligned with the objectives. The overarching goal is to instill in students the significance of a meticulous approach to assignment interpretation, emphasizing that a well-informed foundation is the key to navigating the subsequent complexities of database assignments successfully.

Moving forward into the planning and design phase, students are tasked with translating their understanding of assignment requirements into a structured blueprint for the database. This stage involves the creation of Entity-Relationship Diagrams (ERDs), serving as a visual representation of the relationships between entities within the database. It is here that the intricate web of connections begins to take shape, guiding the subsequent development process. Additionally, the concept of normalization takes center stage, urging students to critically evaluate and refine their database structures. The practice of normalization is paramount in eliminating redundancies and dependencies, fostering an optimized and efficient database design. Thus, the planning and design phase acts as the scaffolding upon which the entire database assignment will stand, demanding careful consideration and strategic thinking to lay a solid foundation for the subsequent implementation.

Reading Instructions Carefully

Within the broader realm of understanding assignment requirements, a specific emphasis is placed on the critical skill of reading instructions with meticulous attention. This sub-section underscores the imperative nature of the first step in any assignment: a careful and thorough reading of the provided instructions. As students embark on the assignment journey, they are advised to scrutinize the instructions for keywords that signify specific actions or requirements, such as "normalize," "optimize," or "design." These keywords serve as guiding beacons, directing students towards a precise and targeted approach. The consequences of overlooking these details can be profound, potentially leading to a misguided approach that culminates in an ultimately incorrect solution. Therefore, this sub-section serves as a focal point for honing students' interpretive skills, ensuring that they can decode the assignment's intricacies and approach the task with a clear, informed strategy.

Seeking Clarification

Recognizing that ambiguity can be a stumbling block, the importance of seeking clarification is underscored in this sub-section. Students are encouraged not to shy away from reaching out to their instructors if any aspect of the assignment remains unclear. This proactive approach is positioned as a pivotal strategy to circumvent potential misinterpretations that could snowball into significant errors later in the process. By establishing a clear understanding from the outset, students lay the groundwork for a successful engagement with the assignment, fortifying their ability to navigate the complexities with confidence and accuracy.

Planning and Design

Effective planning serves as the bedrock for a successful database assignment, laying the groundwork for a meticulous and well-executed project. The significance of this planning phase becomes especially apparent as students traverse the intricate landscape of database management. It is within this planning stage that the initial seeds of success are sown, and any oversight can lead to the manifestation of inefficiencies, suboptimal structures, and error-prone databases. The creation of a robust Entity-Relationship Diagram (ERD) emerges as a pivotal aspect of this planning process. Through the ERD, students embark on a visual journey, mapping out the intricate relationships between entities within the database. This graphical representation becomes a guiding compass, ensuring the accurate alignment of entities and relationships, steering away from the pitfalls of a flawed database structure. The importance of normalization surfaces as yet another crucial consideration during the planning phase. Normalization, a foundational concept in database design, serves as the compass that aligns the database structure with optimal principles. Ensuring that the database is properly normalized becomes paramount, as this process eradicates redundancy and dependency issues. Failure to normalize can pave the way for data anomalies and performance bottlenecks, unraveling the integrity of the database. Thus, in the realm of database assignments, the planning phase emerges not merely as a preliminary step but as the linchpin upon which the success or failure of the entire project hinges. It is through effective planning that students fortify themselves against the risks of structural inadequacies and pave the way for a database that stands as a testament to meticulous design and strategic forethought.

Within the realm of database assignments, the intricacies of the planning phase extend beyond the creation of ERDs and normalization principles, encompassing a holistic strategy for achieving a seamless integration of theoretical concepts and practical application. A nuanced understanding of the database's purpose and the relationships between its components becomes paramount during this planning process. Students must not only identify entities and their connections but also discern the nature of these relationships and the implications for database performance and functionality. Moreover, the planning phase demands an acute awareness of the specific requirements outlined in the assignment instructions. Clarity in these requirements ensures that the subsequent design and implementation align precisely with the objectives set forth, minimizing the risk of diverging down an erroneous path.

As students navigate the intricacies of database assignments, they must embrace a proactive mindset during the planning phase. Anticipating potential challenges and devising preemptive strategies to address them becomes a hallmark of effective planning. This includes considering scalability, potential future modifications, and the adaptability of the database to evolving needs. Through this forward-thinking approach, students not only mitigate risks but also position themselves for a more robust and resilient database structure.

The creation of an ERD, while serving as a visual guide, is not merely a box-ticking exercise; it is a dynamic process that evolves as the understanding of the database deepens. Students should view the ERD as a living document, subject to refinement and modification throughout the planning phase and beyond. This adaptability ensures that the database design remains agile, capable of accommodating changes without compromising its integrity.

Normalization, often viewed as a technical aspect of database design, should be approached with a strategic mindset. It's not merely about adhering to a set of rules; it's about optimizing the database for efficiency and minimizing the risk of data anomalies. During the planning phase, students should carefully analyze the data they intend to store, identifying patterns and dependencies that inform the normalization process. This proactive approach prevents the retrospective realization of normalization shortcomings during the implementation phase, saving valuable time and effort.

Implementation and Coding

Implementation and Coding constitute a pivotal phase in the successful execution of a database assignment. It marks the transition from conceptualizing the design to the practical application of coding, a juncture where students commonly encounter challenges that can impact the overall quality of their work. The translation of a meticulously planned design into functional code demands precision and attention to detail, areas where students often falter. The prevalence of coding errors and oversights can lead to setbacks that are not only time-consuming but may also compromise the integrity of the entire database structure. Within this realm, Syntax Errors emerge as a critical focal point. They represent the fine line between a flawless code execution and a cascade of debugging complexities. A cautionary step, therefore, involves a meticulous review of the code to catch and rectify any syntax errors before execution. Simple typos, overlooked punctuation, or misplaced characters can transform an otherwise well-conceived code into a source of frustration and delays.

Parallel to the pursuit of syntax perfection is the imperative of Testing and Debugging. Regular testing becomes the backbone of a robust database implementation. Through the creation of comprehensive test cases covering various scenarios, students can systematically evaluate the resilience and accuracy of their code. This proactive approach not only identifies potential issues early in the process but also facilitates a smoother debugging phase. The significance of debugging tools cannot be overstated. Integrating these tools into the coding workflow streamlines the identification and rectification of errors, providing students with a more efficient means of navigating the intricacies of their code. Adopting systematic testing procedures, whether through automated tools or manual processes, is instrumental in reducing the likelihood of errors that may otherwise elude initial detection. In essence, the Implementation and Coding phase serves as the crucible where theoretical design meets the crucible of real-world execution, demanding a meticulous and strategic approach to ensure a seamless transition from concept to functionality.

Documentation

Documentation, often relegated to the sidelines, emerges as a linchpin in the triumphant execution of a database assignment. The significance of meticulous documentation cannot be overstated, wielding the power to elevate a project from a mere compilation of code to a transparent, replicable, and comprehensible masterpiece. Within this realm, the integration of meaningful comments into the code stands as a sentinel against ambiguity. These comments not only elucidate the purpose of each code section but also serve as a beacon of understanding for the coder in subsequent endeavors. Beyond self-clarification, these comments extend a helping hand to potential collaborators or reviewers, ensuring that the intricate tapestry of logic woven into the code is decipherable to those who traverse it. Furthermore, the inclusion of a comprehensive README file serves as the pièce de résistance of documentation. This file, more than a mere formality, acts as a roadmap, unveiling the intricacies of the database structure and offering clear instructions for code execution. Its value transcends individual convenience, becoming a vital tool for instructors assessing the work and for any future souls delving into the labyrinth of your database. In essence, documentation emerges as the unsung hero, transforming a mere assortment of code into a lucid, comprehensible, and ultimately successful database assignment.

The role of documentation in the context of a database assignment extends beyond mere formalities; it is the thread that weaves coherence and understanding into the intricate fabric of coding endeavors. As developers engage in the meticulous process of crafting database solutions, the inclusion of meaningful comments within the code becomes a practice of profound significance. Each line, each block of code, is annotated not only to serve as a guiding light for the coder's future self but also as a communicative bridge to potential collaborators or evaluators. These comments, akin to annotations in a scholarly manuscript, decode the thought processes encapsulated in the code, facilitating comprehension and troubleshooting.

A README file, though seemingly unassuming, transforms into a comprehensive guide, akin to the prologue of a literary masterpiece. It encapsulates the essence of the database structure, offering a concise yet detailed overview that transcends the mere technicalities. Here, the importance of clarity cannot be overstated. A well-structured README file is more than a perfunctory addition; it is a user-friendly manual that empowers others to navigate the intricacies of the code with ease. It is a repository of knowledge, providing insights into the rationale behind design choices, potential pitfalls, and additional information crucial for a holistic understanding.

Conclusion:

In conclusion, a profound understanding of database assignments transcends the mere completion of tasks; it encapsulates a holistic approach encompassing meticulous planning, precise implementation, and strategic time management. By delving into the intricacies of database management, students can fortify their learning experience and elevate their academic performance. The journey begins with a clear comprehension of assignment requirements—an often overlooked yet foundational step that sets the trajectory for success. Meticulous planning, as evidenced by the creation of comprehensive Entity-Relationship Diagrams (ERDs) and adherence to normalization principles, lays the groundwork for a robust database structure. Transitioning to the implementation and coding phase requires unwavering attention to detail, with syntax errors and debugging becoming focal points to ensure the integrity of the database solution. As the code takes shape, the significance of documentation emerges, acting as a bridge between the creator's intentions and the comprehensibility of the code for others. Lastly, effective time management serves as the keystone, guiding students through the assignment process in a systematic manner. These best practices not only guarantee successful database assignments but also contribute to a profound understanding of database management concepts, echoing beyond academic realms into the broader landscape of professional competency. Embracing these principles empowers students to navigate the intricate world of database assignments with confidence, fostering skills that are not only instrumental in academic success but are also invaluable assets in their future careers.

Furthermore, the importance of code implementation cannot be overstated. As students venture into the realm of coding, they must approach this phase with precision and care. Syntax errors, often arising from minor oversights, can snowball into significant obstacles during the debugging process. Thus, a vigilant review of the code before execution is indispensable. Testing and debugging should not be viewed as mere technicalities but as integral components of the coding process. The creation of diverse and comprehensive test cases becomes a strategic tool to assess the resilience of the implemented code under various scenarios. This iterative approach minimizes the likelihood of overlooking errors and bolsters the reliability of the database implementation.

Simultaneously, the role of documentation becomes increasingly evident. Meaningful comments strategically placed within the code serve as signposts, guiding both the original creator and potential collaborators through the logic and functionality of the database. A README file, rich in detail, serves as a comprehensive guidebook, offering insights into the database's structure, instructions for execution, and any additional information crucial for understanding the intricacies of the code. Documentation is not merely an ancillary task but a critical element that enhances transparency, facilitates collaboration, and contributes to the replicability of the solution.

In the broader context, effective time management emerges as the linchpin that binds these practices together. Breaking down the assignment into manageable tasks and establishing realistic deadlines ensures a steady and measured progression. Procrastination, a common pitfall, is mitigated by commencing the assignment early, affording students the luxury of time for contemplation, refinement, and comprehensive testing. This proactive time management strategy not only diminishes the stress associated with looming deadlines but also allows for a more thoughtful and deliberate approach to each phase of the assignment.

In essence, the adoption of these best practices transcends the mere completion of database assignments; it instills in students a comprehensive skill set crucial for success both academically and professionally. It fosters a mindset that values not just the end result but the journey itself—the meticulous planning, the precise coding, the thoughtful documentation, and the strategic time management. The amalgamation of these practices does not only lead to successful assignments but engenders a profound understanding of database management concepts. This understanding, beyond being a prerequisite for academic achievement, serves as a beacon guiding students through the challenges they will encounter in their future careers.

Post a comment...

Mastering database assignments: best practices for success and understanding submit your homework, attached files.

Database Star

Database Normalization: A Step-By-Step-Guide With Examples

Database normalisation is a concept that can be hard to understand.

But it doesn’t have to be.

In this article, I’ll explain what normalisation in a DBMS is and how to do it, in simple terms.

By the end of the article, you’ll know all about it and how to do it.

So let’s get started.

Want to improve your database modelling skills? Click here to get my Database Normalisation Checklist: a list of things to do as you normalise or design your database!

Table of Contents

What Is Database Normalization?

Database normalisation, or just normalisation as it’s commonly called, is a process used for data modelling or database creation, where you organise your data and tables so it can be added and updated efficiently.

It’s something a person does manually, as opposed to a system or a tool doing it. It’s commonly done by database developers and database administrators.

It can be done on any relational database , where data is stored in tables that are linked to each other. This means that normalization in a DBMS (Database Management System) can be done in Oracle, Microsoft SQL Server, MySQL, PostgreSQL and any other type of database.

To perform the normalization process, you start with a rough idea of the data you want to store, and apply certain rules to it in order to get it to a more efficient form.

I’ll show you how to normalise a database later in this article.

Why Normalize a Database?

So why would anyone want to normalize their database?

Why do we want to go through this manual process of rearranging the data?

There are a few reasons we would want to go through this process:

  • Make the database more efficient
  • Prevent the same data from being stored in more than one place (called an “insert anomaly”)
  • Prevent updates being made to some data but not others (called an “update anomaly”)
  • Prevent data not being deleted when it is supposed to be, or from data being lost when it is not supposed to be (called a “delete anomaly”)
  • Ensure the data is accurate
  • Reduce the storage space that a database takes up
  • Ensure the queries on a database run as fast as possible

Normalization in a DBMS is done to achieve these points. Without normalization on a database, the data can be slow, incorrect, and messy .

Data Anomalies

Some of these points above relate to “anomalies”.

An anomaly is where there is an issue in the data that is not meant to be there . This can happen if a database is not normalised.

Let’s take a look at the different kinds of data anomalies that can occur and that can be prevented with a normalised database.

Our Example

We’ll be using a student database as an example in this article, which records student, class, and teacher information.

Let’s say our student database looks like this:

This table keeps track of a few pieces of information:

  • The student names
  • The fees a student has paid
  • The classes a student is taking, if any

This is not a normalised table, and there are a few issues with this.

Insert Anomaly

An insert anomaly happens when we try to insert a record into this table without knowing all the data we need to know.

For example, if we wanted to add a new student but did not know their course name.

The new record would look like this:

We would be adding incomplete data to our table, which can cause issues when trying to analyse this data.

Update Anomaly

An update anomaly happens when we want to update data, and we update some of the data but not other data.

For example, let’s say the class Biology 1 was changed to “Intro to Biology”. We would have to query all of the columns that could have this Class field and rename each one that was found.

There’s a risk that we miss out on a value, which would cause issues.

Ideally, we would only update the value once, in one location.

Delete Anomaly

A delete anomaly occurs when we want to delete data from the table, but we end up deleting more than what we intended.

For example, let’s say Susan Johnson quits and her record needs to be deleted from the system. We could delete her row:

But, if we delete this row, we lose the record of the Biology 2 class, because it’s not stored anywhere else. The same can be said for the Medicine course.

We should be able to delete one type of data or one record without having impacts on other records we don’t want to delete.

What Are The Normal Forms?

The process of normalization involves applying rules to a set of data. Each of these rules transforms the data to a certain structure, called a normal form .

There are three main normal forms that you should consider (Actually, there are six normal forms in total, but the first three are the most common).

Whenever the first rule is applied, the data is in “ first normal form “. Then, the second rule is applied and the data is in “ second normal form “. The third rule is then applied and the data is in “ third normal form “.

Fourth and fifth normal forms are then achieved from their specific rules.

Alright, so there are three main normal forms that we’re going to look at. I’ve written a post on designing a database , but let’s see what is involved in getting to each of the normal forms in more detail.

What Is First Normal Form?

First normal form is the way that your data is represented after it has the first rule of normalization applied to it. Normalization in DBMS starts with the first rule being applied – you need to apply the first rule before applying any other rules.

Let’s start with a sample database. In this case, we’re going to use a student and teacher database at a school. We mentioned this earlier in the article when we spoke about anomalies, but here it is again.

Our Example Database

We have a set of data we want to capture in our database, and this is how it currently looks. It’s a single table called “student” with a lot of columns.

Everything is in one table.

How can we normalise this?

We start with getting the data to First Normal Form.

To apply first normal form to a database, we look at each table, one by one, and ask ourselves the following questions of it:

Does the combination of all columns make a unique row every single time?

What field can be used to uniquely identify the row?

Let’s look at the first question.

No. There could be the same combination of data, and it would represent a different row. There could be the same values for this row and it would be a separate row (even though it is rare).

The second question says:

Is this the student name? No, as there could be two students with the same name.

Address? No, this isn’t unique either.

Any other field?

We don’t have a field that can uniquely identify the row.

If there is no unique field, we need to create a new field. This is called a primary key, and is a database term for a field that is unique to a single row. (Related: The Complete Guide to Database Keys )

When we create a new primary key, we can call it whatever we like, but it should be obvious and consistently named between tables. I prefer using the ID suffix, so I would call it student ID.

This is our new table:

Student ( student ID , student name, fees paid, date of birth, address, subject 1, subject 2, subject 3, subject 4, teacher name, teacher address, course name)

This can also be represented in an Entity Relationship Diagram (ERD):

Normalisation ERD Examples - 1NF

The way I have written this is a common way of representing tables in text format. The table name is written, and all of the columns are shown in brackets, with the primary key underlined.

This data is now in first normal form.

This example is still in one table, but it’s been made a little better by adding a unique value to it.

Want to find a tool that creates these kinds of diagrams? There are many tools for creating these kinds of diagrams. I’ve listed 76 of them in this guide to Data Modeling Tools , along with reviews, price, and other features. So if you’re looking for one to use, take a look at that list.

What Is Second Normal Form?

The rule of second normal form on a database can be described as:

  • Fulfil the requirements of first normal form
  • Each non-key attribute must be functionally dependent on the primary key

What does this even mean?

It means that the first normal form rules have been applied. It also means that each field that is not the primary key is determined by that primary key , so it is specific to that record. This is what “functional dependency” means.

Let’s take a look at our table.

Are all of these columns dependent on and specific to the primary key?

The primary key is student ID, which represents the student. Let’s look at each column:

  • student name: Yes, this is dependent on the primary key. A different student ID means a different student name.
  • fees paid: Yes, this is dependent on the primary key. Each fees paid value is for a single student.
  • date of birth: Yes, it’s specific to that student.
  • address: Yes, it’s specific to that student.
  • subject 1: No, this column is not dependent on the student. More than one student can be enrolled in one subject.
  • subject 2: As above, more than one subject is allowed.
  • subject 3: No, same rule as subject 2.
  • subject 4: No, same rule as subject 2
  • teacher name: No, the teacher name is not dependent on the student.
  • teacher address: No, the teacher address is not dependent on the student.
  • course name: No, the course name is not dependent on the student.

We have a mix of Yes and No here. Some fields are dependent on the student ID, and others are not.

How can we resolve those we marked as No?

Let’s take a look.

First, the subject 1 column. It is not dependent on the student, as more than one student can have a subject, and the subject isn’t a part of the definition of a student.

So, we can move it to a new table:

Subject (subject name)

I’ve called it subject name because that’s what the value represents. When we are writing queries on this table or looking at diagrams, it’s clearer what subject name is instead of using subject.

Now, is this field unique? Not necessarily. Two subjects could have the same name and this would cause problems in our data.

So, what do we do? We add a primary key column, just like we did for student. I’ll call this subject ID, to be consistent with the student ID.

Subject ( subject ID , subject name)

This means we have a student table and a subject table. We can do this for all four of our subject columns in the student table, removing them from the student table so it looks like this:

Student ( student ID , student name, fees paid, date of birth, address, teacher name, teacher address, course name)

But they are in separate tables. How do we link them together?

We’ll cover that shortly. For now, let’s keep going with our student table.

The next column we marked as No was the Teacher Name column. The teacher is separate to the student so should be captured separately. This means we should move it to its own table.

Teacher (teacher name)

We should also move the teacher address to this table, as it’s a property of the teacher. I’ll also rename teacher address to be just address.

Teacher (teacher name, address)

Just like with the subject table, the teacher name and address is not unique. Sure, in most cases it would be, but to avoid duplication we should add a primary key. Let’s call it teacher ID,

Teacher ( teacher ID , teacher name, address)

The last column we have to look at was the Course Name column. This indicates the course that the student is currently enrolled in.

While the course is related to the student (a student is enrolled in a course), the name of the course itself is not dependent on the student.

So, we should move it to a separate table. This is so any changes to courses can be made independently of students.

The course table would look like this:

Course (course name)

Let’s also add a primary key called course ID.

Course ( course ID , course name)

We now have our tables created from columns that were in the student table. Our database so far looks like this:

Student ( student ID , student name, fees paid, date of birth, address) Subject ( subject ID , subject name) Teacher ( teacher ID , teacher name, address) Course ( course ID , course name)

Using the data from the original table, our data could look like this:

How do we link these tables together? We still need to know which subjects a student is taking, which course they are in, and who their teachers are.

Foreign Keys in Tables

We have four separate tables, capturing different pieces of information. We need to capture that students are taking certain courses, have teachers, and subjects. But the data is in different tables.

How can we keep track of this?

We use a concept called a foreign key.

A foreign key is a column in one table that refers to the primary key in another table . Related: The Complete Guide to Database Keys .

It’s used to link one record to another based on its unique identifier, without having to store the additional information about the linked record.

Here are our two tables so far:

Student ( student ID , student name, fees paid, date of birth, address) Subject ( subject ID , subject name) Teacher ( teacher ID , teacher name, teacher address) Course ( course ID , course name)

To link the two tables using a foreign key, we need to put the primary key (the underlined column) from one table into the other table.

Let’s start with a simple one: students taking courses. For our example scenario, a student can only be enrolled in one course at a time, and a course can have many students.

We need to either:

  • Add the course ID from the course table into the student table
  • Add the student ID from the student table into the course table

But which one is it?

In this situation, I ask myself a question to work out which way it goes:

Does a table1 have many table2s, or does a table2 have many table1s?

If it’s the first, then table1 ID goes into table 2, and if it’s the second then table2 ID goes into table1.

So, if we substitute table1 and table2 for course and student:

Does a course have many students, or does a student have many courses?

Based on our rules, the first statement is true: a course has many students.

This means that the course ID goes into the student table.

Student ( student ID , course ID , student name, fees paid, date of birth, address) Subject ( subject ID , subject name) Teacher ( teacher ID , teacher name, teacher address) Course ( course ID , course name)

I’ve italicised it to indicate it is a foreign key – a value that links to a primary key in another table.

When we actually populate our tables, instead of having the course name in the student table, the course ID goes in the student table. The course name can then be linked using this ID.

This also means that the course name is stored in one place only, and can be added/removed/updated without impacting other tables.

I’ve created a YouTube video to explain how to identify and diagram one-to-many relationships like this:

We’ve linked the student to the course. Now let’s look at the teacher.

How are teachers related? Depending on the scenario, they could be related in one of a few ways:

  • A student can have one teacher that teaches them all subjects
  • A subject could have a teacher than teaches it
  • A course could have a teacher that teaches all subjects in a course

In our scenario, a teacher is related to a course. We need to relate these two tables using a foreign key.

Does a teacher have many courses, or does a course have many teachers?

In our scenario, the first statement is true. So the teacher ID goes into the course table:

Student ( student ID , course ID , student name, fees paid, date of birth, address) Subject ( subject ID , subject name) Teacher ( teacher ID , teacher name, teacher address) Course ( course ID , teacher ID , course name)

The table data would look like this:

This allows us to change the teacher’s information without impacting the courses or students.

Student and Subject

So we’ve linked the course, teacher, and student tables together so far.

What about the subject table?

Does a subject have many students, or does a student have many subjects?

The answer is both.

How is that possible?

A student can be enrolled in many subjects at a time, and a subject can have many students in it.

How can we represent that? We could try to put one table’s ID in the other table:

But if we do this, we’re storing many pieces of information in one column, possibly separated by commas.

This makes it hard to maintain and is very prone to errors.

If we have this kind of relationship, one that goes both ways, it’s called a many to many relationship . It means that many of one record is related to many of the other record.

Many to Many Relationships

A many to many relationship is common in databases. Some examples where it can happen are:

  • Students and subjects
  • Employees and companies (an employee can have many jobs at different companies, and a company has many employees)
  • Actors and movies (an actor is in multiple movies, and a movie has multiple actors)

If we can’t represent this relationship by putting a foreign key in each table, how can we represent it?

We use a joining table.

This is a table that is created purely for storing the relationships between the two tables.

It works like this. Here are our two tables:

Student ( student ID , course ID , student name, fees paid, date of birth, address) Subject ( subject ID , subject name)

And here is our joining table:

Subject_Student ( student ID , subject ID )

It has two columns. Student ID is a foreign key to the student table, and subject ID is a foreign key to the subject table.

Each record in the row would look like this:

Each row represents a relationship between a student and a subject.

Student 1 is linked to subject 1.

Student 1 is linked to subject 2.

Student 2 is linked to subject 2.

This has several advantages:

  • It allows us to store many subjects for each student, and many students for each subject.
  • It separates the data that describes the records (subject name, student name, address, etc.) from the relationship of the records (linking ID to ID).
  • It allows us to add and remove relationships easily.
  • It allows us to add more information about the relationship. We could add an enrolment date, for example, to this table, to capture when a student enrolled in a subject.

You might be wondering, how do we see the data if it’s in multiple tables? How can we see the student name and the name of the subjects they are enrolled in?

Well, that’s where the magic of SQL comes in. We use a SELECT query with JOINs to show the data we need. But that’s outside the scope of this article – you can read the articles on my Oracle Database page to find out more about writing SQL.

One final thing I have seen added to these joining tables is a primary key of its own. An ID field that   represents the record. This is an optional step – a primary key on a single new column works in a similar way to defining the primary key on the two ID columns. I’ll leave it out in this example.

So, our final table structure looks like this:

Student ( student ID , course ID , student name, fees paid, date of birth, address) Subject ( subject ID , subject name) Subject Enrolment ( student ID , subject ID ) Teacher ( teacher ID , teacher name, teacher address) Course ( course ID , teacher ID , course name)

I’ve called the table Subject Enrolment. I could have left it as the concatenation of both of the related tables (student subject), but I feel it’s better to rename the table to what it actually captures – the fact a student has enrolled in a subject. This is something I recommend in my SQL Best Practices post .

I’ve also underlined both columns in this table, as they represent the primary key. They can also represent a foreign key, which is why they are also italicised.

An ERD of these tables looks like this:

Normalisation ERD Examples - 2NF

This database structure is in second normal form. We almost have a normalised database.

Now, let’s take a look at third normal form.

What Is Third Normal Form?

Third normal form is the final stage of the most common normalization process. The rule for this is:

  • Fulfils the requirements of second normal form
  • Has no transitive functional dependency

What does this even mean? What is a transitive functional dependency?

It means that every attribute that is not the primary key must depend on the primary key and the primary key only .

For example:

  • Column A determines column B
  • Column B determines column C
  • Therefore, column A determines C

This means that column A determines column B which determines column C . This is a transitive functional dependency, and it should be removed. Column C should be in a separate table.

We need to check if this is the case for any of our tables.

Student ( student ID , course ID , student name, fees paid, date of birth, address)

Do any of the non-primary-key fields depend on something other than the primary key?

No, none of them do. However, if we look at the address, we can see something interesting:

We can see that there is a relationship between the ZIP code and the city or suburb. This is common with addresses, and you may have noticed this if you have filled out any forms for addresses online recently.

How are they related? The ZIP code, or postal code, determines the city, state, and suburb.

In this case, 56128 is South Boston, and 56125 is North Boston. (I just made this up so this is probably inaccurate data).

This falls into the pattern we mentioned earlier: A determines B which determines C.

Student determines the address ZIP code which determines the suburb.

So, how can we improve this?

We can move the ZIP code to another table, along with everything it identifies, and link to it from the student table.

Our table could look like this:

Student ( student ID , course ID , student name, fees paid, date of birth, street address, address code ID ) Address Code ( address code ID , ZIP code, suburb, city, state)

I’ve created a new table called Address Code, and linked it to the student table. I created a new column for the address code ID, because the ZIP code may refer to more than one suburb. This way we can capture that fact, and it’s in a separate table to make sure it’s only stored in one place.

Let’s take a look at the other tables:

Subject ( subject ID , subject name) Subject Enrolment ( student ID , subject ID )

Both of these tables have no columns that aren’t dependent on the primary key.

Teacher ( teacher ID , teacher name, teacher address)

The teacher table also has the same issue as the student table when we look at the address. We can, and should use the same approach for storing address.

So our table would look like this:

Teacher ( teacher ID , teacher name, street address, address code ID ) Address Code ( address code ID , ZIP code, suburb, city, state)

It uses the same Address Code table as mentioned above. We aren’t creating a new address code table.

Finally, the course table:

Course ( course ID , teacher ID , course name)

This table is OK. The course name is dependent on the course ID.

So, what does our database look like now?

Student ( student ID , course ID , student name, fees paid, date of birth, street address, address code ID ) Address Code ( address code ID , ZIP code, suburb, city, state) Subject ( subject ID , subject name) Subject Enrolment ( student ID , subject ID ) Teacher ( teacher ID , teacher name, street address, address code ID ) Course ( course ID , teacher ID , course name)

So, that’s how third normal form could look if we had this example.

An ERD of third normal form would look like this:

Normalisation ERD Examples - 3NF

Stopping at Third Normal Form

For most database normalisation exercises, stopping after achieving Third Normal Form is enough .

It satisfies a good relationship rules and will greatly improve your data structure from having no normalisation at all.

There are a couple of steps after third normal form that are optional. I’ll explain them here so you can learn what they are.

Fourth Normal Form and Beyond

Fourth normal form is the next step after third normal form.

What does it mean?

It needs to satisfy two conditions:

  • Meet the criteria of third normal form.
  • There are no non-trivial multivalued dependencies other than a candidate key.

So, what does this mean?

A multivalued dependency is probably better explained with an example, which I’ll show you shortly. It means that there are other attributes in the table that are not dependent on the primary key, and can be moved to another table.

Our database looks like this:

This meets the third normal form rules.

However, let’s take a look at the address fields: street address and address code.

  • Both the student and teacher table have these
  • What if a student moves addresses? Do we update the address in this field? If we do, then we lose the old address.
  • If an address is updated, is it because they moved? Or is it because there was an error in the old address?
  • What if two students have the same street address. Are they actually at the same address? What if we update one and not the other?
  • What if a teacher and a student are at the same address?
  • What if we want to capture a student or a teacher having multiple addresses (for example, postal and residential)?

There are a lot of “what if” questions here. There is a way we can resolve them and improve the quality of the data.

This is a multivalued dependency.

We can solve this by moving the address to a separate table .

The address can then be linked to the teacher and student tables.

Let’s start with the address table.

Address ( address ID , street address, address code ID )

In this table, we have a primary key of address ID, and we have stored the street address here. The address code table stays the same.

We need to link this to the student and teacher tables. How do we do this?

Do we also want to capture the fact that a student or teacher can have multiple addresses? It may be a good idea to future proof the design. It’s something you would want to confirm in your organisation.

For this example, we will design it so there can be multiple addresses for a single student.

Our tables could look like this:

Student ( student ID , course ID , student name, fees paid, date of birth) Address ( address ID , street address, address code ID ) Address Code ( address code ID , ZIP code, suburb, city, state) Student Address ( address ID, student ID ) Subject ( subject ID , subject name) Subject Enrolment ( student ID , subject ID ) Teacher ( teacher ID , teacher name) Teacher Address ( teacher ID, address ID ) Course ( course ID , teacher ID , course name)

An ERD would look like this:

Normalisation ERD Examples - 4NF

A few changes have been made here:

  • The address code ID has been removed from the Student table, because the relationships between student and address is now captured in the joining table called Student Address.
  • The teacher’s address is also captured in the joining table Teacher Address, and the address code ID has been removed from the Teacher table. I couldn’t think of a better name for each of these tables.
  • Address still links to address code ID

This design will let you do a few things:

  • Store multiple addresses for each student or teacher
  • Store additional information about an address relationship to a teach or student, such as an effective date (to track movements over time) or an address type (postal, residential)
  • Determine which students or teachers live at the same address with certainty (it’s linked to the same record).

So, that’s how you can achieve fourth normal form on this database.

There are a few enhancements you can make to this design, but it depends on your business rules:

  • Combine the student and teacher tables into a person table, as they are both effectively people, but teachers teach a class and students take a class. This table could then link to subjects and define that relationship as “teaches” or “is enrolled in”, to cater for this.
  • Relate a course to a subject, so you can see which subjects are in a course
  • Split the address into separate fields for unit number, street number, address line 1, address line 2, and so on.
  • Split the student name and teacher name into first and last names to help with displaying data and sorting.

These changes could improve the design, but I haven’t detailed them in any of these steps as they aren’t required for fourth normal form.

I hope this explanation has helped you understand what the normal forms are and what normalization in DBMS is. Do you have any questions on this process? Share them in the section below.

Lastly, if you enjoy the information and career advice I’ve been providing,  sign up to my newsletter below  to stay up-to-date on my articles. You’ll also receive a fantastic bonus. Thanks!

68 thoughts on “Database Normalization: A Step-By-Step-Guide With Examples”

assignment in dbms

Thanks so much for explaining this concept Ben. To me as a learner, this is the best way to grab this concept.

You broke this down to the last atom. Keep up the good work!

assignment in dbms

Thanks James, glad you found it helpful!

assignment in dbms

Absolutely, the best and easiest explanation I have seen. Very helpful.

assignment in dbms

Saludos Ben, buen post. Podrías por favor revisar la simbología que utilizaste en la relación de las tablas Student y Course, dado que comentaste en las líneas de arriba “significa que la identificación del curso entra en la tabla de estudiantes.” Comenta si la relación sería: Course -< Student

Hi Ronald, Sure, I’ll check this and update the post. (Google Translate: Greetings Ben, good post. Could you please check the symbology you used in the Student and Course table relationship, since you commented on the lines above “it means that the course identification enters the student table.” Comment if the relationship would be: Course – < Student)

Saludos Ben, la simbología de Courses y Student según planteaste es de “1 a n” verifica si sería ” -< " Buen post.

Thanks Ronald! (Google Translate: Greetings Ben, the symbology of Courses and Student as you raised is “1 to n” verifies if it would be “- <" Good post.)

assignment in dbms

thank you for sharing these things to us , damn i really love it. You guys are really awesome

assignment in dbms

i dont understand the second normal form linking student id to course id isnt clear

assignment in dbms

Excellent working example

Glad you found it useful!

assignment in dbms

This is a nice compilation and a good illustration of how to carry out table normalization. I wish you can provide script samples that represent the ERD you presented here. It will be so much helpful.

Hi DJ, Glad you like the article. Good idea – I’ll create some sample scripts and add them to the post. Thanks, Ben

assignment in dbms

Good job! This is a great way explaining this topic. You made it look easy to understand. But, one question I have for you is where is a best scenario in real life used the fourth normal form?

Hi Nati, Thanks, I’m glad you like the article. I’m not sure what would be a realistic example of using fourth normal form. I think many 3NF databases can be turned into 4NF, depending on how to want to record values (either a value in a table or an ID to another table). I haven’t used it that often.

assignment in dbms

Dear Sir’ Can we call the Fourth Normal Form as a BCNF (Boyce Codd Normal Form). Or not?

Hi Subzar, I think Fourth Normal Form is slightly different to BCNF. I haven’t used either method but I know they are a little different. I think 4NF comes after BCNF.

assignment in dbms

Hey Ben, Your notes are too helpful. Will recommend my other friends for sure. Thanks a lot :)

assignment in dbms

You’ve done a truly superb job on the majority of this. You’ve used far more details than most people who provide examples do.

Particularly good is the splitting of addresses into a separate table. That is just not done nearly enough.

However, two tables have critical problems: (1) The Student table should not contain Course ID (nor fees paid); there should be a separate Student_Course intersection table. (2) Similarly, the Course table should not have a Teacher ID, likewise a separate Course_Teacher intersection table should be created.

Reasoning (condensed): (1) A student must be able to enroll first, without yet specificying a course. The student’s name and other enrollment data are not related to any specific course. (2) A course has data of its own not related to the teacher: # of credit/lab hours, cost(s), first term offered, last term offered, etc.. Should the only teacher currently teaching a course withdraw from it, the course data should not be lost. Courses have prerequisites, sometimes complex ones, that have nothing to do with who is teaching the course.

Thanks for the feedback Scott and glad you like the post! I understand your reasoning, and yes ideally there would be those two intersection tables. These scenarios are things that we, as developers, would clarify during the design. The example I went with was a simple one where a student must have a course and a course must have a teacher, but in the real world it would cater to your scenarios. Thanks again, Ben

assignment in dbms

Simple & powerfully conveyed. Thank you.

Glad you found it helpful!

assignment in dbms

As a grade 11 teacher, I am well aware of the complexities students face when teaching/explaining the concepts within this topic. This article is brilliant and breaks down such a confusing topic quite nicely with examples along the way. My students will definitely benefit from this, thank you so much.

assignment in dbms

I am just starting out in SQL and this was quite helpful. Thanks.

assignment in dbms

what a tremendous insights about the normalisation you have explained and its gave me a lot of confedence Thank u some much ben my deepest gratitude for sharing knowledge . you truly proved sharing is caring with regards chandu, india

assignment in dbms

Came across your material while searching for Normalisation material, as wanting to use my time to improve my Club Membership records, having gained a ‘Database qualification’ some 20 to 30 years years ago, I think, I needed to refresh my memory! Anyway – some queries:

1. Shouldn’t the Student Name be broken down or decomposed into StudentForename and StudentSurname, since doesn’t 1NF require this? 2. Shouldn’t Teacher Name be converted as per 121 above as well?

This would enable records to be retrieved using Surname or Forename

Hi Tim, yes that’s a good point and it would be better to break it into two names for that purpose.

assignment in dbms

Wow, this is the very first website i finally thoroughly understood normalization. Thanks a lot.

Hello again

I have thought thru the data I need to record, I think, time will tell I suspect. Anyway we run upto 18 competitions, played by teams of 1, 2 3 or 4 members, thus I think that there may be Many to Many relationship between Member and Competition tables, as in Many Member records may be related to Many Competition records [potential for a Pairs or Triples or Fours teams to win all the Competitions they enter], am I correct?

Also should I design the Competition table as CompID, Year, Comp1, Comp 2, Comp3, each Header having the name of the Competition, then I presume a table that links the two, along the lines of:

CompID, Year, MemberID OR MemberID, Year, CompID

Regards, Tim

Hello again, thinking further, I presume that I could create 18 tables, one per Competition to capture the annual results.

Again though, presume my single Comp table (see above) shouldn’t have a column per comp, as this is a repeating group

So do I create a ‘joining table’, that records Year and Comp, another that records Member and Comp and one that records Member and Year.

I may be over thinking it, but as No Comp this year, I think I need to be able to record this, I think

Hi Tim, good question. You could create one table per competition, but you would have 18 tables which have the same structure and different data, which is quite repetitive. I would suggest having a single table for comp, and a column that indicates which competition it is for. It’s OK for a table to have a value that is repeated like this, as it identifies which competition something refers to. Yes you could create joining tables for Year and Comp (if there is a many to many relationship between them) and Member and Comp as well. What’s the relationship between Member and Year?

Thanks for reply, however, would it be easier to say create a Comp table of 18 records, a Comp Type table which has 2 records, that is Annual and One Day, another table for Comp Year, which will record the annual competition results based on:

CompYear – CompTypeID – CompID – MemID

thus each year would create 32 records [10 x 1 + 4 x2 + 2 x3 + 2 x 4], e.g

2019 – 1 – 4 – 1 2019 – 1 – 4 – 2 2019 – 1 – 4 – 3 2019 – 1 – 4 – 4 2019 – 1 – 3 – 1 2019 – 1 – 3 – 2 2019 – 1 – 3 – 3 2019 – 2 – 1 – 1

so members 1 to 4 won the 2019 one day comp Bickford Fours; and members 1 to 3 won the 2019 one day comp Arthur Johnson Triples; and member 1 won the 2019 annual singles championship

Would this work and have I had a light bulb moment?

Hi Tim, yes I think that would work! Storing the comp data separately from the comp type (and so on) will ensure the data is not repeated and is only stored in one place. Good luck!

assignment in dbms

Ben, Thank you so much! I was only able to grasp the concept of normalization in one hour or so because how you simplified the concepts through a simple running example.

assignment in dbms

Thanks a lot sir Daniel i have really understood this you are a great teacher

assignment in dbms

Firstly :Thank you for your website. Secondly: I have still problem with understanding the Second normal form. For example you have written : “student name: Yes, this is dependent on the primary key. A different student ID means a different student name.”. So in your design I am not allowed to have 2 students with same names? What will happen when this, not so uncommon situation occurs?

Glad you like it Wojtek! Yes, in this design you can have two students with the same name. They would have different IDs and different rows in the table, as two people with the same name is common like you mentioned.

assignment in dbms

This is the best explanation on why and how to normalize Tables… excellent work, maybe the best explanation out there….

assignment in dbms

Hi, Thanks for the post. That is exactly what I was looking for. But I have a question, how would I insert into student address and teacher address. Best regards

assignment in dbms

This is amazing, very well explained. Simple example made it easy to understand. Thank you so much!

assignment in dbms

Thanks sir, this very helpful

assignment in dbms

Sorry but your example is not in 1NF. 1NF dictates that you cannot have a repeating group. The subjects are a repeating group. Not saying you got the design wrong at the end just that you failed to remove the repeating group in 1NF. When you went to 2NF you made rules for the repeating group multiple times and took care of it but it should have been taken care of in 1NF.

assignment in dbms

Its so helpful easy to understand

assignment in dbms

This is great! You make it easy and simple to learn where I can understand.

assignment in dbms

If you”re going to break address into atoms, (unit, street, city, zip, etc.), would you also break down telephone numbers, (country code, area code, exchange, unit number) into separate fields in another table? How elemental do you go?

assignment in dbms

Clearly explained :)

assignment in dbms

Wow c’est vraiment très utile, ça vient d’apporter un plus ma connaissance. Vraiment merci beaucoup pour cet article.

assignment in dbms

Great post! Just wanted to check – for the ERD diagram in the 2NF example, wouldn’t the relationship between Course and Student be the other way around? A course can have many students, but a student can only be enrolled in one course. So the crows feet symbol should be on the Student table.

assignment in dbms

Hi Ben, I am hoping you can respond to the question above. I noticed the same and I was hoping to find a correction or explanation in the notes. I second everyone else’s compliments on a great post, too.

assignment in dbms

From table Student (student ID, course ID, student name, fees paid, date of birth, street address, address code ID) why you put “street address” column remember that “address code ID” is available idenitify address of student i dont understand here

assignment in dbms

Hi Ben ! ive got a question for you. i didnt understand this part:

So that means in a first normal form duplicate roes are allowed?

assignment in dbms

I stumbled on this article explaining so succinctly about normalization of database. I must admit that it helped me understand the concept using an example far much better than just theory.

Kudos to you @Ben – You are really a DB star.

Will recommend it to my friends. I am in the process of putting this knowledge into an Employee Management System.

assignment in dbms

Mmnh ! Thank you sir, it’s very awesome tutor. 👍

assignment in dbms

The model breaks as soon as you add a 2nd course for a student. CourseID should not be in the student table. You need a separate table that ties studentID and courseID together

That’s a good point. Yes you would need a separate table for that scenario.

assignment in dbms

The ERDs for the 2nd / 3rd / 4th normal form show the crows foot at the COURSE table, but the STUDENT table receives the FK course_id. The crows foot represents the many end of the relationship, but there is no representation in the course table of any student data point.

Imho, this is where it is broken in addition to what Dan has pointed to.

assignment in dbms

Loved it – easy explanation. Thank you – love from India

assignment in dbms

Well done Ben, this is the best normalization tutorial I have ever seen. Thanks so much. keep up the good work.

assignment in dbms

Thanks for taking the time to create this. This is one of the best breakdowns that I’ve read regarding DB Normalization. However, I can’t really wrap my mind around 4NF as I would like to know how to use it in a real life scenario. Thanks again as this was extremely helpful to me!

assignment in dbms

Thank you . Very clear explanation

assignment in dbms

If the statement is true that each student can only have 1 course, then the relationship is not shown correctly in the ERD.

assignment in dbms

Hi, I don’t quite understand how your example satisfies third normal form. It seems that street address could depend on address ID, which depends upon the primary key. In other words, if address ID were to change, I would assume street address would also have to change. So doesn’t that create transitive dependency?

ii) I also don’t understand why you made two address tables, couldn’t they be combined into one?

assignment in dbms

Hi ben thanks for superb work.

What I always think that how to determine functional dependency? In this example , After 1NF, we know that course is not functionally dependent on student id because it is day to day example & it make sense.

however While designing DB for client whose domain is unknown to us, how to know effectively the functional dependency from client? What question we should ask as layman?

assignment in dbms

Thank you very much

assignment in dbms

This is my last stop to understanding data normalisation after two years of searching and searching. Thousands of tons of thanks Ben.

assignment in dbms

thanks so much sir have really enjoyed the class and gain alot

Leave a Comment Cancel Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed .

Guru99

Entity Relationship (ER) Diagram Model with DBMS Example

Richard Peterson

What is ER Diagram?

ER Diagram stands for Entity Relationship Diagram, also known as ERD is a diagram that displays the relationship of entity sets stored in a database. In other words, ER diagrams help to explain the logical structure of databases. ER diagrams are created based on three basic concepts: entities, attributes and relationships.

ER Diagrams contain different symbols that use rectangles to represent entities, ovals to define attributes and diamond shapes to represent relationships.

At first look, an ER diagram looks very similar to the flowchart. However, ER Diagram includes many specialized symbols, and its meanings make this model unique. The purpose of ER Diagram is to represent the entity framework infrastructure.

ER Diagram Examples

What is ER Model?

ER Model stands for Entity Relationship Model is a high-level conceptual data model diagram. ER model helps to systematically analyze data requirements to produce a well-designed database. The ER Model represents real-world entities and the relationships between them. Creating an ER Model in DBMS is considered as a best practice before implementing your database.

ER Modeling helps you to analyze data requirements systematically to produce a well-designed database. So, it is considered a best practice to complete ER modeling before implementing your database.

History of ER models

ER diagrams are visual tools that are helpful to represent the ER model. Peter Chen proposed ER Diagram in 1971 to create a uniform convention that can be used for relational databases and networks. He aimed to use an ER model as a conceptual modeling approach.

Why use ER Diagrams?

Here, are prime reasons for using the ER Diagram

  • Helps you to define terms related to entity relationship modeling
  • Provide a preview of how all your tables should connect, what fields are going to be on each table
  • Helps to describe entities, attributes, relationships
  • ER diagrams are translatable into relational tables which allows you to build databases quickly
  • ER diagrams can be used by database designers as a blueprint for implementing data in specific software applications
  • The database designer gains a better understanding of the information to be contained in the database with the help of ERP diagram
  • ERD Diagram allows you to communicate with the logical structure of the database to users

Facts about ER Diagram Model

Now in this ERD Diagram Tutorial, let’s check out some interesting facts about ER Diagram Model:

  • ER model allows you to draw Database Design
  • It is an easy to use graphical tool for modeling data
  • Widely used in Database Design
  • It is a GUI representation of the logical structure of a Database
  • It helps you to identifies the entities which exist in a system and the relationships between those entities

ER Diagrams Symbols & Notations

Entity Relationship Diagram Symbols & Notations mainly contains three basic symbols which are rectangle, oval and diamond to represent relationships between elements, entities and attributes. There are some sub-elements which are based on main elements in ERD Diagram. ER Diagram is a visual representation of data that describes how data is related to each other using different ERD Symbols and Notations.

Following are the main components and its symbols in ER Diagrams:

  • Rectangles: This Entity Relationship Diagram symbol represents entity types
  • Ellipses : Symbol represent attributes
  • Diamonds: This symbol represents relationship types
  • Lines: It links attributes to entity types and entity types with other relationship types
  • Primary key: attributes are underlined
  • Double Ellipses: Represent multi-valued attributes

ER Diagram Symbols & Notations

Components of the ER Diagram

This model is based on three basic concepts:

  • Relationships

ER Diagram Examples

For example, in a University database, we might have entities for Students, Courses, and Lecturers. Students entity can have attributes like Rollno, Name, and DeptID. They might have relationships with Courses and Lecturers.

Components of the ER Diagram

WHAT IS ENTITY?

A real-world thing either living or non-living that is easily recognizable and nonrecognizable. It is anything in the enterprise that is to be represented in our database. It may be a physical thing or simply a fact about the enterprise or an event that happens in the real world.

An entity can be place, person, object, event or a concept, which stores data in the database. The characteristics of entities are must have an attribute, and a unique key. Every entity is made up of some ‘attributes’ which represent that entity.

Examples of entities:

  • Person: Employee, Student, Patient
  • Place: Store, Building
  • Object: Machine, product, and Car
  • Event: Sale, Registration, Renewal
  • Concept: Account, Course

Notation of an Entity

An entity set is a group of similar kind of entities. It may contain entities with attribute sharing similar values. Entities are represented by their properties, which also called attributes. All attributes have their separate values. For example, a student entity may have a name, age, class, as attributes.

Entity

Example of Entities:

A university may have some departments. All these departments employ various lecturers and offer several programs.

Relationship

Relationship is nothing but an association among two or more entities. E.g., Tom works in the Chemistry department.

Relationship

Entities take part in relationships. We can often identify relationships with verbs or verb phrases.

For example:

  • You are attending this lecture
  • I am giving the lecture
  • Just loke entities, we can classify relationships according to relationship-types:
  • A student attends a lecture
  • A lecturer is giving a lecture.

Weak Entities

A weak entity is a type of entity which doesn’t have its key attribute. It can be identified uniquely by considering the primary key of another entity. For that, weak entity sets need to have participation.

Weak Entities

In above ER Diagram examples, “Trans No” is a discriminator within a group of transactions in an ATM.

Let’s learn more about a weak entity by comparing it with a Strong Entity

It is a single-valued property of either an entity-type or a relationship-type.

For example, a lecture might have attributes: time, date, duration, place, etc.

An attribute in ER Diagram examples, is represented by an Ellipse

Attributes

Cardinality

Defines the numerical attributes of the relationship between two entities or entity sets.

Different types of cardinal relationships are:

  • One-to-One Relationships
  • One-to-Many Relationships
  • May to One Relationships
  • Many-to-Many Relationships

Cardinality

1.One-to-one:

One entity from entity set X can be associated with at most one entity of entity set Y and vice versa.

Example: One student can register for numerous courses. However, all those courses have a single line back to that one student.

One-to-one Cardinality

2.One-to-many:

One entity from entity set X can be associated with multiple entities of entity set Y, but an entity from entity set Y can be associated with at least one entity.

For example, one class is consisting of multiple students.

One-to-many Cardinality

3. Many to One

More than one entity from entity set X can be associated with at most one entity of entity set Y. However, an entity from entity set Y may or may not be associated with more than one entity from entity set X.

For example, many students belong to the same class.

Many to One Cardinality

4. Many to Many:

One entity from X can be associated with more than one entity from Y and vice versa.

For example, Students as a group are associated with multiple faculty members, and faculty members can be associated with multiple students.

Many to Many Cardinality

How to Create an Entity Relationship Diagram (ERD)

Now in this ERD Diagram Tutorial, we will learn how to create an ER Diagram. Following are the steps to create an ER Diagram:

Create an Entity Relationship Diagram

Let’s study them with an Entity Relationship Diagram Example:

Step 1) Entity Identification

We have three entities

Entity Identification

Step 2) Relationship Identification

We have the following two relationships

  • The student is assigned a course
  • Professor delivers a course

Relationship Identification

Step 3) Cardinality Identification

For them problem statement we know that,

  • A student can be assigned multiple courses
  • A Professor can deliver only one course

Cardinality Identification

Step 4) Identify Attributes

You need to study the files, forms, reports, data currently maintained by the organization to identify attributes. You can also conduct interviews with various stakeholders to identify entities. Initially, it’s important to identify the attributes without mapping them to a particular entity.

Once, you have a list of Attributes, you need to map them to the identified entities. Ensure an attribute is to be paired with exactly one entity. If you think an attribute should belong to more than one entity, use a modifier to make it unique.

Once the mapping is done, identify the primary Keys. If a unique key is not readily available, create one.

Steps to Create an Entity Relationship Diagram

For Course Entity, attributes could be Duration, Credits, Assignments, etc. For the sake of ease we have considered just one attribute.

Step 5) Create the ERD Diagram

A more modern representation of Entity Relationship Diagram Example

Create the ERD Diagram

Best Practices for Developing Effective ER Diagrams

Here are some best practice or example for Developing Effective ER Diagrams.

  • Eliminate any redundant entities or relationships
  • You need to make sure that all your entities and relationships are properly labeled
  • There may be various valid approaches to an ER diagram. You need to make sure that the ER diagram supports all the data you need to store
  • You should assure that each entity only appears a single time in the ER diagram
  • Name every relationship, entity, and attribute are represented on your diagram
  • Never connect relationships to each other
  • You should use colors to highlight important portions of the ER diagram
  • ER Model in DBMS stands for an Entity-Relationship model
  • The ER model is a high-level data model diagram
  • ER diagrams are a visual tool which is helpful to represent the ER model
  • ER diagrams in DBMS are blueprint of a database
  • Entity relationship diagram DBMS displays the relationships of entity set stored in a database
  • ER diagrams help you to define terms related to entity relationship modeling
  • ER Model in DBMS is based on three basic concepts: Entities, Attributes & Relationships
  • An entity can be place, person, object, event or a concept, which stores data in the database (DBMS)
  • Relationship is nothing but an association among two or more entities
  • A weak entity is a type of entity which doesn’t have its key attribute
  • It is a single-valued property of either an entity-type or a relationship-type
  • It helps you to defines the numerical attributes of the relationship between two entities or entity sets
  • ER- Diagram DBMS is a visual representation of data that describe how data is related to each other
  • While Drawing ER diagrams in DBMS, you need to make sure all your entities and relationships are properly labeled.
  • Difference between Clustered and Non-clustered index
  • Difference Between DDL and DML in DBMS
  • Difference Between File System and DBMS
  • Difference Between Primary Key and Foreign Key
  • Row vs Column – Difference Between Them
  • DBMS Tutorial PDF: Database Management Systems
  • 10 BEST Database Management Software (DBMS) in 2024
  • 60+ DBMS Interview Questions and Answers

Dot Net Tutorials

Assignment Operator in SQL Server

Back to: SQL Server Tutorial For Beginners and Professionals

Assignment Operator in SQL Server with Examples

In this article, I am going to discuss Assignment Operator in SQL Server with Examples. Please read our previous article, where we discussed Clauses in SQL Server . Before understanding Assignment Operator in SQL Server, let us first understand what are operators and why we need operators, and what are the different types of operators available in SQL Server.

What is an Operator in SQL Server?

A n operator is a symbol that performs some specific operation on operands or expressions. These operators are classified as follows in SQL Server.

  • Assignment operator
  • Arithmetic operator
  • Comparison operator
  • Logical operator
  • Set operator

Note: In this article, I am going to discuss Assignment Operator,  rest of all other operators will discuss one by one from our upcoming articles.

Understanding the Assignment Operator in SQL Server:

Let us understand how to use the Assignment Operator in SQL Server with an example. We are going to use the following Employee table to understand the Assignment Operator.

Assignment Operator in SQL Server

Please use the below script to create and populate the Employee table with the required data.

Assignment operator:.

The assignment operator (=) in SQL Server is used to assign the values to a variable. The equal sign (=) is the only Transact-SQL assignment operator. In the following example, we create the @MyCounter variable, and then the assignment operator sets the @MyCounter variable to a value i.e. 1 .

DECLARE @MyCounter INT; SET @MyCounter = 1;

The assignment operator can also be used to establish the relationship between a column heading and the expression that defines the values for that column. The following example displays the column headings as FirstColumn and SecondColumn. The string ‘ abcd ‘ is displayed for all the rows in the FirstColumn column heading. Then, each Employee ID from the Employee table is listed in the SecondColumn column heading.

SELECT FirstColumn = ‘abcd’,  SecondColumn = ID  FROM Employee;

Compound Assignment Operators in SQL Server:

SQL SERVER 2008 has introduced a new concept of Compound Assignment Operators. The Compound Assignment Operators are available in many other programming languages for quite some time. Compound Assignment Operators are operated where variables are operated upon and assigned in the same line. Compound-assignment operators provide a shorter syntax for assigning the result of an arithmetic or bitwise operator. They perform the operation on the two operands before assigning the result to the first operand.

Example without using Compound Assignment Operators

The following example is without using Compound Assignment Operators.

Example using Compound Assignment Operators

The above example can be rewritten using Compound Assignment Operators as follows.

Following are the list of available compound operators in SQL Server

+= Adds some amount to the original value and sets the original value to the result. -= Subtracts some amount from the original value and sets the original value to the result. *= Multiplies by an amount and sets the original value to the result. /= Divides by an amount and sets the original value to the result. %= Divides by an amount and sets the original value to the modulo.

In the next article, I am going to discuss Arithmetic Operators in SQL Server. Here, in this article, I try to explain the Assignment Operator in SQL Server with Examples. I hope this article will help you with your needs. I would like to have your feedback. Please post your feedback, question, or comments about this article.

dotnettutorials 1280x720

About the Author: Pranaya Rout

Pranaya Rout has published more than 3,000 articles in his 11-year career. Pranaya Rout has very good experience with Microsoft Technologies, Including C#, VB, ASP.NET MVC, ASP.NET Web API, EF, EF Core, ADO.NET, LINQ, SQL Server, MYSQL, Oracle, ASP.NET Core, Cloud Computing, Microservices, Design Patterns and still learning new technologies.

1 thought on “Assignment Operator in SQL Server”

assignment in dbms

Operators in SQL Server covers almost all the important areas of SQL. This tutorial is very good.

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This browser is no longer supported.

Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.

= (Assignment Operator) (Transact-SQL)

  • 11 contributors

The equal sign (=) is the only Transact-SQL assignment operator. In the following example, the @MyCounter variable is created, and then the assignment operator sets @MyCounter to a value returned by an expression.

The assignment operator can also be used to establish the relationship between a column heading and the expression that defines the values for the column. The following example displays the column headings FirstColumnHeading and SecondColumnHeading . The string xyz is displayed in the FirstColumnHeading column heading for all rows. Then, each product ID from the Product table is listed in the SecondColumnHeading column heading.

Operators (Transact-SQL) Compound Operators (Transact-SQL) Expressions (Transact-SQL)

Was this page helpful?

Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see: https://aka.ms/ContentUserFeedback .

Submit and view feedback for

Additional resources

  • Engineering Mathematics
  • Discrete Mathematics
  • Operating System
  • Computer Networks
  • Digital Logic and Design
  • C Programming
  • Data Structures
  • Theory of Computation
  • Compiler Design
  • Computer Org and Architecture
  • DBMS Tutorial - Database Management System

Basic of DBMS

  • Introduction of DBMS (Database Management System) - Set 1
  • History of DBMS
  • Advantages of Database Management System
  • Disadvantages of DBMS
  • Application of DBMS
  • Need for DBMS
  • DBMS Architecture 1-level, 2-Level, 3-Level
  • Difference between File System and DBMS

Entity Relationship Model

  • Introduction of ER Model
  • Structural Constraints of Relationships in ER Model
  • Difference between entity, entity set and entity type
  • Difference between Strong and Weak Entity
  • Generalization, Specialization and Aggregation in ER Model
  • Recursive Relationships in ER diagrams

Relational Model

  • Introduction of Relational Model and Codd Rules in DBMS
  • Types of Keys in Relational Model (Candidate, Super, Primary, Alternate and Foreign)
  • Anomalies in Relational Model
  • Mapping from ER Model to Relational Model
  • Strategies for Schema design in DBMS

Relational Algebra

Introduction of relational algebra in dbms.

  • Basic Operators in Relational Algebra
  • Extended Operators in Relational Algebra
  • SQL | Join (Inner, Left, Right and Full Joins)
  • Join operation Vs Nested query in DBMS
  • Tuple Relational Calculus (TRC) in DBMS
  • Domain Relational Calculus in DBMS

Functional Dependencies

  • Functional Dependency and Attribute Closure
  • Armstrong's Axioms in Functional Dependency in DBMS
  • Equivalence of Functional Dependencies
  • Canonical Cover of Functional Dependencies in DBMS

Normalisation

  • Introduction of Database Normalization
  • Normal Forms in DBMS
  • First Normal Form (1NF)
  • Second Normal Form (2NF)
  • Boyce-Codd Normal Form (BCNF)
  • Introduction of 4th and 5th Normal Form in DBMS
  • The Problem of Redundancy in Database
  • Database Management System | Dependency Preserving Decomposition
  • Lossless Decomposition in DBMS
  • Lossless Join and Dependency Preserving Decomposition
  • Denormalization in Databases

Transactions and Concurrency Control

  • Concurrency Control in DBMS
  • ACID Properties in DBMS
  • Implementation of Locking in DBMS
  • Lock Based Concurrency Control Protocol in DBMS
  • Graph Based Concurrency Control Protocol in DBMS
  • Two Phase Locking Protocol
  • Multiple Granularity Locking in DBMS
  • Polygraph to check View Serializability in DBMS
  • Log based Recovery in DBMS
  • Timestamp based Concurrency Control
  • Dirty Read in SQL
  • Types of Schedules in DBMS
  • Conflict Serializability in DBMS
  • Condition of schedules to View-equivalent
  • Recoverability in DBMS
  • Precedence Graph for Testing Conflict Serializability in DBMS
  • Database Recovery Techniques in DBMS
  • Starvation in DBMS
  • Deadlock in DBMS
  • Types of Schedules based Recoverability in DBMS
  • Why recovery is needed in DBMS

Indexing, B and B+ trees

  • Indexing in Databases - Set 1
  • Introduction of B-Tree
  • Insert Operation in B-Tree
  • Delete Operation in B-Tree
  • Introduction of B+ Tree
  • Bitmap Indexing in DBMS
  • Inverted Index
  • Difference between Inverted Index and Forward Index
  • SQL Queries on Clustered and Non-Clustered Indexes

File organization

  • File Organization in DBMS - Set 1
  • File Organization in DBMS | Set 2
  • File Organization in DBMS | Set 3

DBMS Interview questions and Last minute notes

  • Last Minute Notes - DBMS
  • Commonly asked DBMS interview questions
  • Commonly asked DBMS interview questions | Set 2

DBMS GATE Previous Year Questions

  • Database Management System - GATE CSE Previous Year Questions
  • Database Management Systems | Set 2
  • Database Management Systems | Set 3
  • Database Management Systems | Set 4
  • Database Management Systems | Set 5
  • Database Management Systems | Set 6
  • Database Management Systems | Set 7
  • Database Management Systems | Set 8

Pre-Requisite: Relational Model in DBMS

Relational Algebra is a procedural query language. Relational algebra mainly provides a theoretical foundation for relational databases and SQL . The main purpose of using Relational Algebra is to define operators that transform one or more input relations into an output relation. Given that these operators accept relations as input and produce relations as output, they can be combined and used to express potentially complex queries that transform potentially many input relations (whose data are stored in the database) into a single output relation (the query results). As it is pure mathematics, there is no use of English Keywords in Relational Algebra and operators are represented using symbols.

Fundamental Operators

These are the basic/fundamental operators used in Relational Algebra.

  • Selection(σ)
  • Projection(π)
  • Set Difference(-)
  • Set Intersection(∩)
  • Cartesian Product(X)

1. Selection(σ): It is used to select required tuples of the relations.

For the above relation, σ(c>3)R  will select the tuples which have c more than 3.

Note: The selection operator only selects the required tuples but does not display them. For display, the data projection operator is used. 

2. Projection(π): It is used to project required column data from a relation. 

Example: Consider Table 1. Suppose we want columns B and C from Relation R.

Note: By Default, projection removes duplicate data.   

3. Union(U): Union operation in relational algebra is the same as union operation in set theory .

                                                                                                                          FRENCH

                                                                                                                           GERMAN

Consider the following table of Students having different optional subjects in their course.

Note: The only constraint in the union of two relations is that both relations must have the same set of Attributes.   

4. Set Difference(-): Set Difference in relational algebra is the same set difference operation as in set theory.

Example: From the above table of FRENCH and GERMAN, Set Difference is used as follows

Note: The only constraint in the Set Difference between two relations is that both relations must have the same set of Attributes.   

5. Set Intersection(∩): Set Intersection in relational algebra is the same set intersection operation in set theory.

Example: From the above table of FRENCH and GERMAN, the Set Intersection is used as follows

Note: The only constraint in the Set Difference between two relations is that both relations must have the same set of Attributes.  

6. Rename(ρ):  Rename is a unary operation used for renaming attributes of a relation.

7. Cross Product(X): Cross-product between two relations. Let’s say A and B, so the cross product between A X B will result in all the attributes of A followed by each attribute of B. Each record of A will pair with every record of B.

Example: 

                                                                                                                                    A

                                                                                                                             B

                                                                                                                             A X B

Note: If A has ‘n’ tuples and B has ‘m’ tuples then A X B will have ‘ n*m ‘ tuples.   

Derived Operators

These are some of the derived operators , which are derived from the fundamental operators.

  • Natural Join(⋈)
  • Conditional Join

1. Natural Join(⋈): Natural join is a binary operator. Natural join between two or more relations will result in a set of all combinations of tuples where they have an equal common attribute. 

                                                                                                                        EMP

                                                                                                                   DEPT

Natural join between EMP and DEPT with condition :

EMP.Dept_Name = DEPT.Dept_Name           

                                                                                                    EMP ⋈ DEPT

2. Conditional Join: Conditional join works similarly to natural join. In natural join, by default condition is equal between common attributes while in conditional join we can specify any condition such as greater than, less than, or not equal. 

                                                                                                                                R

                                                                                                                               S

Join between R and S with condition   R.marks >= S.marks

Relational Calculus

As Relational Algebra is a procedural query language, Relational Calculus is a non-procedural query language. It basically deals with the end results. It always tells me what to do but never tells me how to do it.

There are two types of Relational Calculus

  • Tuple Relational Calculus(TRC)
  • Domain Relational Calculus(DRC)

In-depth articles:  Basic-operators-in-relational-algebra                                            Extended Relational Algebra Operators  

Following are the Previous Year’s Gate Questions  https://www.geeksforgeeks.org/gate-gate-cs-2012-question-50/   https://www.geeksforgeeks.org/gate-gate-cs-2012-question-43/  

Please Login to comment...

Similar reads.

  • DBMS-Relational Algebra

advertisewithusBannerImg

Improve your Coding Skills with Practice

 alt=

What kind of Experience do you want to share?

Javatpoint Logo

  • Interview Q

DBMS Tutorial

Data modeling, relational data model, normalization, transaction processing, concurrency control, file organization, indexing and b+ tree, sql introduction.

Interview Questions

JavaTpoint

1. INNER JOIN

In SQL, INNER JOIN selects records that have matching values in both tables as long as the condition is satisfied. It returns the combination of all rows from both the tables where the condition satisfies.

2. LEFT JOIN

The SQL left join returns all the values from left table and the matching values from the right table. If there is no matching join value, it will return NULL.

3. RIGHT JOIN

In SQL, RIGHT JOIN returns all the values from the values from the rows of right table and the matched values from the left table. If there is no matching in both tables, it will return NULL.

4. FULL JOIN

In SQL, FULL JOIN is the result of a combination of both left and right outer join. Join tables have all the records from both tables. It puts NULL on the place of matches not found.

Youtube

  • Send your Feedback to [email protected]

Help Others, Please Share

facebook

Learn Latest Tutorials

Splunk tutorial

Transact-SQL

Tumblr tutorial

Reinforcement Learning

R Programming tutorial

R Programming

RxJS tutorial

React Native

Python Design Patterns

Python Design Patterns

Python Pillow tutorial

Python Pillow

Python Turtle tutorial

Python Turtle

Keras tutorial

Preparation

Aptitude

Verbal Ability

Interview Questions

Company Questions

Trending Technologies

Artificial Intelligence

Artificial Intelligence

AWS Tutorial

Cloud Computing

Hadoop tutorial

Data Science

Angular 7 Tutorial

Machine Learning

DevOps Tutorial

B.Tech / MCA

DBMS tutorial

Data Structures

DAA tutorial

Operating System

Computer Network tutorial

Computer Network

Compiler Design tutorial

Compiler Design

Computer Organization and Architecture

Computer Organization

Discrete Mathematics Tutorial

Discrete Mathematics

Ethical Hacking

Ethical Hacking

Computer Graphics Tutorial

Computer Graphics

Software Engineering

Software Engineering

html tutorial

Web Technology

Cyber Security tutorial

Cyber Security

Automata Tutorial

C Programming

C++ tutorial

Control System

Data Mining Tutorial

Data Mining

Data Warehouse Tutorial

Data Warehouse

RSS Feed

Notesformsc

DBMS Lab Assignment Questions

These are DBMS Lab Assignment Questions for practice RDBMS in a lab environment and all queries were tested using Oracle 10g. The Queries may not give you expected result if you implement them on any other DBMS setup without necessary modifications.

Q1: Consider the following relational schema for the Office of the Controller of Examinations Application.

Student ( Rollno , Name, Dob, Gender, Doa, Bcode );

Implement a check constraint for

  • Date of Admission

Branch ( Bcode , Bname, Dno );

Department ( Dno , Dname );

Course ( Ccode , Cname, Credits, Dno );

Branch_Course ( Bcode , Ccode , Semester );

Enrolls ( Rollno , Ccode , Sess , Grade );

For Example,

SESS can take values ‘APRIL 2013’, ‘NOV 2013’

Implement a check constraint for grade Value Set (‘S’, ‘A’, ‘B’, ‘C’, ‘D’, ‘E’, ‘U’ );

Students are admitted to Branches and they are offered by Departments. A branch is offered by only one department.

Each branch has a set of Courses (Subjects). Each student must enroll during a semester. Courses are offered by Departments. A course is offered only by one department. If a student is unsuccessful in a course he/she must enroll for the course during next session. A student has successfully completed a course if the grade obtained by is from the list (A, B, C, D, and E).

A student is unsuccessful if he/she have grade ‘U’ in a course.

Primary Keys are underlined.

These are questions for assignment 1. The solution is available after the last question.

Question (A)

Develop a SQL query to list details of Departments that offer more than 3 branches.

Question (B)

Develop a SQL query to list the details of Departments that offer more than 6 courses.

Question (C)

Develop a SQL query to list the details of courses that are common for more than 3 branches.

Question (D)

Develop a SQL query to list students who got ‘S’ in more than 2 courses during single enrollment.

Question (E)

Create a view that will keep track of the roll number, name and number of courses, a student has completed successfully.

Q2: Consider the following relations for an Order Processing Database application in a Company.

Customer ( Customerno varchar2 (5), Cname varchar2 (50) );

Implement check constraints to check Customerno starts with ‘C’ .

Cust_Order ( Orderno varchar2(5), Odate Date, Customerno references Customer, Ord_amt number(8) );

Implement check constraints to check Orderno starts with ‘ O ’.

Ord_amt is derived attribute (default value is 0);

Item ( Itemno varchar2 (5), Item_name varchar2 (30), unit_price number (5) );

Implement check constraint to check Itemno starts with ‘I’ .

Order_item ( Orderno references Cust_order, Itemno references item, qty number (3) );

Primary Key is underlined.

These are questions for assignment 2. The solution is available after the last question.

Develop DDL to implement above schema enforcing primary key, check constraints and foreign key constraints.

Populate Database with rich data set.

Develop SQL query to list the details of customers who have placed more than 3 orders.

Develop a SQL query to list details of items whose price is less than the average price of all items in each order.

Develop a SQL query to list the orderno and number of items in each order.

Question (F)

Develop a SQL query to list the details of items that are present in 25% of the orders.

Question (G)

Develop an update statement to update the value of Ord_amt.

Question (H)

Create a view that keeps track of detail of each customer and number of Order placed.

Q3: Consider the following relational schema

Staff ( Staffno number (5), Name varchar2 (30), Dob Date, Gender Char (2), Doj Date, Designation varchar2 (30), Basic_pay number (6), Deptno varchar2 (5) );

Gender must take value ‘M ’ or ‘F’.

Dept ( Deptno varchar2 (5), Name varchar2 (30) );

Skill ( Skill_code varchar2 (5), Description varchar2 (30), Charge_Outrage number (3) );

Staff_skill ( Staffno number (5), Skill_code varchar2 (5) );

Project ( Projectno varchar2 (5), Pname varchar2 (5), Start_Date Date, End_Date Date, Project_Manager_Staffno number (5) );

Project Number must start with ‘ P’.

Works ( Staffno number (5), Projectno varchar2 (5), Date_Worked_On Date, Intime Timestamp, Outtime Timestamp );

These are questions for assignment 3. The solution is available after the last question.

Develop DDL to implement the above schema specifying appropriate data types for each attributes and enforcing primary key, check constraints and foreign key constraints.

Populate the database with rich data set.

Develop a SQL query to list the departmentno and number of staff in each department,

Develop a SQL query to list the details of staff who earn the AVG basic pay of all staff.

Develop a SQL query to list the details of staff who have more than 3 skills.

Develop a SQL query to list the details of staff who have skills with a charge outrate greater than 60 per hour.

Create a view that will keep track of the department number, department name, the number of employees in the department and total basic pay expenditure for the department.

Develop a SQL query to list the details of Depts which has more than 5 staff working in it.

Question (I)

Q4: Consider the following relational schema for a banking database application.

Customer ( Cid , Cname );

Branch ( Bcode , Bname );

Account ( Ano , Atype, Balance, Cid, Bcode );

An account can be a saving account or a current account. Check Atype in ‘S’ or ‘C’. A customer can have both types of accounts.

Transaction ( Tid , Ano , Tttype, Tdate, Tamount );

Ttype can be ‘D’ or ‘W’.

D – Deposit, W – Withdrawal

These are questions for assignment 4. The solution is available after the last question.

Develop DDL to implement the above schema specifying an appropriate data type for each attribute enforcing primary key, check constraints and foreign key constraints.

Populate the database with a rich data set.

Develop a SQL query to list the details of customers who have a saving account and a current account.

Develop a SQL query to list the details of branches and the number of accounts in each branch.

Develop a SQL query to list the details of branches where the number of accounts is less than the average number of accounts in all branches.

Develop a SQL query to list the details of customers who have performed three transaction on a day.

Create a view that will keep track of branch details and the number of accounts in each branch.

Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

IMAGES

  1. How To Draw Er Diagram In Dbms With Examples

    assignment in dbms

  2. Er Diagram Examples With Solutions In Dbms

    assignment in dbms

  3. Er Diagram Examples With Solutions In Dbms

    assignment in dbms

  4. Week 7 NPTEL Assignment Solutions/Answers || Database Management Systems (DBMS),March,2020

    assignment in dbms

  5. DBMS Assignment

    assignment in dbms

  6. NPTEL DBMS assignment solution week 8 || NPTEL DBMS Quiz assignment

    assignment in dbms

VIDEO

  1. DBMS

  2. DBMS video assignment

  3. NPTEL DBMS Week 3 assignment explanation

  4. DBMS Assignment Indexing & Aggregation

  5. DBMS video assignment 2

  6. IITM DBMS GRADED ASSIGNMENT WEEK 4 PART 1

COMMENTS

  1. Introduction to Relational Databases (RDBMS)

    Module 3 • 3 hours to complete. In this module, you will learn about the fundamental aspects of MySQL and PostgreSQL and identify Relational Database Management System (RDBMS) tools. You will explore the process of creating databases and tables and the definition of keys, constraints, and connections in MySQL.

  2. DBMS Tutorial

    A Database Management System is software or technology used to manage data from a database. DBMS provides many operations e.g. creating a database, storing in the database, updating an existing database, delete from the database. DBMS is a system that enables you to store, modify and retrieve data in an organized way. It also provides security to the database.

  3. SQL Exercises, Practice, Solution

    SQL stands for Structured Query Language and it is an ANSI standard computer language for accessing and manipulating database systems. It is used for managing data in relational database management system which stores data in the form of tables and relationship between data is also stored in the form of tables. SQL statements are used to ...

  4. Computer Science 303

    This assignment helps students explore database systems and how to manage them. Practice setting up a database, and complete a project to gain understanding of database management. Updated: 01/10/2024

  5. Database Management Systems and SQL

    Database Management Systems and SQL are two of the most important and widely used tools on the internet today. You use a Database Management System (DBMS) to store the data you collect from various sources, and SQL to manipulate and access the particular data you want in an efficient way. Many different businesses use these tools to increase ...

  6. Assignments

    Assignments. This section contains problem sets, labs, and a description of the final project. Some assignments require access to online development tools and environments that may not be freely available to OCW users. The assignments are included here as examples of the work MIT students were expected to complete.

  7. Mastering Database Assignments: Your Comprehensive Guide

    Navigating the intricate realm of database assignments demands a meticulous understanding of potential challenges and the adept application of optimization strategies. Beyond merely identifying schema errors and performance bottlenecks, this section of the guide immerses you in a deeper exploration of solutions that go beyond the conventional.

  8. Introduction of DBMS (Database Management System)

    A Database Management System (DBMS) is a software system that is designed to manage and organize data in a structured manner. It allows users to create, modify, and query a database, as well as manage the security and access controls for that database. DBMS provides an environment to store and retrieve the data in coinvent and efficient manner.

  9. Navigating the Database Landscape of Your DBMS Assignment ...

    Database Optimization: Optimizing databases is always a DBMS assignment task, and certain occupations focus on improving it. This involves examining and optimizing searches, processing plans, and ...

  10. Mastering Database Assignments: Best Practices for Success and

    In the intricate landscape of database management assignments, the first crucial step towards success lies in a comprehensive understanding of the assignment requirements. This initial phase serves as the cornerstone for the entire process, requiring students to refrain from hastily plunging into the technical intricacies without a clear grasp ...

  11. DBMS

    DBMS - Assignment Operation in Relational AlgebraWatch more Videos at https://www.tutorialspoint.com/videotutorials/index.htmLecture By: Mr. Arnab Chakrabort...

  12. A Step-By-Step Guide to Normalization in DBMS With Examples

    Database normalisation, or just normalisation as it's commonly called, is a process used for data modelling or database creation, where you organise your data and tables so it can be added and updated efficiently. It's something a person does manually, as opposed to a system or a tool doing it. It's commonly done by database developers ...

  13. Relational Algebra in DBMS: Operations with Examples

    Select operator selects tuples that satisfy a given predicate. σ p (r) σ is the predicate. r stands for relation which is the name of the table. p is prepositional logic. Example 1. σ topic = "Database" (Tutorials) Output - Selects tuples from Tutorials where topic = 'Database'. Example 2.

  14. Data Models in DBMS

    A Data Model in Database Management System (DBMS) is the concept of tools that are developed to summarize the description of the database. Data Models provide us with a transparent picture of data which helps us in creating an actual database. It shows us from the design of the data to its proper implementation of data.

  15. Entity Relationship (ER) Diagram Model with DBMS Example

    Summary. ER Model in DBMS stands for an Entity-Relationship model. The ER model is a high-level data model diagram. ER diagrams are a visual tool which is helpful to represent the ER model. ER diagrams in DBMS are blueprint of a database. Entity relationship diagram DBMS displays the relationships of entity set stored in a database.

  16. Assignment Operator in SQL Server

    The assignment operator (=) in SQL Server is used to assign the values to a variable. The equal sign (=) is the only Transact-SQL assignment operator. In the following example, we create the @MyCounter variable, and then the assignment operator sets the @MyCounter variable to a value i.e. 1. The assignment operator can also be used to establish ...

  17. = (Assignment Operator) (Transact-SQL)

    In this article. Applies to: SQL Server Azure SQL Database Azure SQL Managed Instance Azure Synapse Analytics Analytics Platform System (PDW) SQL analytics endpoint in Microsoft Fabric Warehouse in Microsoft Fabric The equal sign (=) is the only Transact-SQL assignment operator. In the following example, the @MyCounter variable is created, and then the assignment operator sets @MyCounter to a ...

  18. DBMS Relational Algebra

    Types of Relational operation. 1. Select Operation: The select operation selects tuples that satisfy a given predicate. It is denoted by sigma (σ). p is used as a propositional logic formula which may use connectors like: AND OR and NOT. These relational can use as relational operators like =, ≠, ≥, <, >, ≤. 2.

  19. Database Management System Week 5 Assignment 5 Solution

    🎉 Welcome to Harsha's CodeLab, your hub for Database Management System solutions! If you're diving into the NPTEL course on DBMS, you've come to the right p...

  20. Introduction of Relational Algebra in DBMS

    Pre-Requisite: Relational Model in DBMS Relational Algebra is a procedural query language. Relational algebra mainly provides a theoretical foundation for relational databases and SQL.The main purpose of using Relational Algebra is to define operators that transform one or more input relations into an output relation.

  21. DBMS SQL Joins

    DBMS SQL Joins with DBMS Overview, DBMS vs Files System, DBMS Architecture, Three schema Architecture, DBMS Language, DBMS Keys, DBMS Generalization, DBMS Specialization, Relational Model concept, SQL Introduction, Advantage of SQL, DBMS Normalization, Functional Dependency, DBMS Schedule, Concurrency Control etc.

  22. Assignment Operator in Relational Algebra

    #AssignmentOperator #RelationalAlgebra #DBMS #ShanuKuttanThis video explains Assignment Operator in Relational Algebra, Assignment Operation in Relational Al...

  23. DBMS Lab Assignment Questions

    These are DBMS Lab Assignment Questions for practice RDBMS in a lab environment and all queries were tested using Oracle 10g. The Queries may not give you expected result if you implement them on any other DBMS setup without necessary modifications. Advertisements. Q1: Consider the following relational schema for the Office of the Controller of ...