Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
190211b
add not equal operator
HelenPolychroni Dec 29, 2022
4a1052a
add NOT operator
HelenPolychroni Dec 29, 2022
530a02f
Change misc file
HelenPolychroni Dec 29, 2022
2c4dada
try
DeppieK Dec 29, 2022
77f5ed7
Merge branch 'branchDK' of https://github.com/HelenPolychroni/miniDB …
DeppieK Dec 29, 2022
ad20aa3
change regarding BETWEEN stmt
DeppieK Dec 29, 2022
1e02ed9
not operator
HelenPolychroni Jan 2, 2023
d2f1c38
operator
HelenPolychroni Jan 2, 2023
c0167af
not operator
HelenPolychroni Jan 2, 2023
38d923b
still working on between stmt
DeppieK Jan 4, 2023
b554318
between...
DeppieK Jan 4, 2023
21834b1
between operator implementation
DeppieK Jan 15, 2023
a6a99f3
or and not op
HelenPolychroni Jan 16, 2023
e310925
and and or op
HelenPolychroni Jan 16, 2023
c330351
not and or
HelenPolychroni Jan 16, 2023
c35fdad
not op
HelenPolychroni Jan 16, 2023
196af6e
.
HelenPolychroni Jan 16, 2023
2f688ce
.
HelenPolychroni Jan 16, 2023
d62a1af
.
HelenPolychroni Jan 16, 2023
d0af9f0
.
HelenPolychroni Jan 17, 2023
dae085a
Add not and and functionality
HelenPolychroni Jan 28, 2023
0c0578a
Add not and and functionality
HelenPolychroni Jan 28, 2023
3328d1f
Add and functionality
HelenPolychroni Jan 29, 2023
4affeb3
Add and functionality
HelenPolychroni Jan 29, 2023
0c33de4
Add and functionality in update
HelenPolychroni Jan 29, 2023
1410415
Finish and in select function
HelenPolychroni Jan 29, 2023
d8e4207
Add complex AND and OR functionality
HelenPolychroni Feb 2, 2023
e1bf7e3
Add complex AND and OR functionality
HelenPolychroni Feb 2, 2023
6695ea9
add complex AND and OR functionality in delete
HelenPolychroni Feb 2, 2023
e2f4d74
add AND and OR functionality in delete
HelenPolychroni Feb 2, 2023
bd5e3d8
.
HelenPolychroni Feb 2, 2023
6a0cade
.
HelenPolychroni Feb 2, 2023
2772fda
.
HelenPolychroni Feb 2, 2023
5815a21
complete AND and OR functionality in DELETE, UPDATE, SELECT
HelenPolychroni Feb 2, 2023
a3fd054
changes on between stmt
DeppieK Feb 2, 2023
8ccca49
changes on between stmt
DeppieK Feb 2, 2023
ff734d5
chech some things for issue #2
HelenPolychroni Feb 3, 2023
4a653ba
check some things for issue no 2
HelenPolychroni Feb 3, 2023
79e1bf7
Merge branch 'master' of https://github.com/HelenPolychroni/miniDB
HelenPolychroni Feb 3, 2023
c028329
fix some things
HelenPolychroni Feb 3, 2023
dce7576
add 'unique' in columns
HelenPolychroni Feb 3, 2023
0d529ee
set the unique attribute for issue no 2
HelenPolychroni Feb 5, 2023
032470c
handle unique for btree indexing...
HelenPolychroni Feb 7, 2023
614b3e1
fix some thing for unique in btree indexing
HelenPolychroni Feb 7, 2023
a5c9129
Print some messages to see the tree's data
HelenPolychroni Feb 9, 2023
e22235c
Add keyword unique to some columns to handle btree index over unique …
HelenPolychroni Feb 9, 2023
1f424fc
Fix some issues and handle btree index in conditions
HelenPolychroni Feb 9, 2023
53ba666
Handle select where with btree
HelenPolychroni Feb 9, 2023
3d3ac04
Remove some unnecessary print messages for table's data
HelenPolychroni Feb 10, 2023
beccf8f
Fix some things for btree index in select condition
HelenPolychroni Feb 10, 2023
15cec4a
Almost finish with select where with btree
HelenPolychroni Feb 10, 2023
ef09672
fix some things
HelenPolychroni Feb 10, 2023
d5d8cb1
implement hash index
HelenPolychroni Feb 11, 2023
2f9a368
fix some things
HelenPolychroni Feb 11, 2023
da47f0e
handle hash index
HelenPolychroni Feb 11, 2023
b317851
Remove some unnecessary comments
HelenPolychroni Feb 13, 2023
f049463
Handle equivalent query plans using relational algebraic equivalence …
HelenPolychroni Feb 13, 2023
1034d95
Create a function to handle the query transformation
HelenPolychroni Feb 13, 2023
fd63c41
test some things for OR Optimizations
HelenPolychroni Feb 16, 2023
82b8154
Test some things for OR Optimization's query
HelenPolychroni Feb 16, 2023
05a863d
Add optimization for AND and OR operators
HelenPolychroni Feb 16, 2023
8b9004f
Handle Equivalence Transformation Rules
HelenPolychroni Feb 16, 2023
729fe53
Add attribute unique in some columns
HelenPolychroni Feb 16, 2023
b544c69
Add some comments
HelenPolychroni Feb 18, 2023
6cc2e5a
Add some comments
HelenPolychroni Feb 18, 2023
fd78a63
Add some comments
HelenPolychroni Feb 18, 2023
253a1f1
Remove some unnecessary print messages
HelenPolychroni Feb 18, 2023
7088763
Handle hash index
HelenPolychroni Feb 18, 2023
d29c457
Handle hash
HelenPolychroni Feb 18, 2023
76949b4
Implement select_where_with_hash function
HelenPolychroni Feb 18, 2023
71f0bf0
Add some comments
HelenPolychroni Feb 18, 2023
800824a
Handle hash index in select
HelenPolychroni Feb 18, 2023
0950d30
Fix some things
HelenPolychroni Feb 18, 2023
418a285
Create find function in hash index
HelenPolychroni Feb 18, 2023
396d081
Fix some things
HelenPolychroni Feb 18, 2023
3b60010
Complete select_where_with_hash
HelenPolychroni Feb 18, 2023
e881ec5
Make some columns unique
HelenPolychroni Feb 18, 2023
5ec293c
Make some columns unique
HelenPolychroni Feb 19, 2023
fbdd315
Remove some unnecessary comments
HelenPolychroni Feb 19, 2023
370c4a1
Make some columns unique
HelenPolychroni Feb 19, 2023
1844e9c
Remove some unnecessary comments
HelenPolychroni Feb 19, 2023
9c2eccb
Fixed some things
HelenPolychroni Feb 20, 2023
952fcea
Finish extendible hashing
HelenPolychroni Feb 20, 2023
a597ca3
Fixed some things
HelenPolychroni Feb 20, 2023
7fbbd77
Finish extendible hashing
HelenPolychroni Feb 20, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"python.analysis.extraPaths": [
"./miniDB"
]
}
37 changes: 29 additions & 8 deletions mdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ def in_paren(qsplit, ind):
def create_query_plan(query, keywords, action):
'''
Given a query, the set of keywords that we expect to pe present and the overall action, return the query plan for this query.

This can and will be used recursively
'''

Expand Down Expand Up @@ -95,16 +94,39 @@ def create_query_plan(query, keywords, action):

if action=='create table':
args = dic['create table'][dic['create table'].index('('):dic['create table'].index(')')+1]
#print("\n")
dic['create table'] = dic['create table'].removesuffix(args).strip()

# 4 primary key
arg_nopk = args.replace('primary key', '')[1:-1]
arglist = [val.strip().split(' ') for val in arg_nopk.split(',')]
dic['column_names'] = ','.join([val[0] for val in arglist])
dic['column_types'] = ','.join([val[1] for val in arglist])

# 4 unique columns
arg_nounique = args.replace('unique', '')[1:-1]
arglist1 = [val.strip().split(' ') for val in arg_nounique.split(',')]

dic['column_names'] = ','.join([val[0] for val in arglist1])
dic['column_types'] = ','.join([val[1] for val in arglist1])

if 'primary key' in args:
#print("primary here")
arglist = args[1:-1].split(' ')
dic['primary key'] = arglist[arglist.index('primary')-2]

dic['primary key'] = arglist[arglist.index('primary')-2] # -2 tp find key's name, -1 to find key's data type e.g string/ integer
else:
dic['primary key'] = None

# handle unique columns
if 'unique' in args:
arglist1 = args[1:-1].split(' ')
indx_lst = [idx for idx, value in enumerate(arglist1) if value == 'unique' or value == 'unique,']

dic['unique'] = ','.join(arglist1[n-2] for n in indx_lst)
else:
dic['unique'] = None
#print("\n")
#print(dic)
#print("\n")

if action=='import':
dic = {'import table' if key=='import' else key: val for key, val in dic.items()}
Expand Down Expand Up @@ -175,7 +197,8 @@ def interpret(query):
'unlock table': ['unlock table', 'force'],
'delete from': ['delete from', 'where'],
'update table': ['update table', 'set', 'where'],
'create index': ['create index', 'on', 'using'],
#'create index': ['create index', 'on', 'using'],
'create index': ['create index', 'on', 'column', 'using'],
'drop index': ['drop index'],
'create view' : ['create view', 'as']
}
Expand Down Expand Up @@ -205,9 +228,7 @@ def execute_dic(dic):
def interpret_meta(command):
"""
Interpret meta commands. These commands are used to handle DB stuff, something that can not be easily handled with mSQL given the current architecture.

The available meta commands are:

lsdb - list databases
lstb - list tables
cdb - change/create database
Expand Down Expand Up @@ -295,4 +316,4 @@ def remove_db(db_name):
if isinstance(result,Table):
result.show()
except Exception:
print(traceback.format_exc())
print(traceback.format_exc())
26 changes: 22 additions & 4 deletions miniDB/btree.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def __init__(self, b, values=None, ptrs=None,left_sibling=None, right_sibling=No
self.parent = parent # the index of a buckets parent
self.is_leaf = is_leaf # a boolean value signaling whether the node is a leaf or not


def find(self, value, return_ops=False):
'''
Returns the index of the next node to search for a value if the node is not a leaf (a ptrs of the available ones).
Expand All @@ -28,10 +28,20 @@ def find(self, value, return_ops=False):
ops = 0 # number of operations (<>= etc). Used for benchmarking
if self.is_leaf: #
return


'''
if (isinstance(value, int)):
value = float(value)
'''
#print(value)
# for each value in the node, if the user supplied value is smaller, return the btrees value index
# else (no value in the node is larger) return the last ptr
#print(self.values)
#for index, existing_val in enumerate(self.values):
#print("existing val: ", existing_val)
#print("index: ", index)
for index, existing_val in enumerate(self.values):
#print("existing val: ", existing_val)
ops+=1
if value is None or existing_val is None:
continue
Expand Down Expand Up @@ -221,8 +231,6 @@ def split(self, node_id):
self.split(node.parent)




def show(self):
'''
Show important info for each node (sort by level - root first, then left to right).
Expand Down Expand Up @@ -288,9 +296,18 @@ def find(self, operator, value):
operator: string. The provided evaluation operator.
value: float. The value being searched for.
'''

'''
if (isinstance(value, int)):
value = float(value)
'''
results = []


# find the index of the node that the element should exist in
leaf_idx, ops = self._search(value, True)
#print("leaf idx: ",leaf_idx)
#print("ops: ", ops)
target_node = self.nodes[leaf_idx]

if operator == '=':
Expand Down Expand Up @@ -343,6 +360,7 @@ def find(self, operator, value):
target_node = self.nodes[target_node.left_sibling]
results.extend(target_node.ptrs)


# print the number of operations (usefull for benchamrking)
# print(f'With BTree -> {ops} comparison operations')
return results
Loading