rdbms

How to store a row's multiple column's sum on that same table's same row's another column? [duplicate]

你。 提交于 2019-12-25 18:03:06
问题 This question already has answers here : How can I write a user defined function in MySQL so that when I delete a row from one table, that particular row from another table also gets deleted? (3 answers) Closed last year . CREATE TABLE `student` ( `student_id` int(5) NOT NULL AUTO_INCREMENT, `student_first_name` varchar(30) not null, `student_lase_name` varchar(30) not null, `student_roll_no` int(5) not null, `student_class` int(2) not null, PRIMARY KEY (`student_id`) ); CREATE TABLE `result

How to design this RDBMS schema?

痞子三分冷 提交于 2019-12-25 09:28:48
问题 So we have foods, which are usually of one single unit and recipes, which consist of varying amount of different foods. We want to track a few basic things like the price and the nutrition info. How would we design RDBMS schema for this? So, here is the probably most obvious solution: [Foods] : ID, Name, Carbs, Protein, Fat, Price [RecipeIngredients] : ID, FoodID, RecipeID, AmountOfFood [Recipes] : ID, Name However, since recipe has almost all the same actions as foods, I need to create a lot

In a database table, what is the maximum number of primary keys?

你离开我真会死。 提交于 2019-12-25 07:26:10
问题 In a database table, what is the maximum number of primary keys? 回答1: You only have one primary key (or possibly none, although that makes various things tricky) but the key can consist of more than one column. Personally, I've found the composite primary keys (ones with more than one column) have been a pain when I've used them, but that could be due to my incompetence. Even so, in some of the cases it made logical sense to use a composite key and I probably wouldn't have changed the design.

How do i aggregate data from 2 columns referencing another table and also get the monthly totals for the past 3 months?

こ雲淡風輕ζ 提交于 2019-12-24 19:16:58
问题 Using the data below: How do I get the sum of the cost of each incident based on two columns (crime_incidentid, similar_incidentid) in the listofincidents table? Also how do I get the sums for the past 3 months (January, February and March)? create table crimeincidents ( id int not null, name varchar(20), primary key (id) ); create table listofincidents ( id int not null, incidentdate datetime not null, crime_incidentid int not null, similar_incidentid int not null, cost_to_city decimal(8,2),

Are SQL queries limited by the DBMS used?

北慕城南 提交于 2019-12-24 19:04:34
问题 I've seen reading recently to try and understand initially what the difference was between SQL and MySQL, and I encountered a useful quote from another post "Basically, MySQL is one of many books holding everything, and SQL is how you go about reading that book.". Depending on the backend used, i.e MySQL vs PostgreSQL. Can a SQL query suddenly not become valid? In particular, relational DBMS vs non-relational DBMS ? 回答1: Each database implements its own dialect of the SQL language. The

Is there a way to represent relationship between a tuple and to a table in E-R diagram?

我是研究僧i 提交于 2019-12-24 15:53:02
问题 I know this might sound a bit ridiculous, but I got a doubt that if we can represent relationship between two tables, how the two table's data is related, is there a way to represent relationship like, each registered user has a seperate pagelikes table. To make it more clear about my doubt, let me explain in this way, students enrolling for a few courses, say c, c++, java or others. Then, we can say: Student -(enrols for)- courses which means that student x can register for courses like c, c

How to improve performance of this query?

我是研究僧i 提交于 2019-12-24 12:57:34
问题 With reference to SQL Query how to summarize students record by date? I was able to get the report I wanted. I was told in real world the students table will have 30 Millions of records. I do have index on (StudentID, Date). Any suggestions to improve the performance or is there a better way to build the report ? Right now I have the following query ;with cte as ( select id, studentid, date, '#'+subject+';'+grade+';'+convert(varchar(10), date, 101) report from student ) -- insert into

Solr / rdbms, where to store additonal data

北慕城南 提交于 2019-12-24 11:51:43
问题 What would be considered best practice when you need additional data about facet results. ie. i need a friendlyname / image / meta keywords / description / and more.. for product categories. (when faceting on categories) include it in the document? (can lead to looots of duplication) introduce category as a new index in solr (or fake by doctype=category field in solr) use a rdbms to lookup additional data using a SELECT WHERE IN (..category facet result ids..) Thanks, Remco 回答1: I would think

Caching moderate amounts of data in a web app - DB or flat files?

我与影子孤独终老i 提交于 2019-12-24 11:35:39
问题 A web app I'm working on requires frequent parsing of diverse web resources (HTML, XML, RSS, etc). Once downloaded, I need to cache these resources to minimize network load. The app requires a very straightforward cache policy: only re-download a cached resource when more than X minutes have passed since the access time. Should I: Store both the access time (e.g. 6/29/09 at 10:50 am) and the resource itself in the database. Store the access time and a unique identifier in the database. The

(Xpages) SOA or Direct Database Access

北战南征 提交于 2019-12-24 10:59:18
问题 I'm currently doing an application usign Lotus Notes' XPages. I'm planning to use XPages(or Lotus Notes in general) as the front-end/UI/Design only (not a data storage), while an RDBMS (Oracle, MySQL) as the data storage. I found out that XPages currently doesn't support external RDBMS as data source. Based on my research, I have 2 options (or if you know of others, please put it in the comment section), either to so a SOA approach (where I will get my data using web services) or a direct