Difference Between Strong and Weak Entity

AmitDiwan
Updated on 15-Apr-2021 07:40:52

357 Views

In this post, we will understand the difference between strong entity and weak entity −Strong EntityIt has primary key.It doesn’t depend on any other entity.It can be represented using a single rectangle.The relationship between two strong entities can be represented using a single diamond.It can either have total participation or no participation.Weak EntityA weak entity has a partial discriminator key.It depends on the strong entity.It can be represented using a double rectangle.The relationship between a strong and a weak entity can be represented using a double diamond.They always have total participation.Read More

Difference Between View and Materialized View

AmitDiwan
Updated on 15-Apr-2021 07:37:31

2K+ Views

In this post, we will understand the difference between a view and a materialized view.ViewsIt is a logical and virtual copy of a table that is created by executing a ‘select query’ statement.This result isn’t stored anywhere on the disk.Hence, every time, a query needs to be executed when certain data is needed.This way, the most recently updated data would be available from the tables.The tuple/result of the query doesn’t get stored.Instead, the query expression is stored on the disk.The query expression is stored, due to which the last updated data is obtained.They don’t have a storage/update cost associated with ... Read More

Difference Between Star and Snowflake Schema

AmitDiwan
Updated on 15-Apr-2021 07:35:33

375 Views

In this post, we will understand the difference between star schema and snowflake schema.Star SchemaHierarchies of dimensions are stored in a dimensional table.It contains a fact table that is surrounded by dimension tables.In this schema, a single join creates the relationship between a fact table and any dimension tables.It is a simple database design.It has high levels of data redundancy.The processing of cube is quick.A single dimension table contains the aggregated data.It is a de-normalized data structure.The queries run quickly in comparison to other schema.It uses start join query optimization technique. Hence, the queries perform well.Tables can be connected with ... Read More

Select Nth Smallest Element from a List in Python

AmitDiwan
Updated on 14-Apr-2021 14:19:28

474 Views

When it is required to select the nth smallest element from a list in linear time complexity, two methods are required. One method to find the smallest element, and another method that divides the list into two parts. This division depends on the ‘i’ value that is given by user. Based on this value, the list is split, and the smallest element is determined.Below is a demonstration of the same −Example Live Demodef select_smallest(my_list, beg, end, i):    if end - beg k:       return select_smallest(my_list, pivot_val + 1, end, i - k)    return my_list[pivot_val] ... Read More

Sort Tuples by Total Digits in Python

AmitDiwan
Updated on 14-Apr-2021 14:17:14

471 Views

When it is required to sort the element in a list of tuple based on the digits, the ‘sorted’ method and the lambda function can be used.Below is a demonstration for the same −Example Live Demomy_list = [(11, 23, 45, 678), (34, 67), (653, ), (78, 99, 23, 45), (67, 43)] print("The list is : ") print(my_list) my_result = sorted(my_list, key = lambda tup : sum([len(str(ele)) for ele in tup ])) print("The sorted tuples are ") print(my_result)OutputThe list is : [(11, 23, 45, 678), (34, 67), (653, ), (78, 99, 23, 45), (67, 43)] The sorted tuples are ... Read More

Check String is Palindrome Using Stack in Python

AmitDiwan
Updated on 14-Apr-2021 14:16:04

965 Views

When it is required to check if a string is a palindrome using stack data structure, a stack class is created, and push and pop methods are defined to add and delete values from stack. Another method checks to see if the stack is empty or not.Below is a demonstration for the same −Example Live Democlass Stack_structure:    def __init__(self):       self.items = []    def check_empty(self):       return self.items == []    def push_val(self, data):       self.items.append(data)    def pop_val(self):       return self.items.pop() my_instance = Stack_structure() text_input = ... Read More

Print Nth Node from the Last of a Linked List in Python

AmitDiwan
Updated on 14-Apr-2021 14:11:01

305 Views

When it is required to print the specific node from the end of a linked list, the methods ‘list_length’ and ‘return_from_end’ methods are defined. The ‘list_length’ reutrns the length of the linked list.The ‘return_from_end’ method is used to return the nth element from the end of the linked list.Below is a demonstration for the same −Example Live Democlass Node:    def __init__(self, data):       self.data = data       self.next = None class LinkedList_structure:    def __init__(self):       self.head = None       self.last_node = None    def add_vals(self, data):       ... Read More

Print Middle Most Node of a Linked List in Python

AmitDiwan
Updated on 14-Apr-2021 14:07:43

234 Views

When it is required to print the middle most element of a linked list, a method named ‘print_middle_val’ is defined. This method takes the linked list as a parameter and gets the middle most element.Below is a demonstration for the same −Example Live Democlass Node:    def __init__(self, data):       self.data = data       self.next = None class LinkedList_structure:    def __init__(self):       self.head = None       self.last_node = None    def add_vals(self, data):       if self.last_node is None:          self.head = Node(data)       ... Read More

Reverse First N Elements of a Linked List in Python

AmitDiwan
Updated on 14-Apr-2021 14:04:07

214 Views

When it is required to reverse a specific set of elements in a linked list, a method named ‘reverse_list’ is defined. This iterates through the list, and reverses the specific set of elements.Below is a demonstration for the same −Example Live Democlass Node:    def __init__(self, data):       self.data = data       self.next = None class LinkedList_structure:    def __init__(self):       self.head = None       self.last_node = None    def add_vals(self, data):       if self.last_node is None:          self.head = Node(data)          self.last_node ... Read More

Find Number of Occurrences of All Elements in a Linked List using Python

AmitDiwan
Updated on 14-Apr-2021 14:00:12

176 Views

When it is required to find the number of occurences of all the elements of a linked list, a method to add elements to the linked list, a method to print the elements and a method to find the occurrence of all elements in the linked list are defined.Below is a demonstration for the same −Example Live Democlass Node:    def __init__(self, data):       self.data = data       self.next = None class LinkedList_structure:    def __init__(self):       self.head = None       self.last_node = None    def add_vals(self, data):       ... Read More

Advertisements