Commit 2d6d6f95 authored by Javinator9889's avatar Javinator9889 🎼

Updated database model and added methods for "InsertOperations"

parent 1d72ee12
This diff is collapsed.
......@@ -56,4 +56,29 @@ class InsertOperations(DatabaseOperationsBase):
is_metadata_by_user) VALUES (%s, %s, %s, %s, %s, %s)
"""
self.__session.execute(query, (file_id, video_id, audio_quality, audio_format, times_requested,
is_metadata_by_user))
\ No newline at end of file
is_metadata_by_user))
def registerNewPlaylist(self, playlist_id: str, number_elements: int, times_requested: int):
query = """
INSERT INTO YouTubeMDApp.playlist(playlist_id, number_elements, times_requested) VALUES (%s, %s, %s)
"""
self.__session.execute(query, (playlist_id, number_elements, times_requested))
def registerNewSongForPlaylist(self, playlist_id: str, file_id: str, playlist_quality: str, playlist_format: str):
query = """
INSERT INTO YouTubeMDApp.playlist_has_music
(playlist_playlist_id, music_file_id, playlist_quality, playlist_format) VALUES (%s, %s, %s, %s)
"""
self.__session.execute(query, (playlist_id, file_id, playlist_quality, playlist_format))
def registerNewSongMetadata(self, title: str, artist: str, cover: str, duration: str, file_id: str):
query = """
INSERT INTO YouTubeMDApp.metadata(title, artist, cover, duration, music_file_id) VALUES (%s, %s, %s, %s, %s)
"""
self.__session.execute(query, (title, artist, cover, duration, file_id))
def registerNewSongInHistory(self, user_id: int, file_id: str):
query = """
INSERT INTO YouTubeMDApp.history(user_id, file_id) VALUES (%s, %s)
"""
self.__session.execute(query, (user_id, file_id))
......@@ -4,7 +4,7 @@ CREATE TABLE IF NOT EXISTS history (user_id int NOT NULL, file_id varchar NOT NU
CREATE TABLE IF NOT EXISTS metadata (title varchar, artist varchar, cover text, duration varchar, music_file_id varchar NOT NULL, PRIMARY KEY (music_file_id));
CREATE TABLE IF NOT EXISTS music (file_id varchar NOT NULL,video_id varchar, audio_quality int, audio_format int, times_requested int, is_metadata_by_user boolean, PRIMARY KEY (file_id));
CREATE TABLE IF NOT EXISTS playlist (playlist_id varchar NOT NULL, number_elements int, times_requested int, PRIMARY KEY (playlist_id));
CREATE TABLE IF NOT EXISTS playlist_has_music (playlist_playlist_id varchar NOT NULL, music_file_id varchar NOT NULL);
CREATE TABLE IF NOT EXISTS playlist_has_music (playlist_playlist_id varchar NOT NULL, music_file_id varchar NOT NULL, playlist_quality int, playlist_format int);
CREATE TABLE IF NOT EXISTS preferences (audio_quality varchar, audio_format varchar, os varchar, should_ask_metadata boolean, user_id int NOT NULL, PRIMARY KEY (user_id));
CREATE TABLE IF NOT EXISTS "User" (user_id int NOT NULL, username varchar, name text, PRIMARY KEY (user_id));
CREATE TABLE IF NOT EXISTS Statistics (lang varchar, downloads int, last_time_active datetime, user_id int NOT NULL, PRIMARY KEY(user_id));
\ No newline at end of file
......@@ -151,6 +151,18 @@ o
<text x="26" y="60" fill="rgb(0,0,0)" fill-opacity="1.0" font-size="10" stroke="none">
times_requested
</text>
<text x="16" y="74" fill="rgb(255,0,0)" fill-opacity="1.0" font-size="10" stroke="none">
o
</text>
<text x="26" y="74" fill="rgb(0,0,0)" fill-opacity="1.0" font-size="10" stroke="none">
playlist_quality
</text>
<text x="16" y="88" fill="rgb(255,0,0)" fill-opacity="1.0" font-size="10" stroke="none">
o
</text>
<text x="26" y="88" fill="rgb(0,0,0)" fill-opacity="1.0" font-size="10" stroke="none">
playlist_format
</text>
</g>
<g fill="rgb(164,225,255)" stroke="rgb(0,0,255)" fill-opacity="1.0" stroke-opacity="1.0" clip-path="url(#clipPath6_0_)" transform="translate(302,31)" >
<rect x="0" y="0" width="169" height="109" rx="20" ry="20" />
......@@ -179,6 +191,30 @@ o
name
</text>
</g>
<g fill="rgb(164,225,255)" stroke="rgb(0,0,255)" fill-opacity="1.0" stroke-opacity="1.0" clip-path="url(#clipPath5_0_)" transform="translate(39,29)" >
<rect x="0" y="0" width="169" height="109" rx="20" ry="20" />
<text id="Statistics" x="62" y="14" fill="rgb(0,0,255)" font-weight="bold" fill-opacity="1.0" font-size="10" stroke="none">
Statistics
</text>
<text x="16" y="32" fill="rgb(255,0,0)" fill-opacity="1.0" font-size="10" stroke="none">
o
</text>
<text x="26" y="32" fill="rgb(0,0,0)" fill-opacity="1.0" font-size="10" stroke="none">
lang
</text>
<text x="16" y="46" fill="rgb(255,0,0)" fill-opacity="1.0" font-size="10" stroke="none">
o
</text>
<text x="26" y="46" fill="rgb(0,0,0)" fill-opacity="1.0" font-size="10" stroke="none">
downloads
</text>
<text x="16" y="60" fill="rgb(255,0,0)" fill-opacity="1.0" font-size="10" stroke="none">
o
</text>
<text x="26" y="60" fill="rgb(0,0,0)" fill-opacity="1.0" font-size="10" stroke="none">
last_time_active
</text>
</g>
<g fill="rgb(164,225,255)" stroke="rgb(0,0,255)" fill-opacity="1.0" stroke-opacity="1.0" clip-path="url(#clipPath2_0_)" transform="translate(305,287)" >
<rect x="0" y="0" width="169" height="109" rx="20" ry="20" />
<text id="Music" x="70" y="14" fill="rgb(0,0,255)" font-weight="bold" fill-opacity="1.0" font-size="10" stroke="none">
......@@ -224,29 +260,5 @@ o
is_metadata_by_user
</text>
</g>
<g fill="rgb(164,225,255)" stroke="rgb(0,0,255)" fill-opacity="1.0" stroke-opacity="1.0" clip-path="url(#clipPath5_0_)" transform="translate(39,29)" >
<rect x="0" y="0" width="169" height="109" rx="20" ry="20" />
<text id="Statistics" x="62" y="14" fill="rgb(0,0,255)" font-weight="bold" fill-opacity="1.0" font-size="10" stroke="none">
Statistics
</text>
<text x="16" y="32" fill="rgb(255,0,0)" fill-opacity="1.0" font-size="10" stroke="none">
o
</text>
<text x="26" y="32" fill="rgb(0,0,0)" fill-opacity="1.0" font-size="10" stroke="none">
lang
</text>
<text x="16" y="46" fill="rgb(255,0,0)" fill-opacity="1.0" font-size="10" stroke="none">
o
</text>
<text x="26" y="46" fill="rgb(0,0,0)" fill-opacity="1.0" font-size="10" stroke="none">
downloads
</text>
<text x="16" y="60" fill="rgb(255,0,0)" fill-opacity="1.0" font-size="10" stroke="none">
o
</text>
<text x="26" y="60" fill="rgb(0,0,0)" fill-opacity="1.0" font-size="10" stroke="none">
last_time_active
</text>
</g>
</svg>
\ No newline at end of file
This diff is collapsed.
<?xml version = '1.0' encoding = 'UTF-8'?>
<oracle.dbtools.crest.model.design.datatypes.DataTypesDesign>
<object objectType="main_view" objectID="CFDE5FC8-D6A4-DF2D-FAA9-F1FC327377FA" name="DataTypes" visible="false"/>
<object objectType="main_view" objectID="CFDE5FC8-D6A4-DF2D-FAA9-F1FC327377FA" name="" visible="false"/>
</oracle.dbtools.crest.model.design.datatypes.DataTypesDesign>
<?xml version = '1.0' encoding = 'UTF-8'?>
<oracle.dbtools.crest.model.design.logical.LogicalDesign>
<object objectType="Entity" objectID="1558C95F-4CEC-1E30-AA15-58B7C6ACD81B" name="Metadata" seqName="seg_0" propertyClassName="oracle.dbtools.crest.model.design.logical.Entity" propertyParentId="6F505A55-3C56-E65E-61AB-E3E34318876E" propertySourceId="" propertyTargetId=""/>
<object objectType="Entity" objectID="FB782D70-50E0-0A98-4654-5E94050F8458" name="Music" seqName="seg_0" propertyClassName="oracle.dbtools.crest.model.design.logical.Entity" propertyParentId="6F505A55-3C56-E65E-61AB-E3E34318876E" propertySourceId="" propertyTargetId=""/>
<object objectType="Entity" objectID="52FEBBBF-C76E-AEF4-45C5-3341E59BD946" name="Playlist" seqName="seg_0" propertyClassName="oracle.dbtools.crest.model.design.logical.Entity" propertyParentId="6F505A55-3C56-E65E-61AB-E3E34318876E" propertySourceId="" propertyTargetId=""/>
<object objectType="Entity" objectID="312E0255-FAA7-1630-54E5-A4FCB50F6276" name="Preferences" seqName="seg_0" propertyClassName="oracle.dbtools.crest.model.design.logical.Entity" propertyParentId="6F505A55-3C56-E65E-61AB-E3E34318876E" propertySourceId="" propertyTargetId=""/>
<object objectType="Entity" objectID="B1A287E6-50CA-DB8B-0AAD-60C303A2A402" name="Statistics" seqName="seg_0" propertyClassName="oracle.dbtools.crest.model.design.logical.Entity" propertyParentId="6F505A55-3C56-E65E-61AB-E3E34318876E" propertySourceId="" propertyTargetId=""/>
<object objectType="Entity" objectID="52FEBBBF-C76E-AEF4-45C5-3341E59BD946" name="Playlist" seqName="seg_0" propertyClassName="oracle.dbtools.crest.model.design.logical.Entity" propertyParentId="6F505A55-3C56-E65E-61AB-E3E34318876E" propertySourceId="" propertyTargetId=""/>
<object objectType="Entity" objectID="96125017-F1D2-153D-CBAC-D12E0939CF4E" name="User" seqName="seg_0" propertyClassName="oracle.dbtools.crest.model.design.logical.Entity" propertyParentId="6F505A55-3C56-E65E-61AB-E3E34318876E" propertySourceId="" propertyTargetId=""/>
<object objectType="Relation" objectID="B934A368-41CA-2247-7505-4DDD707ADAB7" name="creates" seqName="seg_0" propertyClassName="oracle.dbtools.crest.model.design.logical.Relation" propertyParentId="6F505A55-3C56-E65E-61AB-E3E34318876E" propertySourceId="96125017-F1D2-153D-CBAC-D12E0939CF4E" propertyTargetId="B1A287E6-50CA-DB8B-0AAD-60C303A2A402"/>
<object objectType="Relation" objectID="46906DFA-66DD-2DD5-790C-7A87FFE7755C" name="has" seqName="seg_0" propertyClassName="oracle.dbtools.crest.model.design.logical.Relation" propertyParentId="6F505A55-3C56-E65E-61AB-E3E34318876E" propertySourceId="FB782D70-50E0-0A98-4654-5E94050F8458" propertyTargetId="1558C95F-4CEC-1E30-AA15-58B7C6ACD81B"/>
<object objectType="Relation" objectID="DDBAFE8B-B820-1773-EE96-8B363262CAA9" name="History" seqName="seg_0" propertyClassName="oracle.dbtools.crest.model.design.logical.Relation" propertyParentId="6F505A55-3C56-E65E-61AB-E3E34318876E" propertySourceId="96125017-F1D2-153D-CBAC-D12E0939CF4E" propertyTargetId="FB782D70-50E0-0A98-4654-5E94050F8458"/>
<object objectType="Entity" objectID="B1A287E6-50CA-DB8B-0AAD-60C303A2A402" name="Statistics" seqName="seg_0" propertyClassName="oracle.dbtools.crest.model.design.logical.Entity" propertyParentId="6F505A55-3C56-E65E-61AB-E3E34318876E" propertySourceId="" propertyTargetId=""/>
<object objectType="Entity" objectID="FB782D70-50E0-0A98-4654-5E94050F8458" name="Music" seqName="seg_0" propertyClassName="oracle.dbtools.crest.model.design.logical.Entity" propertyParentId="6F505A55-3C56-E65E-61AB-E3E34318876E" propertySourceId="" propertyTargetId=""/>
<object objectType="Relation" objectID="1D1B52B1-8974-5046-5AB7-7AB4BF89C08A" name="Playlist_has_Music" seqName="seg_0" propertyClassName="oracle.dbtools.crest.model.design.logical.Relation" propertyParentId="6F505A55-3C56-E65E-61AB-E3E34318876E" propertySourceId="52FEBBBF-C76E-AEF4-45C5-3341E59BD946" propertyTargetId="FB782D70-50E0-0A98-4654-5E94050F8458"/>
<object objectType="Relation" objectID="46906DFA-66DD-2DD5-790C-7A87FFE7755C" name="has" seqName="seg_0" propertyClassName="oracle.dbtools.crest.model.design.logical.Relation" propertyParentId="6F505A55-3C56-E65E-61AB-E3E34318876E" propertySourceId="FB782D70-50E0-0A98-4654-5E94050F8458" propertyTargetId="1558C95F-4CEC-1E30-AA15-58B7C6ACD81B"/>
<object objectType="Relation" objectID="B934A368-41CA-2247-7505-4DDD707ADAB7" name="creates" seqName="seg_0" propertyClassName="oracle.dbtools.crest.model.design.logical.Relation" propertyParentId="6F505A55-3C56-E65E-61AB-E3E34318876E" propertySourceId="96125017-F1D2-153D-CBAC-D12E0939CF4E" propertyTargetId="B1A287E6-50CA-DB8B-0AAD-60C303A2A402"/>
<object objectType="Relation" objectID="C49FD692-24A0-3030-2280-A4D5B8CDFC01" name="sets" seqName="seg_0" propertyClassName="oracle.dbtools.crest.model.design.logical.Relation" propertyParentId="6F505A55-3C56-E65E-61AB-E3E34318876E" propertySourceId="96125017-F1D2-153D-CBAC-D12E0939CF4E" propertyTargetId="312E0255-FAA7-1630-54E5-A4FCB50F6276"/>
<object objectType="Relation" objectID="DDBAFE8B-B820-1773-EE96-8B363262CAA9" name="History" seqName="seg_0" propertyClassName="oracle.dbtools.crest.model.design.logical.Relation" propertyParentId="6F505A55-3C56-E65E-61AB-E3E34318876E" propertySourceId="96125017-F1D2-153D-CBAC-D12E0939CF4E" propertyTargetId="FB782D70-50E0-0A98-4654-5E94050F8458"/>
</oracle.dbtools.crest.model.design.logical.LogicalDesign>
......@@ -54,6 +54,32 @@
<logicalDatatype>LOGDT011</logicalDatatype>
<ownDataTypeParameters>,,</ownDataTypeParameters>
</Attribute>
<Attribute name="playlist_quality" id="BCFF4641-2EDB-B760-2023-3BECCBA5CF60">
<createdBy>Javier Alonso Silva</createdBy>
<createdTime>2018-06-20 19:10:08 UTC</createdTime>
<ownerDesignName>database_design</ownerDesignName>
<engineerTo>
<item key="C5DFC5DD-35E9-B422-B2BF-B7648E7DE99B" value="true"/>
</engineerTo>
<nullsAllowed>true</nullsAllowed>
<useDomainConstraints>false</useDomainConstraints>
<use>1</use>
<logicalDatatype>LOGDT011</logicalDatatype>
<ownDataTypeParameters>,,</ownDataTypeParameters>
</Attribute>
<Attribute name="playlist_format" id="80560FD1-D982-C45C-53EA-DC66BABB04CA">
<createdBy>Javier Alonso Silva</createdBy>
<createdTime>2018-06-20 19:10:24 UTC</createdTime>
<ownerDesignName>database_design</ownerDesignName>
<engineerTo>
<item key="C5DFC5DD-35E9-B422-B2BF-B7648E7DE99B" value="true"/>
</engineerTo>
<nullsAllowed>true</nullsAllowed>
<useDomainConstraints>false</useDomainConstraints>
<use>1</use>
<logicalDatatype>LOGDT011</logicalDatatype>
<ownDataTypeParameters>,,</ownDataTypeParameters>
</Attribute>
</attributes>
<identifiers itemClass="oracle.dbtools.crest.model.design.logical.CandidateKey">
<identifier id="E3C428C4-0B62-6F66-F2BC-DB1AEE9F9400" name="Playlist PK">
......
......@@ -32,7 +32,7 @@
</OView>
<OView class="oracle.dbtools.crest.swingui.relational.TVTable" oid="47A181FD-9D20-6987-2EAE-0B7F53C88FB3" otype="Table" vid="44FE6C73-9DC7-1AD1-9776-430C14CF03AD">
<hideElementsInCurrentOnly>false</hideElementsInCurrentOnly>
<bounds x="2" y="30" width="306" height="112"/>
<bounds x="2" y="30" width="306" height="142"/>
</OView>
<OView class="oracle.dbtools.crest.swingui.relational.TVTable" oid="D088A558-CA22-9A96-F938-4F7712E4AEF1" otype="Table" vid="A05D5803-ED8E-B325-BEA5-C740A63CE2DF">
<hideElementsInCurrentOnly>false</hideElementsInCurrentOnly>
......@@ -63,7 +63,7 @@
<lineWidth>1</lineWidth>
<points>
<point x="130" y="390"/>
<point x="130" y="142"/>
<point x="130" y="172"/>
</points>
</Connector>
<Connector class="oracle.dbtools.crest.swingui.relational.TVFKRelation" oid="51EE3780-3B5D-E1A1-65B0-7ED699DD5948" otype="FKIndexAssociation" vid_source="D2EC0BC0-F700-1329-2716-2C21984B5622" vid_target="96F7DC31-5392-F6F5-90A9-53BD7AAFBAD7">
......@@ -99,7 +99,7 @@
<lineWidth>1</lineWidth>
<points>
<point x="262" y="240"/>
<point x="262" y="142"/>
<point x="262" y="172"/>
</points>
</Connector>
<Connector class="oracle.dbtools.crest.swingui.relational.TVFKRelation" oid="C7DC4550-6D2C-B38B-5C23-5E37D6D8832D" otype="FKIndexAssociation" vid_source="D2EC0BC0-F700-1329-2716-2C21984B5622" vid_target="A05D5803-ED8E-B325-BEA5-C740A63CE2DF">
......
......@@ -37,6 +37,28 @@
<colAssociation fkAssociation="B59DC6EC-C75B-86D4-AFA3-705630B49873" referredColumn="1F1E7DDA-F1AD-9264-27B3-CC9CC8B4A8FB"/>
</associations>
</Column>
<Column name="playlist_quality" id="37D138F2-15D2-216D-04B4-9E7D510E4AB4">
<createdBy>Javier Alonso Silva</createdBy>
<createdTime>2018-06-20 19:09:34 UTC</createdTime>
<ownerDesignName>database_design</ownerDesignName>
<nullsAllowed>true</nullsAllowed>
<useDomainConstraints>false</useDomainConstraints>
<use>1</use>
<logicalDatatype>LOGDT011</logicalDatatype>
<ownDataTypeParameters>,,</ownDataTypeParameters>
<autoIncrementCycle>false</autoIncrementCycle>
</Column>
<Column name="playlist_format" id="8C829605-2812-5AB3-DA74-D18B5CDF8A18">
<createdBy>Javier Alonso Silva</createdBy>
<createdTime>2018-06-20 19:09:45 UTC</createdTime>
<ownerDesignName>database_design</ownerDesignName>
<nullsAllowed>true</nullsAllowed>
<useDomainConstraints>false</useDomainConstraints>
<use>1</use>
<logicalDatatype>LOGDT011</logicalDatatype>
<ownDataTypeParameters>,,</ownDataTypeParameters>
<autoIncrementCycle>false</autoIncrementCycle>
</Column>
</columns>
<indexes itemClass="oracle.dbtools.crest.model.design.relational.Index">
<ind_PK_UK id="26077F0B-DF80-4C22-9679-E91111201BFD" name="Playlist_has_Music_PK">
......
......@@ -4,7 +4,7 @@ CREATE TABLE IF NOT EXISTS history (user_id int NOT NULL, file_id varchar NOT NU
CREATE TABLE IF NOT EXISTS metadata (title varchar, artist varchar, cover text, duration varchar, music_file_id varchar NOT NULL, PRIMARY KEY (music_file_id));
CREATE TABLE IF NOT EXISTS music (file_id varchar NOT NULL,video_id varchar, audio_quality int, audio_format int, times_requested int, is_metadata_by_user boolean, PRIMARY KEY (file_id));
CREATE TABLE IF NOT EXISTS playlist (playlist_id varchar NOT NULL, number_elements int, times_requested int, PRIMARY KEY (playlist_id));
CREATE TABLE IF NOT EXISTS playlist_has_music (playlist_playlist_id varchar NOT NULL, music_file_id varchar NOT NULL);
CREATE TABLE IF NOT EXISTS playlist_has_music (playlist_playlist_id varchar NOT NULL, music_file_id varchar NOT NULL, playlist_quality int, playlist_format int);
CREATE TABLE IF NOT EXISTS preferences (audio_quality varchar, audio_format varchar, os varchar, should_ask_metadata boolean, user_id int NOT NULL, PRIMARY KEY (user_id));
CREATE TABLE IF NOT EXISTS "User" (user_id int NOT NULL, username varchar, name text, PRIMARY KEY (user_id));
CREATE TABLE IF NOT EXISTS Statistics (lang varchar, downloads int, last_time_active datetime, user_id int NOT NULL, PRIMARY KEY(user_id));
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment