OOP and SQL Concepts
Document Details

Uploaded by UnconditionalChalcedony261
2002
Tags
Summary
This document covers Object-Oriented Programming (OOP) principles in C# and SQL concepts, including relational databases, Structured Query Language (SQL), and database management system (DBMS). It explores class structures, access modifiers, and database design, with an overview of techniques such as ER modeling and normalization. This content is for those learning programming and database concepts.
Full Transcript
**OOP** **C\#** It is an object-oriented programming language created by Microsoft that runs on the.NET Framework. C\# has roots from the C family, and the language is close to other popular languages like C++ and Java. The first version was released **in 2002**. The **.NET framework** helps you...
**OOP** **C\#** It is an object-oriented programming language created by Microsoft that runs on the.NET Framework. C\# has roots from the C family, and the language is close to other popular languages like C++ and Java. The first version was released **in 2002**. The **.NET framework** helps you build web apps, desktop apps, and web services. **.NET** core is for creating cross-platform cloud apps that run on Windows, Mac, and Linux. The **MAIN METHOD** is the entry point of a C\# application. **Namespaces** are used in C\# to organize and provide a level of separation of codes. **Console.WriteLine**(\"Creating my namespace\"); **Constants** are immutable values which are known at compile time and do not change for the life of the program. Use **PascalCase** for class names and method names. Use **camelCase** for method parameters and local variables. Use **PascalCase** for constant names, both fields and local constants. **Coding Principles** - - - - - **Console.ReadLine()**; USE TO READ USER OUTPUT **object-oriented programming** is about creating objects that contain both data and methods. A **class** is a template for objects, and an object is an instance of a class. Fields and methods inside classes are often referred to as \"**Class Members**\": When the individual objects are created, they inherit all the variables and methods from the class. Variables inside a class are called **FIELDS** **Access Modifiers** are keywords that define the accessibility of a member, class or datatype in a program. **Public** The code is accessible for all classes **Private** The code is only accessible within the same class **Protected** The code is accessible within the same class, or in a class that is inherited from that class. **Internal** The code is only accessible within its own assembly, but not from another assembly. A **Method** is a function inside our Class that contains a series of statements. A **Property** in C\# is a member of a class that is used to set and get the data from a data field (i.e. variable) of a class. The **Accessors** are nothing but special methods which are used to set and get the values from the underlying data member (i.e. variable) of a class. This **set** accessor contains a fixed variable named value. A **constructor** is a special method that is used to initialize objects. **Encapsulation** is defined as the wrapping up of data and information under a single unit. **Advantages of Encapsulation** - - - - **PUBLIC** keyword It is called an access modifier, which specifies that the color variable/field of Car is accessible for other classes as well, such as Program. **DBMS** **Advantages of Using DBMS** - - - - **MS SQL Server** is a relational database management system (RDBMS) developed by Microsoft. **Relationships** in SQL tables define how tables are connected to one another. **Structured Query Language** is a standardized programming language used to manage and manipulate relational databases. The **WHERE** clause in SQL is used to filter records and specify the conditions that must be met for a query The **ORDER BY** clause in SQL is used to sort the result set of a query by one or more columns The **DISTINCT** keyword in SQL is used to remove duplicate values from the result set Returns the number of rows that match a specified condition The **SUM** calculates the total sum of a numeric column. **MAX**: Returns the maximum value from a numeric column. **MIN**: Returns the minimum value from a numeric column. The **GROUP BY** clause in SQL is used to group rows that have the same values in specified columns into summary rows The **HAVING** clause in SQL is used to filter the results after GROUP BY has been applied, similar to how the WHERE clause A **correlated subquery** is a subquery in SQL that refers to values from the outer query. **Full-Text Search** is a database technique which will retrieve records A **JOIN** is used in SQL to combine rows from two or more tables based on a related column. **Right Joints** select all the columns in the Right table and only the matching records from the left table The **UNION** operation combines the results of two queries and removes duplicate rows from the final output. The **INTERSECT** operation returns only the rows that are present in both queries (common values). The **EXCEPT** operation returns rows from the first query that are NOT in the second query. **core principles** 1\. Data Integrity 2\. Avoiding Redundancy 3\. Normalization 4\. Entity Relationships 5\. Use of Constraints 6\. Scalability and Performance **Entity relationship (ER) Modeling** A visual approach of representing the structure of a database by identifying and defining the different entities (objects or concepts) within the data and how they are related to each other through relationships. **Entity Relationship Cardinality (ERD)** This defines the number of instances of one entity that can be linked to the number of instances of another entity. A **FOREIGN KEY** (FK) is a column or combination of columns that is used to establish and enforce a link between the data in two tables **Constraints** are used to limit the type of data that can go into a table. **Normalization** - is the process of organizing data within tables in a specific manner to organize data efficiently. **Denormalization** - is also the method which is used in a database. It is a technique in which data are combined to execute the query quickly. **Main goal of normalization is**: - - - **Relational database design principles** are guidelines for organizing data in tables to ensure data integrity and efficiency. **Relational Database Design Principles** - Ensure accuracy and consistency (e.g., primary key uniqueness). - Store data once and reference it. - Optimize for efficient queries and updates. - Use ER diagrams to represent relationships clearly. - Apply rules to structure data to reduce redundancy.